/* =====================================================================
   Teknaf WMS — design tokens
   ===================================================================== */
:root {
  --brand-900:#053b32; --brand-800:#075045; --brand-700:#0b6b5b;
  --brand-600:#0f8a74; --brand-500:#14a88d; --brand-100:#d7f2ec; --brand-50:#eefaf7;
  --accent:#f59e0b; --accent-soft:#fef3c7;

  --ok:#16a34a;   --ok-soft:#dcfce7;
  --info:#0284c7; --info-soft:#e0f2fe;
  --warn:#d97706; --warn-soft:#fef3c7;
  --bad:#dc2626;  --bad-soft:#fee2e2;
  --muted-soft:#eef2f6;

  --bg:#f4f6f8; --surface:#ffffff; --surface-2:#f8fafc;
  --line:#e2e8f0; --line-strong:#cbd5e1;
  --text:#0f172a; --text-2:#475569; --text-3:#94a3b8;

  --radius:10px; --radius-sm:6px;
  --shadow:0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow-lg:0 10px 30px rgba(15,23,42,.12);
  --sidebar-w:248px;
  --font:"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono:"SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
}

*,*::before,*::after { box-sizing:border-box; }
html,body { margin:0; padding:0; }
body {
  font-family:var(--font); background:var(--bg); color:var(--text);
  font-size:14px; line-height:1.55; -webkit-font-smoothing:antialiased;
}
a { color:var(--brand-700); text-decoration:none; }
a:hover { text-decoration:underline; }
h1,h2,h3,h4 { margin:0; font-weight:650; letter-spacing:-.01em; line-height:1.25; }
h1 { font-size:22px; } h2 { font-size:17px; } h3 { font-size:15px; }
p { margin:0 0 10px; }
small { font-size:12px; }
code { font-family:var(--mono); font-size:12px; background:var(--surface-2);
  padding:1px 5px; border-radius:4px; border:1px solid var(--line); }

/* ---------------- app shell ---------------- */
.app { display:flex; min-height:100vh; }

