/* ═══════════════════════════════════════════════════════════
   GHAYA COO — Professional Botanical Dashboard
   Deep forest green · warm ivory · gold accent
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Surfaces */
  --bg:        #f7f5f0;
  --bg-2:      #efece4;
  --bg-3:      #e6e2d8;
  --card:      #ffffff;
  --card-2:    #faf9f6;
  --line:      #ddd8cc;
  --line-soft: #ece8de;

  /* Text */
  --text:      #1a2e22;
  --text-2:    #2d4a38;
  --muted:     #6b7568;
  --muted-2:   #9aa396;

  /* Brand greens */
  --green-900: #0f2e1e;
  --green-800: #1a4731;
  --green-700: #235c3f;
  --green-600: #2d7350;
  --green-500: #3a8a62;
  --green-400: #5aab82;
  --green-100: #e4efe7;
  --green-50:  #f0f7f2;

  /* Accents */
  --gold:      #b8923e;
  --gold-light:#d4b06a;
  --gold-soft: #f5ecd8;

  /* Status */
  --danger:    #c0392b;
  --danger-soft:#fce8e6;
  --warn:      #b47a1e;
  --warn-soft: #faf0dc;
  --ok:        #2d7a4f;
  --ok-soft:   #e4f2ea;

  /* Radius & shadow */
  --r-sm:  8px;
  --r-md:  12px;
  --r-lg:  16px;
  --r-xl:  20px;
  --r-2xl: 24px;

  --shadow-xs: 0 1px 2px rgba(15, 46, 30, .04);
  --shadow-sm: 0 2px 6px rgba(15, 46, 30, .06);
  --shadow-md: 0 4px 14px rgba(15, 46, 30, .08);
  --shadow-lg: 0 8px 28px rgba(15, 46, 30, .10);
  --shadow-xl: 0 16px 48px rgba(15, 46, 30, .12);

  --transition: .18s cubic-bezier(.4, 0, .2, 1);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  min-height: 100vh;
}

