:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --bg: #f1f3f4;
  --card: #ffffff;
  --text: #202124;
  --muted: #5f6368;
  --border: #dadce0;
  --high: #ea4335;
  --medium: #fbbc04;
  --low: #34a853;
  --todo: #9aa0a6;
  --wip: #1a73e8;
  --review: #f29900;
  --done: #34a853;
  --shadow: 0 1px 3px rgba(60,64,67,.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Sarabun', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a73e8, #34a853);
}
.login-card {
  background: var(--card);
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2);
  width: 360px;
  max-width: 90vw;
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; text-align: center; }
.login-card .sub { color: var(--muted); text-align: center; margin-bottom: 24px; font-size: 14px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }

.btn {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn-block { width: 100%; margin-top: 20px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }

.error-msg { color: var(--high); font-size: 13px; margin-top: 12px; text-align: center; min-height: 18px; }

/* ---------- Layout ---------- */
.topbar {
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 700; font-size: 18px; }
.topbar nav a { margin: 0 10px; color: var(--muted); font-weight: 500; }
.topbar nav a.active { color: var(--primary); }
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 14px; }

.container { max-width: 1200px; margin: 24px auto; padding: 0 24px; }
.page-title { font-size: 20px; margin-bottom: 16px; }

/* ---------- Cards / Dashboard ---------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid-4, .grid-3 { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.stat { text-align: center; }
.stat .num { font-size: 32px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 13px; }

.dept-card h3 { font-size: 15px; margin-bottom: 10px; }
.dept-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; color: #fff; }
.badge.todo { background: var(--todo); }
.badge.wip { background: var(--wip); }
.badge.review { background: var(--review); }
.badge.done { background: var(--done); }
.badge.high { background: var(--high); }
.badge.medium { background: var(--medium); color: #000; }
.badge.low { background: var(--low); }

/* ---------- Kanban ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .kanban { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .kanban { grid-template-columns: 1fr; } }
.col {
  background: #e8eaed;
  border-radius: 12px;
  padding: 10px;
  min-height: 200px;
}
.col h3 { font-size: 14px; padding: 4px 6px 10px; display: flex; justify-content: space-between; }
.col h3 .cnt { color: var(--muted); font-weight: 400; }
.task {
  background: var(--card);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: grab;
  border-left: 3px solid var(--todo);
}
.task.high { border-left-color: var(--high); }
.task.medium { border-left-color: var(--medium); }
.task.low { border-left-color: var(--low); }
.task .t-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.task .t-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.task.dragging { opacity: .4; }
.col.drop-target { outline: 2px dashed var(--primary); }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--card);
  border-radius: 12px;
  padding: 24px;
  width: 460px; max-width: 92vw;
  max-height: 90vh; overflow: auto;
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal .row { display: flex; gap: 10px; }
.modal .row > * { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ---------- Agent chat ---------- */
.chat-box { max-height: 280px; overflow-y: auto; margin: 12px 0; }
.chat-msg { padding: 8px 12px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; white-space: pre-wrap; }
.chat-msg.user { background: #e8f0fe; }
.chat-msg.agent { background: #e6f4ea; }
.muted { color: var(--muted); font-size: 13px; }
.hidden { display: none !important; }