.sidebar {
  width:var(--sidebar-w); flex:0 0 var(--sidebar-w);
  background:linear-gradient(180deg,var(--brand-900),var(--brand-800) 55%,#04302a);
  color:#cfe9e2; display:flex; flex-direction:column;
  position:sticky; top:0; height:100vh; overflow-y:auto;
}
.sidebar__brand {
  display:flex; gap:10px; align-items:center; padding:18px 18px 16px;
  border-bottom:1px solid rgba(255,255,255,.09);
}
.sidebar__logo {
  width:34px; height:34px; border-radius:9px; flex:0 0 34px;
  background:linear-gradient(135deg,var(--brand-500),var(--brand-700));
  display:grid; place-items:center; font-size:17px;
  box-shadow:0 2px 10px rgba(20,168,141,.35);
}
.sidebar__title { color:#fff; font-weight:680; font-size:14px; line-height:1.2; }
.sidebar__sub { font-size:11px; color:#8fc4b8; letter-spacing:.03em; text-transform:uppercase; }

.nav { padding:10px 10px 24px; flex:1; }
.nav__group { margin-top:14px; }
.nav__label {
  font-size:10px; text-transform:uppercase; letter-spacing:.09em;
  color:#6ea99b; padding:6px 10px 5px; font-weight:650;
}
.nav__item {
  display:flex; align-items:center; gap:10px; padding:8px 10px; margin:1px 0;
  border-radius:7px; color:#cfe9e2; font-size:13.5px; font-weight:500;
  transition:background .12s, color .12s;
}
.nav__item:hover { background:rgba(255,255,255,.08); color:#fff; text-decoration:none; }
.nav__item.is-active { background:var(--brand-600); color:#fff; box-shadow:inset 0 0 0 1px rgba(255,255,255,.12); }
.nav__icon { width:17px; text-align:center; font-size:14px; opacity:.95; }
.nav__badge {
  margin-left:auto; background:var(--accent); color:#3b2500; font-size:10.5px;
  font-weight:700; border-radius:20px; padding:1px 7px;
}

.main { flex:1; min-width:0; display:flex; flex-direction:column; }

.topbar {
  height:58px; background:var(--surface); border-bottom:1px solid var(--line);
  display:flex; align-items:center; gap:14px; padding:0 20px;
  position:sticky; top:0; z-index:40;
}
.topbar__title { font-weight:650; font-size:15px; }
.topbar__crumb { color:var(--text-3); font-size:12px; }
.topbar__spacer { flex:1; }
.topbar__btn {
  position:relative; width:34px; height:34px; border-radius:8px; border:1px solid var(--line);
  background:var(--surface); display:grid; place-items:center; cursor:pointer; color:var(--text-2);
}
.topbar__btn:hover { background:var(--surface-2); }
.topbar__dot {
  position:absolute; top:-4px; right:-4px; min-width:16px; height:16px; padding:0 4px;
  border-radius:9px; background:var(--bad); color:#fff; font-size:10px; font-weight:700;
  display:grid; place-items:center;
}
.avatar {
  width:32px; height:32px; border-radius:50%; background:var(--brand-600); color:#fff;
  display:grid; place-items:center; font-weight:650; font-size:12.5px; flex:0 0 32px;
}

.content { padding:20px; max-width:1560px; width:100%; }

.page-head {
  display:flex; align-items:flex-start; gap:14px; flex-wrap:wrap; margin-bottom:16px;
}
.page-head__text { flex:1; min-width:220px; }
.page-head__sub { color:var(--text-2); font-size:13px; margin-top:3px; }
.page-head__actions { display:flex; gap:8px; flex-wrap:wrap; }

/* ---------------- cards & grid ---------------- */
.card {
  background:var(--surface); border:1px solid var(--line);
  border-radius:var(--radius); box-shadow:var(--shadow);
}
.card__head {
  padding:13px 16px; border-bottom:1px solid var(--line);
  display:flex; align-items:center; gap:10px; flex-wrap:wrap;
}
.card__head h2, .card__head h3 { margin:0; }
.card__sub { color:var(--text-3); font-size:12px; }
.card__body { padding:16px; }
.card__body--flush { padding:0; }
.card__foot { padding:10px 16px; border-top:1px solid var(--line); background:var(--surface-2);
  border-radius:0 0 var(--radius) var(--radius); font-size:12.5px; color:var(--text-2); }

.grid { display:grid; gap:16px; }
.grid--kpi   { grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); }
.grid--2     { grid-template-columns:repeat(auto-fit,minmax(340px,1fr)); }
.grid--3     { grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); }
.grid--sidebar { grid-template-columns:2fr 1fr; }
@media (max-width:1100px){ .grid--sidebar { grid-template-columns:1fr; } }

/* ---------------- KPI tiles ---------------- */
.kpi { position:relative; overflow:hidden; padding:15px 16px; }
.kpi__label { font-size:11.5px; text-transform:uppercase; letter-spacing:.05em;
  color:var(--text-3); font-weight:650; }
.kpi__value { font-size:26px; font-weight:700; letter-spacing:-.02em; margin-top:5px; line-height:1.1; }
.kpi__meta { font-size:12px; color:var(--text-2); margin-top:4px; }
.kpi__icon {
  position:absolute; right:12px; top:12px; width:34px; height:34px; border-radius:9px;
  display:grid; place-items:center; font-size:16px; background:var(--brand-50); color:var(--brand-700);
}
.kpi--ok   .kpi__icon { background:var(--ok-soft);   color:var(--ok); }
.kpi--info .kpi__icon { background:var(--info-soft); color:var(--info); }
.kpi--warn .kpi__icon { background:var(--warn-soft); color:var(--warn); }
.kpi--bad  .kpi__icon { background:var(--bad-soft);  color:var(--bad); }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x:auto; }
table.tbl { width:100%; border-collapse:collapse; font-size:13px; }
.tbl th {
  text-align:left; padding:9px 14px; background:var(--surface-2);
  border-bottom:1px solid var(--line); font-size:11px; letter-spacing:.05em;
  text-transform:uppercase; color:var(--text-2); font-weight:650; white-space:nowrap;
}
.tbl td { padding:10px 14px; border-bottom:1px solid var(--line); vertical-align:middle; }
.tbl tbody tr:last-child td { border-bottom:0; }
.tbl tbody tr:hover { background:var(--brand-50); }
.tbl .num { text-align:right; font-variant-numeric:tabular-nums; }
.tbl .nowrap { white-space:nowrap; }
.tbl__empty { padding:36px 16px; text-align:center; color:var(--text-3); }

/* ---------------- badges & pills ---------------- */
.badge {
  display:inline-flex; align-items:center; gap:5px; padding:2px 9px; border-radius:20px;
  font-size:11.5px; font-weight:600; line-height:1.7; white-space:nowrap;
  background:var(--muted-soft); color:var(--text-2);
}
.badge--ok   { background:var(--ok-soft);   color:#15803d; }
.badge--info { background:var(--info-soft); color:#0369a1; }
.badge--warn { background:var(--warn-soft); color:#b45309; }
.badge--bad  { background:var(--bad-soft);  color:#b91c1c; }
.badge--muted{ background:var(--muted-soft);color:var(--text-2); }
.badge--brand{ background:var(--brand-100); color:var(--brand-800); }
.badge__dot { width:6px; height:6px; border-radius:50%; background:currentColor; }

.chip {
  display:inline-block; padding:1px 8px; border-radius:5px; font-size:11.5px;
  background:var(--surface-2); border:1px solid var(--line); color:var(--text-2); margin:2px 3px 2px 0;
}

/* ---------------- buttons ---------------- */
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  padding:8px 14px; border-radius:var(--radius-sm); border:1px solid var(--line-strong);
  background:var(--surface); color:var(--text); font-size:13px; font-weight:600;
  cursor:pointer; font-family:inherit; transition:background .12s, border-color .12s, box-shadow .12s;
  white-space:nowrap;
}
.btn:hover { background:var(--surface-2); text-decoration:none; }
.btn--primary { background:var(--brand-600); border-color:var(--brand-600); color:#fff; }
.btn--primary:hover { background:var(--brand-700); border-color:var(--brand-700); }
.btn--danger { background:var(--bad); border-color:var(--bad); color:#fff; }
.btn--danger:hover { background:#b91c1c; }
.btn--ghost { background:transparent; border-color:transparent; color:var(--text-2); }
.btn--ghost:hover { background:var(--surface-2); }
.btn--sm { padding:5px 10px; font-size:12px; }
.btn--block { width:100%; }
.btn[disabled] { opacity:.5; cursor:not-allowed; }

.btn-group { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }

/* ---------------- forms ---------------- */
.form-grid { display:grid; gap:14px; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); }
.field { display:flex; flex-direction:column; gap:5px; min-width:0; }
.field--full { grid-column:1/-1; }
.field label { font-size:12.5px; font-weight:600; color:var(--text-2); }
.field .hint { font-size:11.5px; color:var(--text-3); }
input[type=text],input[type=email],input[type=password],input[type=number],input[type=date],
input[type=time],input[type=datetime-local],input[type=search],input[type=tel],select,textarea {
  width:100%; padding:8px 11px; border:1px solid var(--line-strong); border-radius:var(--radius-sm);
  font-family:inherit; font-size:13.5px; background:var(--surface); color:var(--text);
  transition:border-color .12s, box-shadow .12s;
}
input:focus,select:focus,textarea:focus {
  outline:none; border-color:var(--brand-500); box-shadow:0 0 0 3px rgba(20,168,141,.16);
}
textarea { resize:vertical; min-height:78px; }
input[type=color] { width:46px; height:34px; padding:2px; border:1px solid var(--line-strong);
  border-radius:var(--radius-sm); background:var(--surface); }
.check { display:flex; align-items:center; gap:8px; font-size:13px; color:var(--text-2); }
.check input { width:15px; height:15px; accent-color:var(--brand-600); }
.checks { display:flex; flex-wrap:wrap; gap:6px 14px; }

.filters {
  display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end;
}
.filters .field { min-width:150px; flex:0 1 auto; }

/* ---------------- misc ---------------- */
.flash-stack { position:fixed; top:14px; right:16px; z-index:200; display:flex;
  flex-direction:column; gap:8px; max-width:380px; }
.flash {
  padding:11px 14px; border-radius:var(--radius); box-shadow:var(--shadow-lg);
  font-size:13px; display:flex; gap:9px; align-items:flex-start; background:var(--surface);
  border:1px solid var(--line); border-left-width:4px;
}
.flash--success { border-left-color:var(--ok); }
.flash--error   { border-left-color:var(--bad); }
.flash--info    { border-left-color:var(--info); }
.flash__close { margin-left:auto; cursor:pointer; color:var(--text-3); background:none; border:0; font-size:15px; }

.empty { padding:44px 20px; text-align:center; color:var(--text-3); }
.empty__icon { font-size:30px; margin-bottom:8px; opacity:.6; }

.pagination { display:flex; gap:6px; align-items:center; justify-content:center; padding:12px; flex-wrap:wrap; }
.pagination a, .pagination span {
  padding:5px 10px; border-radius:var(--radius-sm); border:1px solid var(--line);
  font-size:12.5px; background:var(--surface); color:var(--text-2);
}
.pagination .is-current { background:var(--brand-600); border-color:var(--brand-600); color:#fff; }

.dl { display:grid; grid-template-columns:auto 1fr; gap:8px 18px; font-size:13px; margin:0; }
.dl dt { color:var(--text-3); font-weight:500; }
.dl dd { margin:0; font-weight:550; }

.bar { height:7px; border-radius:5px; background:var(--muted-soft); overflow:hidden; }
.bar__fill { height:100%; border-radius:5px; background:var(--brand-500); }

.stat-row { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px solid var(--line); }
.stat-row:last-child { border-bottom:0; }
.stat-row__label { flex:1; font-size:13px; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.stat-row__value { font-variant-numeric:tabular-nums; font-weight:650; font-size:13px; }
.swatch { width:9px; height:9px; border-radius:3px; flex:0 0 9px; }

.chart-box { position:relative; height:280px; }
.chart-box--sm { height:220px; }
.map-box { height:520px; border-radius:var(--radius); overflow:hidden; border:1px solid var(--line); }
.map-box--sm { height:300px; }

.tabs { display:flex; gap:4px; border-bottom:1px solid var(--line); margin-bottom:16px; flex-wrap:wrap; }
.tabs a {
  padding:8px 14px; font-size:13px; font-weight:600; color:var(--text-2);
  border-bottom:2px solid transparent; margin-bottom:-1px;
}
.tabs a:hover { color:var(--brand-700); text-decoration:none; }
.tabs a.is-active { color:var(--brand-700); border-bottom-color:var(--brand-600); }

.legend { display:flex; flex-wrap:wrap; gap:8px 14px; font-size:12px; color:var(--text-2); }
.legend span { display:inline-flex; align-items:center; gap:6px; }

.item-row { display:grid; grid-template-columns:2fr 1fr 1.4fr 1.6fr auto; gap:8px; align-items:end; margin-bottom:8px; }
@media (max-width:820px){ .item-row { grid-template-columns:1fr 1fr; } }

.week-grid { display:grid; grid-template-columns:repeat(7,minmax(150px,1fr)); gap:10px; }
.week-col { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; }
.week-col__head { padding:8px 10px; background:var(--brand-50); border-bottom:1px solid var(--line);
  font-size:12px; font-weight:650; color:var(--brand-800); display:flex; justify-content:space-between; }
.week-col__body { padding:8px; display:flex; flex-direction:column; gap:6px; max-height:520px; overflow-y:auto; }
.week-item { padding:7px 8px; border-radius:6px; background:var(--surface-2); border:1px solid var(--line); font-size:11.5px; }
.week-item strong { display:block; font-size:12px; font-weight:620; }

.msg-row { display:flex; gap:12px; padding:12px 16px; border-bottom:1px solid var(--line); }
.msg-row:hover { background:var(--brand-50); }
.msg-row--unread { background:var(--brand-50); }
.msg-row--unread .msg-row__subject { font-weight:700; }
.msg-row__subject { font-size:13.5px; }
.msg-row__preview { color:var(--text-2); font-size:12.5px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.notif-tray {
  position:absolute; right:16px; top:52px; width:340px; background:var(--surface);
  border:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow-lg);
  z-index:60; overflow:hidden;
}
.notif-tray[hidden] { display:none; }
.notif { padding:10px 14px; border-bottom:1px solid var(--line); font-size:12.5px; display:block; color:var(--text); }
.notif:hover { background:var(--surface-2); text-decoration:none; }
.notif--unread { background:var(--brand-50); }
.notif__title { font-weight:650; font-size:13px; }
.notif__time { color:var(--text-3); font-size:11px; }

/* ---------------- auth ---------------- */
.auth {
  min-height:100vh; display:grid; grid-template-columns:1.05fr .95fr;
  background:var(--surface);
}
@media (max-width:900px){ .auth { grid-template-columns:1fr; } .auth__aside { display:none; } }
.auth__aside {
  background:linear-gradient(150deg,var(--brand-900),var(--brand-700) 60%,var(--brand-600));
  color:#eafaf6; padding:52px 48px; display:flex; flex-direction:column; justify-content:center;
  position:relative; overflow:hidden;
}
.auth__aside::after {
  content:""; position:absolute; inset:auto -80px -120px auto; width:340px; height:340px;
  border-radius:50%; background:rgba(255,255,255,.06);
}
.auth__aside h1 { font-size:30px; color:#fff; margin-bottom:12px; letter-spacing:-.02em; }
.auth__aside p { color:#b9ddd4; font-size:14.5px; max-width:430px; }
.auth__features { margin-top:26px; display:grid; gap:11px; }
.auth__feature { display:flex; gap:11px; align-items:flex-start; font-size:13.5px; color:#d6f0e9; }
.auth__feature span:first-child { color:var(--brand-500); font-size:15px; }
.auth__form { display:grid; place-items:center; padding:40px 24px; }
.auth__box { width:100%; max-width:380px; }
.auth__demo {
  margin-top:22px; padding:13px 14px; background:var(--surface-2);
  border:1px dashed var(--line-strong); border-radius:var(--radius); font-size:12px; color:var(--text-2);
}
.auth__demo table { width:100%; font-size:11.5px; border-collapse:collapse; }
.auth__demo td { padding:2px 0; }
.auth__demo td:last-child { text-align:right; font-family:var(--mono); }

.error-page { display:grid; place-items:center; min-height:70vh; text-align:center; }
.error-page__code { font-size:64px; font-weight:750; color:var(--brand-600); letter-spacing:-.03em; }

@media print {
  .sidebar, .topbar, .page-head__actions, .filters, .pagination { display:none !important; }
  body { background:#fff; }
  .card { box-shadow:none; border-color:#ddd; break-inside:avoid; }
}