/* ── Login ──────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(45, 115, 80, .10), transparent 60%),
    radial-gradient(ellipse 60% 50% at 110% 110%, rgba(184, 146, 62, .08), transparent 60%),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--green-800), var(--green-500), var(--gold));
}

.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 32px; }

.brand-mark {
  width: 52px; height: 52px;
  border-radius: var(--r-lg);
  display: grid; place-items: center;
  background: linear-gradient(145deg, var(--green-800), var(--green-600));
  color: #f7f5f0;
  font-weight: 800; font-size: 24px;
  box-shadow: 0 6px 16px rgba(26, 71, 49, .25);
  flex-shrink: 0;
}

.brand h1 { margin: 0; font-size: 22px; font-weight: 700; color: var(--green-900); letter-spacing: .2px; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.brand.small .brand-mark { width: 40px; height: 40px; font-size: 19px; border-radius: var(--r-md); }
.brand.small strong { display: block; font-size: 16px; font-weight: 700; color: #f7f5f0; }
.brand.small .sub { color: rgba(247, 245, 240, .75); font-size: 12px; }

.login-card label {
  display: block; margin-bottom: 16px;
  font-size: 13px; font-weight: 600; color: var(--muted);
}

.login-card input {
  width: 100%; margin-top: 6px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.login-card input:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(45, 115, 80, .12);
  outline: none;
}

.login-card button[type=submit] {
  width: 100%;
  margin-top: 10px;
  padding: 13px;
  background: linear-gradient(145deg, var(--green-800), var(--green-600));
  color: #f7f5f0;
  font-weight: 700; font-size: 15px;
  border: none; border-radius: var(--r-md);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(26, 71, 49, .25);
  transition: transform var(--transition), box-shadow var(--transition);
}

.login-card button[type=submit]:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(26, 71, 49, .30);
}

.login-card button[type=submit]:active { transform: translateY(0); }

.fineprint { color: var(--muted-2); font-size: 11px; margin-top: 16px; line-height: 1.7; text-align: center; }

.error { color: var(--danger); font-size: 13px; min-height: 1.2em; margin-top: 8px; }

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px 28px;
  background: linear-gradient(180deg, var(--green-900), var(--green-800));
  color: #f7f5f0;
  position: sticky; top: 0; z-index: 30;
  box-shadow: 0 2px 16px rgba(15, 46, 30, .20);
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.topbar .brand-mark { background: rgba(255,255,255,.12); color: #f7f5f0; box-shadow: none; }
.topbar strong { color: #f7f5f0; font-size: 16px; font-weight: 700; }
.topbar .sub { color: rgba(247, 245, 240, .70); font-size: 12px; }
.topbar .muted { color: rgba(247, 245, 240, .70); }

.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.topbar button.ghost {
  color: #f7f5f0; border-color: rgba(255,255,255,.20);
  background: rgba(255,255,255,.06);
  border-radius: var(--r-sm);
  transition: background var(--transition), border-color var(--transition);
}
.topbar button.ghost:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.40); }
.topbar button:not(.ghost) { background: var(--card); color: var(--text); }

.topbar .pill {
  background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.18);
  color: #f7f5f0; font-size: 12px;
}

/* ── Pills ──────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--line);
  background: var(--card); color: var(--muted);
  transition: all var(--transition);
}
.pill.ok   { color: var(--ok);     border-color: rgba(45,122,79,.25);  background: var(--ok-soft); }
.pill.warn { color: var(--warn);   border-color: rgba(180,122,30,.25); background: var(--warn-soft); }
.pill.bad  { color: var(--danger); border-color: rgba(192,57,43,.25);  background: var(--danger-soft); }

/* ── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex; align-items: center; gap: 2px;
  padding: 8px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 62px; z-index: 20;
  overflow-x: auto;
  box-shadow: var(--shadow-xs);
}

.tabs button {
  border: none; background: transparent;
  color: var(--muted); font-weight: 600; font-size: 13px;
  padding: 8px 14px; border-radius: var(--r-sm);
  white-space: nowrap;
  transition: all var(--transition);
  position: relative;
}

.tabs button:hover { color: var(--green-700); background: var(--green-50); }
.tabs button.active {
  color: var(--green-800);
  background: var(--green-100);
  font-weight: 700;
}

.tabs button.active::after {
  content: '';
  position: absolute;
  bottom: -9px; left: 50%; transform: translateX(-50%);
  width: 20px; height: 3px;
  background: var(--green-600);
  border-radius: 2px;
}

.tab-group {
  color: var(--muted-2); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  padding: 8px 8px 8px 16px;
  white-space: nowrap;
  border-right: 1px solid var(--line);
  margin-right: 4px;
  align-self: center;
}
.tabs .tab-group:first-child { border-right: none; padding-right: 4px; }

/* ── Main ───────────────────────────────────────────────── */
main { padding: 24px 28px; max-width: 1480px; margin: 0 auto; }

.panel { display: none; }
.panel.active { display: block; animation: fadeUp .25s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ── Panel heads ────────────────────────────────────────── */
.panel-head { margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.panel-head h1 { margin: 0 0 4px; font-size: 24px; font-weight: 800; color: var(--green-900); letter-spacing: .2px; }
.panel-desc { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; max-width: 820px; }

.section-title {
  font-size: 15px; font-weight: 700; color: var(--green-800);
  margin: 22px 0 4px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::before {
  content: ''; width: 4px; height: 16px; border-radius: 2px;
  background: linear-gradient(180deg, var(--green-600), var(--gold));
}
.section-desc { color: var(--muted); font-size: 12px; margin: 0 0 12px; line-height: 1.6; }

.error-banner {
  background: var(--danger-soft); border: 1px solid rgba(192,57,43,.2);
  color: var(--danger); padding: 12px 16px; border-radius: var(--r-md);
  margin-bottom: 16px; font-size: 13px;
}
.banner-good {
  background: var(--green-50); border: 1px solid rgba(45,115,80,.18);
  color: var(--green-800); padding: 12px 16px; border-radius: var(--r-md);
  margin-bottom: 16px; font-size: 13px;
}

/* ── KPIs ──────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpis.small { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 60px; height: 60px;
  background: radial-gradient(circle at top right, rgba(45,115,80,.06), transparent 70%);
  pointer-events: none;
}

.kpi:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--green-400);
}

.kpi .value {
  font-size: 28px; font-weight: 800;
  color: var(--green-800);
  letter-spacing: -.3px;
  line-height: 1.1;
  margin-bottom: 6px;
}

.kpi .label {
  color: var(--muted); font-size: 12px; font-weight: 600;
  line-height: 1.4;
}

.kpi.good .value { color: var(--ok); }
.kpi.warn .value { color: var(--warn); }
.kpi.bad  .value { color: var(--danger); }
.kpi.accent .value { color: var(--gold); }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 14px; padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 700; color: var(--green-900); }

.table-card { padding: 0; overflow: auto; border-radius: var(--r-lg); }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }

/* ── Lists & rows ──────────────────────────────────────── */
.list { display: flex; flex-direction: column; gap: 8px; }
.list.compact { gap: 4px; }

.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 12px;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: var(--bg);
  transition: all var(--transition);
}
.row:hover { border-color: var(--line); background: var(--card-2); }
.row .grow { min-width: 0; }
.row .title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--muted); font-size: 11px; margin-top: 3px; line-height: 1.5; }
.row .side { color: var(--muted); font-size: 11px; white-space: nowrap; }
.row.click { cursor: pointer; }
.row.click:hover { border-color: var(--green-400); background: var(--green-50); }

.empty { color: var(--muted); font-size: 13px; padding: 16px; text-align: center; line-height: 1.6; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state h2 { color: var(--text); margin-bottom: 8px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=search] { min-width: 260px; flex: 1; max-width: 360px; }
.toolbar .muted { margin-inline-start: auto; font-size: 12px; }

/* ── Tables ────────────────────────────────────────────── */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
thead th {
  text-align: right; color: var(--muted); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px;
  padding: 12px 14px; border-bottom: 2px solid var(--line);
  white-space: nowrap; background: var(--bg-2); position: sticky; top: 0;
}
thead th:first-child { border-radius: var(--r-sm) 0 0 0; }
thead th:last-child { border-radius: 0 var(--r-sm) 0 0; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--green-50); }
tbody tr.click { cursor: pointer; }
tbody tr:last-child td { border-bottom: none; }

.id { font-family: "SF Mono", "Fira Code", ui-monospace, Menlo, monospace; font-size: 11px; color: var(--green-600); font-weight: 600; }
.strong { font-weight: 700; color: var(--text); }

/* ── Status badges ─────────────────────────────────────── */
.status {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  border: 1px solid var(--line); color: var(--muted); background: var(--bg);
}
.status.done         { color: var(--ok);     border-color: rgba(45,122,79,.25);  background: var(--ok-soft); }
.status.blocked,
.status.error        { color: var(--danger); border-color: rgba(192,57,43,.25);  background: var(--danger-soft); }
.status.in_review    { color: var(--gold);   border-color: rgba(184,146,62,.30); background: var(--gold-soft); }
.status.in_progress,
.status.running      { color: var(--green-700); border-color: rgba(45,115,80,.25); background: var(--green-50); }
.status.paused       { color: var(--muted); }
.status.idle         { color: var(--ok);     border-color: rgba(45,122,79,.25);  background: var(--ok-soft); }

/* ── Progress bar ──────────────────────────────────────── */
.bar { height: 6px; background: var(--bg-3); border-radius: 99px; overflow: hidden; min-width: 90px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green-600), var(--green-400)); border-radius: 99px; transition: width .4s ease; }

/* ── Departments ───────────────────────────────────────── */
.dept-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.dept-mini {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px;
  transition: all var(--transition);
}
.dept-mini:hover { border-color: var(--green-400); background: var(--green-50); }
.dept-mini .name { font-size: 13px; font-weight: 700; color: var(--green-800); }
.dept-mini .muted { font-size: 11px; color: var(--muted); margin-top: 2px; }
.dept-mini .nums { color: var(--muted); font-size: 11px; margin-top: 8px; display: flex; gap: 10px; flex-wrap: wrap; }

.dept-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.dept-card {
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.dept-card:hover { box-shadow: var(--shadow-md); border-color: var(--green-400); }
.dept-card h3 { margin: 0 0 2px; font-size: 16px; font-weight: 700; color: var(--green-900); }
.dept-card .head { color: var(--muted); font-size: 12px; }
.dept-card .stats { display: flex; gap: 16px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.dept-card .stats b { color: var(--text); font-size: 18px; font-weight: 800; display: block; margin-bottom: 2px; }

/* ── Models ────────────────────────────────────────────── */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.profile-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 16px;
  box-shadow: var(--shadow-xs); transition: all var(--transition);
}
.profile-card:hover { box-shadow: var(--shadow-sm); border-color: var(--green-400); }
.profile-card .top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.profile-card .pname { font-weight: 800; font-size: 14px; color: var(--green-800); }
.profile-card .agents { color: var(--muted); font-size: 12px; margin-top: 8px; line-height: 1.5; }
.profile-card .state { font-size: 11px; font-weight: 600; }
.profile-card .state.ready { color: var(--ok); }
.profile-card .state.cooling { color: var(--warn); }

/* ── Modal ─────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(15, 46, 30, .50);
  backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 24px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal[hidden] { display: none; }
.modal-card {
  width: min(860px, 100%); max-height: 88vh; overflow: hidden;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-xl); display: flex; flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: scaleIn .25s ease;
}
@keyframes scaleIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.modal-card .card-head { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; overflow: auto; font-size: 13px; line-height: 1.75; }
.modal-body h4 { margin: 18px 0 8px; font-size: 13px; font-weight: 700; color: var(--green-700); }
.comment {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px; margin-bottom: 10px;
  white-space: pre-wrap; font-size: 13px; line-height: 1.7;
}
.comment .meta { color: var(--muted); font-size: 11px; margin-bottom: 6px; font-weight: 600; }

/* ── Buttons ───────────────────────────────────────────── */
button {
  cursor: pointer; border: 1.5px solid var(--line);
  background: var(--card); color: var(--text);
  border-radius: var(--r-sm); padding: 8px 14px;
  font-size: 13px; font-weight: 600;
  transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
}
button:hover { border-color: var(--green-500); color: var(--green-700); }
button:active { transform: scale(.98); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--green-50); border-color: var(--green-400); }

input, select, textarea {
  background: var(--card); border: 1.5px solid var(--line);
  color: var(--text); border-radius: var(--r-sm);
  padding: 9px 12px; font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(45, 115, 80, .10);
}

/* ── Chat ──────────────────────────────────────────────── */
.chat-card { display: flex; flex-direction: column; gap: 12px; }
.chat-log {
  max-height: 55vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 8px 4px;
  scroll-behavior: smooth;
}

.chat-msg {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--card-2);
  box-shadow: var(--shadow-xs);
  animation: msgIn .2s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.chat-msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.chat-msg .body { white-space: normal; line-height: 1.75; font-size: 13px; }

.chat-msg.ceo {
  align-self: flex-start;
  border-color: rgba(45, 115, 80, .20);
  background: var(--green-50);
  border-radius: var(--r-lg) var(--r-lg) var(--r-lg) 4px;
}
.chat-msg.coo {
  align-self: flex-end;
  border: none;
  background: linear-gradient(145deg, var(--green-700), var(--green-800));
  color: #f7f5f0;
  border-radius: var(--r-lg) var(--r-lg) 4px var(--r-lg);
  box-shadow: 0 4px 14px rgba(26, 71, 49, .18);
}
.chat-msg.coo .meta { color: rgba(247, 245, 240, .70); }
.chat-msg.coo .body { color: #f7f5f0; }

.chat-form { display: flex; gap: 10px; align-items: flex-end; }
.chat-form textarea {
  flex: 1; resize: vertical; min-height: 48px; max-height: 180px;
  padding: 12px 14px; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--card);
  color: var(--text); font: inherit; font-size: 13px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.chat-form textarea:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px rgba(45, 115, 80, .10); }

.chat-form button[type=submit] {
  background: linear-gradient(145deg, var(--green-800), var(--green-600));
  color: #f7f5f0; border: none; font-weight: 700;
  padding: 11px 20px; border-radius: var(--r-md);
  box-shadow: 0 4px 12px rgba(26, 71, 49, .20);
  transition: transform var(--transition), box-shadow var(--transition);
}
.chat-form button[type=submit]:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(26, 71, 49, .25); }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .topbar { padding: 12px 16px; flex-direction: column; align-items: flex-start; gap: 10px; }
  .tabs { padding: 6px 12px; top: 0; position: static; }
  main { padding: 16px; }
  .toolbar input[type=search] { min-width: 0; }
  .kpi .value { font-size: 24px; }
  .split { grid-template-columns: 1fr; }
  .chat-msg { max-width: 92%; }
  .panel-head h1 { font-size: 20px; }
}

/* ── Scrollbar ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-2); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--green-400); }

/* ── Selection ─────────────────────────────────────────── */
::selection { background: var(--green-100); color: var(--green-900); }

/* ── Focus visible ─────────────────────────────────────── */
:focus-visible { outline: 2px solid var(--green-600); outline-offset: 2px; border-radius: var(--r-sm); }

/* ═══════════════════════════════════════════════════════════
   DARK MODE — overrides
   ═══════════════════════════════════════════════════════════ */
[data-theme="dark"] {
  --bg:        #121a16;
  --bg-2:      #1a2420;
  --bg-3:      #222e28;
  --card:      #1c2822;
  --card-2:    #222e28;
  --line:      #2e3e34;
  --line-soft: #263329;

  --text:      #e8efe9;
  --text-2:    #c8d8cc;
  --muted:     #8a9a8e;
  --muted-2:   #5a6a5e;

  --green-900: #e8efe9;
  --green-800: #c8e0d0;
  --green-700: #a8d0b8;
  --green-600: #7ab896;
  --green-500: #5aab82;
  --green-400: #3a8a62;
  --green-100: #1e3328;
  --green-50:  #182a20;

  --gold:      #d4b06a;
  --gold-light:#e0c88a;
  --gold-soft: #2a2418;

  --danger:    #e06050;
  --danger-soft:#2a1816;
  --warn:      #d4a040;
  --warn-soft: #2a2210;
  --ok:        #5aab82;
  --ok-soft:   #182a20;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.15);
  --shadow-sm: 0 2px 6px rgba(0,0,0,.20);
  --shadow-md: 0 4px 14px rgba(0,0,0,.25);
  --shadow-lg: 0 8px 28px rgba(0,0,0,.30);
  --shadow-xl: 0 16px 48px rgba(0,0,0,.35);
}

[data-theme="dark"] body {
  background: var(--bg);
  color: var(--text);
}

[data-theme="dark"] .login-wrap {
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(45,115,80,.06), transparent 60%),
    radial-gradient(ellipse 60% 50% at 110% 110%, rgba(184,146,62,.05), transparent 60%),
    var(--bg);
}

[data-theme="dark"] .topbar {
  background: linear-gradient(180deg, #0a1510, #121a16);
}

[data-theme="dark"] .tabs {
  background: var(--card);
}

[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background: var(--bg-2);
}

[data-theme="dark"] .row { background: var(--bg-2); }
[data-theme="dark"] .row:hover { background: var(--card-2); }

/* ── Theme toggle button ──────────────────────────────── */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.20);
  background: rgba(255,255,255,.06);
  color: #f7f5f0;
  display: grid; place-items: center;
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
  padding: 0;
}
.theme-toggle:hover { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.40); }

/* ── Command palette ──────────────────────────────────── */
.cmd-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 46, 30, .55);
  backdrop-filter: blur(6px);
  display: grid; place-items: start center;
  padding-top: 12vh;
  animation: fadeIn .15s ease;
}
.cmd-overlay[hidden] { display: none; }

.cmd-palette {
  width: min(600px, 92vw);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: scaleIn .2s ease;
}

.cmd-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.cmd-input-wrap svg { flex-shrink: 0; color: var(--muted); }

.cmd-input {
  flex: 1; border: none; background: transparent;
  font-size: 15px; color: var(--text);
  outline: none; padding: 4px 0;
}

.cmd-results {
  max-height: 50vh; overflow-y: auto;
  padding: 6px;
}

.cmd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-md);
  cursor: pointer; transition: background var(--transition);
}
.cmd-item:hover, .cmd-item.active {
  background: var(--green-50);
}
.cmd-item .cmd-icon {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--green-100); color: var(--green-700);
  font-size: 14px; flex-shrink: 0;
}
.cmd-item .cmd-label { font-size: 13px; font-weight: 600; color: var(--text); }
.cmd-item .cmd-hint { font-size: 11px; color: var(--muted); margin-top: 1px; }
.cmd-item .cmd-key {
  margin-inline-start: auto;
  font-size: 10px; color: var(--muted-2);
  background: var(--bg-2); padding: 2px 6px;
  border-radius: 4px; font-family: monospace;
}

.cmd-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

.cmd-footer {
  padding: 8px 18px; border-top: 1px solid var(--line);
  display: flex; gap: 16px; font-size: 10px; color: var(--muted-2);
}
.cmd-footer kbd {
  background: var(--bg-2); padding: 1px 5px; border-radius: 3px;
  font-family: monospace; font-size: 10px;
}

/* ── Export button ────────────────────────────────────── */
.export-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-sm);
  background: var(--card); border: 1.5px solid var(--line);
  color: var(--text); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
}
.export-btn:hover { border-color: var(--green-500); color: var(--green-700); background: var(--green-50); }

/* ── Task creation modal ──────────────────────────────── */
.task-modal-form { display: flex; flex-direction: column; gap: 14px; }
.task-modal-form label { font-size: 13px; font-weight: 600; color: var(--muted); }
.task-modal-form input, .task-modal-form select, .task-modal-form textarea {
  width: 100%; margin-top: 4px;
}
.task-modal-form textarea { min-height: 80px; resize: vertical; }
.task-modal-form .hint { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.5; }
.task-modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
#task-modal-form button[type=submit]:disabled { opacity: .65; cursor: wait; transform: none; }
.task-modal-actions button.primary {
  background: linear-gradient(145deg, var(--green-800), var(--green-600));
  color: #f7f5f0; border: none;
  box-shadow: 0 4px 12px rgba(26,71,49,.20);
}

/* ── Toast notifications ──────────────────────────────── */
.toast-container {
  position: fixed; bottom: 24px; left: 24px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600;
  animation: toastIn .3s ease;
  pointer-events: auto;
  max-width: 380px;
}
.toast.success { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.toast.error { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.toast.info { border-color: var(--green-400); background: var(--green-50); color: var(--green-700); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(12px); } }

/* ── Employee detail ──────────────────────────────────── */
.emp-detail { display: grid; gap: 16px; }
.emp-detail-header { display: flex; align-items: center; gap: 16px; }
.emp-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: linear-gradient(145deg, var(--green-800), var(--green-600));
  color: #f7f5f0; font-size: 22px; font-weight: 800;
  display: grid; place-items: center; flex-shrink: 0;
}
.emp-detail-name { font-size: 18px; font-weight: 800; color: var(--green-900); }
.emp-detail-title { font-size: 13px; color: var(--muted); margin-top: 2px; }
.emp-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.emp-detail-item { background: var(--bg); border-radius: var(--r-sm); padding: 10px 12px; }
.emp-detail-item .label { font-size: 11px; color: var(--muted); font-weight: 600; }
.emp-detail-item .value { font-size: 14px; font-weight: 700; color: var(--text); margin-top: 2px; }

/* ── Employee cards (modern grid) ─────────────────────── */
.emp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.emp-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.emp-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green-600), var(--gold));
  opacity: 0;
  transition: opacity var(--transition);
}

.emp-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--green-400);
}

.emp-card:hover::before { opacity: 1; }

.emp-card-top {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px;
}

.emp-card .emp-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(145deg, var(--green-800), var(--green-600));
  color: #f7f5f0; font-size: 16px; font-weight: 800;
  display: grid; place-items: center; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(26, 71, 49, .15);
}

.emp-card-info { flex: 1; min-width: 0; }
.emp-card-name { font-size: 15px; font-weight: 700; color: var(--green-900); }
.emp-card-title { font-size: 12px; color: var(--muted); margin-top: 2px; }

.emp-card-status {
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: var(--bg-2);
  text-transform: uppercase; letter-spacing: .5px;
}

.emp-card-meta {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 12px;
}

.emp-card-meta-item {
  background: var(--bg);
  border-radius: var(--r-sm);
  padding: 8px 10px;
}

.emp-card-meta-label {
  font-size: 10px; color: var(--muted);
  font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px;
}

.emp-card-meta-value {
  font-size: 12px; font-weight: 600; color: var(--text);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.emp-card-bar {
  display: flex; align-items: center; gap: 8px;
}

.emp-card-bar .bar { flex: 1; }
.emp-card-bar-label {
  font-size: 10px; color: var(--muted); font-weight: 600;
  white-space: nowrap;
}

/* ── Quick stats bar ──────────────────────────────────── */
.quick-stats {
  display: flex; gap: 16px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 18px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
}
.quick-stat { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.quick-stat .dot { width: 8px; height: 8px; border-radius: 50%; }
.quick-stat .label { color: var(--muted); }
.quick-stat .value { font-weight: 700; color: var(--text); }