/* =========================================================
   GURUR LOJİSTİK — Management panel
   Modern, soft-cornered admin design system (light + dark)
   ========================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  --brand:        #e2382c;
  --brand-2:      #ff6a3d;
  --brand-ink:    #b81f16;
  --grad-brand:   linear-gradient(125deg, #e2382c 0%, #ff6a3d 100%);
  --grad-ink:     linear-gradient(160deg, #14264a 0%, #0a1731 60%, #101f3d 100%);
  --grad-sheen:   linear-gradient(120deg, rgba(255,255,255,.16), rgba(255,255,255,0));

  --accent:       #2e86ff;
  --accent-2:     #22d3ee;
  --ok:           #10b981;
  --warn:         #f59e0b;
  --bad:          #ef4444;
  --info:         #6366f1;

  --bg:           #f2f5fb;
  --bg-2:         #e9eff8;
  --surface:      #ffffff;
  --surface-2:    #f7f9fd;
  --surface-3:    #eef3fa;
  --line:         #e3eaf5;
  --line-soft:    #eef2f9;
  --text:         #10203c;
  --text-2:       #5c6a86;
  --text-3:       #8d9ab3;
  --sidebar:      #413f3f;
  --sidebar-2:    #101f3d;
  --sidebar-text: #b9c6dd;

  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --r-xs: 9px;
  --r-pill: 999px;

  --shadow-sm: 0 2px 8px -2px rgba(16, 32, 60, .10);
  --shadow:    0 14px 34px -20px rgba(16, 32, 60, .34);
  --shadow-lg: 0 34px 70px -34px rgba(16, 32, 60, .45);
  --ring:      0 0 0 4px rgba(226, 56, 44, .14);

  --sidebar-w: 272px;
  --sidebar-w-min: 86px;
  --topbar-h: 76px;

  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --tr: .24s cubic-bezier(.4, 0, .2, 1);
}

[data-theme="dark"] {
  --bg:           #070d1a;
  --bg-2:         #0a1224;
  --surface:      #101a2e;
  --surface-2:    #16223a;
  --surface-3:    #1b2942;
  --line:         #1f2d47;
  --line-soft:    #182339;
  --text:         #e8eefa;
  --text-2:       #9aa9c4;
  --text-3:       #71809c;
  --sidebar:      #0a1122;
  --sidebar-2:    #0e1830;
  --sidebar-text: #96a5c0;

  --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, .45);
  --shadow:    0 16px 40px -22px rgba(0, 0, 0, .7);
  --shadow-lg: 0 40px 80px -36px rgba(0, 0, 0, .8);
}

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background var(--tr), color var(--tr);
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
svg { flex: none; }

::selection { background: var(--brand); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-3) 45%, transparent);
  border-radius: var(--r-pill);
  border: 3px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

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

.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--sidebar-w);
  background: var(--sidebar);
  background-image: radial-gradient(120% 60% at 0% 0%, rgba(226,56,44,.16), transparent 62%);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: width var(--tr), transform var(--tr);
  border-inline-end: 1px solid rgba(255, 255, 255, .05);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: 1.35rem 1.25rem 1.1rem;
  min-height: var(--topbar-h);
}

.brand-mark {
  width: 42px; height: 42px;
  border-radius: 14px;
  background: var(--grad-brand);
  display: grid; place-items: center;
  color: #fff;
  box-shadow: 0 10px 24px -10px rgba(226, 56, 44, .8);
  flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; overflow: hidden; }
.brand-text b { color: #fff; font-size: .98rem; letter-spacing: .01em; white-space: nowrap; }
.brand-text span { color: var(--sidebar-text); font-size: .7rem; letter-spacing: .12em;
  text-transform: uppercase; white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: .35rem .75rem 1.25rem; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); }

.nav-group { margin-bottom: 1.1rem; }
.nav-group-label {
  color: #64769a;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
  padding: 0 .8rem .5rem;
  white-space: nowrap;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .62rem .8rem;
  border-radius: 14px;
  color: var(--sidebar-text);
  font-weight: 600;
  font-size: .885rem;
  transition: var(--tr);
  position: relative;
  margin-bottom: 2px;
  white-space: nowrap;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link.active {
  background: var(--grad-brand);
  color: #fff;
  box-shadow: 0 12px 26px -14px rgba(226, 56, 44, .95);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  inset-inline-start: -0.75rem;
  top: 50%;
  translate: 0 -50%;
  width: 4px; height: 22px;
  border-radius: 0 4px 4px 0;
  background: #fff;
}
.nav-link svg { width: 19px; height: 19px; flex: none; }
.nav-link .nav-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.nav-badge {
  min-width: 21px;
  height: 21px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: .7rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}
.nav-link.active .nav-badge { background: rgba(0, 0, 0, .22); }
.nav-link:not(.active) .nav-badge { background: var(--brand); }

.sidebar-foot { padding: .9rem 1rem 1.15rem; border-top: 1px solid rgba(255,255,255,.06); }
.site-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .75rem;
  border-radius: 13px;
  background: rgba(255, 255, 255, .06);
  color: #dbe4f3;
  font-size: .82rem;
  font-weight: 700;
  transition: var(--tr);
  white-space: nowrap;
}
.site-link:hover { background: rgba(255, 255, 255, .12); color: #fff; }

/* collapsed sidebar */
body.nav-collapsed .sidebar { width: var(--sidebar-w-min); }
body.nav-collapsed .brand-text,
body.nav-collapsed .nav-group-label,
body.nav-collapsed .nav-text,
body.nav-collapsed .nav-badge,
body.nav-collapsed .site-link span { display: none; }
body.nav-collapsed .nav-link { justify-content: center; padding-inline: 0; }
body.nav-collapsed .site-link { justify-content: center; }
body.nav-collapsed .main { margin-inline-start: var(--sidebar-w-min); }
body.nav-collapsed .sidebar-head { justify-content: center; padding-inline: 0; }

/* ---------- 4. Main ---------- */
.main {
  flex: 1;
  margin-inline-start: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin var(--tr);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .9rem clamp(1rem, 2.4vw, 2rem);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  width: 42px; height: 42px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-2);
  display: grid; place-items: center;
  cursor: pointer;
  transition: var(--tr);
  position: relative;
  flex: none;
}
.icon-btn:hover { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); transform: translateY(-1px); }
.icon-btn svg { width: 19px; height: 19px; }

.search-box { position: relative; flex: 1; max-width: 460px; }
.search-box svg {
  position: absolute; inset-inline-start: 14px; top: 50%; translate: 0 -50%;
  width: 17px; height: 17px; color: var(--text-3); pointer-events: none;
}
.search-box input {
  width: 100%;
  height: 44px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  padding-inline: 42px 16px;
  font: inherit;
  font-size: .9rem;
  color: var(--text);
  transition: var(--tr);
}
.search-box input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.search-box input::placeholder { color: var(--text-3); }

.search-results {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: .5rem;
  max-height: 60vh;
  overflow-y: auto;
  display: none;
  z-index: 70;
}
.search-results.show { display: block; }
.search-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .7rem; border-radius: var(--r-md);
  transition: var(--tr);
}
.search-item:hover { background: var(--surface-3); }
.search-item svg { width: 17px; height: 17px; color: var(--brand); }
.search-item b { font-size: .87rem; font-weight: 700; display: block; }
.search-item small { color: var(--text-3); font-size: .76rem; }
.search-group {
  font-size: .66rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase;
  color: var(--text-3); padding: .6rem .7rem .25rem;
}
.search-empty { padding: 1.1rem; text-align: center; color: var(--text-3); font-size: .85rem; }

.topbar-spacer { flex: 1; }

.dot-alert {
  position: absolute; top: 8px; inset-inline-end: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px var(--surface);
}

.lang-switch { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 3px; }
.lang-switch button {
  border: 0; background: transparent; cursor: pointer;
  padding: .32rem .72rem; border-radius: var(--r-pill);
  font: inherit; font-size: .78rem; font-weight: 800; color: var(--text-3);
  transition: var(--tr);
}
.lang-switch button.active { background: var(--grad-brand); color: #fff; }

.user-chip {
  display: flex; align-items: center; gap: .6rem;
  padding: .34rem .8rem .34rem .34rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: var(--tr);
}
.user-chip:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--grad-brand); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: .78rem; flex: none;
  object-fit: cover;
}
.avatar.lg { width: 66px; height: 66px; font-size: 1.35rem; border-radius: 22px; }
.avatar.sm { width: 28px; height: 28px; font-size: .68rem; }
.user-chip .u-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: start; }
.user-chip .u-meta b { font-size: .83rem; }
.user-chip .u-meta span { font-size: .7rem; color: var(--text-3); }

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: .45rem;
  display: none;
  z-index: 70;
}
.dropdown-menu.show { display: block; animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: .65rem; width: 100%;
  padding: .58rem .7rem; border-radius: var(--r-md);
  font: inherit; font-size: .87rem; font-weight: 600;
  color: var(--text); background: none; border: 0; cursor: pointer; text-align: start;
  transition: var(--tr);
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); color: var(--brand); }
.dropdown-menu svg { width: 17px; height: 17px; color: var(--text-3); }
.dropdown-menu a:hover svg, .dropdown-menu button:hover svg { color: var(--brand); }
.dropdown-sep { height: 1px; background: var(--line); margin: .35rem .3rem; }

.notif-menu { min-width: 340px; max-height: 70vh; overflow-y: auto; }
.notif-item { display: flex; gap: .7rem; padding: .65rem .7rem; border-radius: var(--r-md); }
.notif-item:hover { background: var(--surface-3); }
.notif-item.unread { background: color-mix(in srgb, var(--brand) 6%, transparent); }
.notif-dot { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.notif-item b { font-size: .84rem; display: block; }
.notif-item small { color: var(--text-3); font-size: .76rem; }

/* ---------- 5. Page ---------- */
.page { padding: clamp(1rem, 2.4vw, 2rem); flex: 1; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.35rem;
}
.page-head h1 { font-size: clamp(1.35rem, 2.4vw, 1.85rem); }
.page-head p { color: var(--text-2); font-size: .92rem; margin-top: .2rem; }
.page-actions { display: flex; gap: .55rem; flex-wrap: wrap; }

.crumbs { display: flex; align-items: center; gap: .4rem; font-size: .78rem;
  color: var(--text-3); font-weight: 600; margin-bottom: .4rem; }
.crumbs a:hover { color: var(--brand); }

/* ---------- 6. Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
  padding: 1.05rem 1.25rem;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { font-size: 1rem; }
.card-head p { font-size: .8rem; color: var(--text-3); }
.card-body { padding: 1.25rem; }
.card-body.tight { padding: .85rem; }
.card-foot { padding: .9rem 1.25rem; border-top: 1px solid var(--line-soft); background: var(--surface-2); }

.grid { display: grid; gap: 1.05rem; }
.g-1 { grid-template-columns: 1fr; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: 2fr 1fr; }
.g-1-2 { grid-template-columns: 1fr 2fr; }
.g-3-2 { grid-template-columns: 3fr 2fr; }

/* ---------- 7. KPI tiles ---------- */
.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: var(--tr);
  display: block;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 32%, var(--line)); }
.kpi::after {
  content: '';
  position: absolute;
  inset-block-start: -40%;
  inset-inline-end: -18%;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: var(--tone-soft, rgba(226,56,44,.1));
  filter: blur(4px);
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; position: relative; }
.kpi-icon {
  width: 46px; height: 46px; border-radius: 15px;
  display: grid; place-items: center; color: #fff;
  background: var(--tone-grad, var(--grad-brand));
  box-shadow: 0 12px 26px -14px var(--tone-shadow, rgba(226,56,44,.9));
}
.kpi-icon svg { width: 21px; height: 21px; }
.kpi-label { color: var(--text-2); font-size: .81rem; font-weight: 700; margin-top: .95rem; position: relative; }
.kpi-value { font-size: 1.72rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; position: relative; }
.kpi-value small { font-size: .95rem; font-weight: 700; color: var(--text-3); }

.delta {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .74rem; font-weight: 800;
  padding: .2rem .55rem; border-radius: var(--r-pill);
}
.delta.up { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.delta.down { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.delta.flat { background: var(--surface-3); color: var(--text-3); }

.tone-brand { --tone-grad: var(--grad-brand); --tone-soft: rgba(226,56,44,.11); --tone-shadow: rgba(226,56,44,.9); }
.tone-ok    { --tone-grad: linear-gradient(125deg,#10b981,#34d399); --tone-soft: rgba(16,185,129,.12); --tone-shadow: rgba(16,185,129,.85); }
.tone-warn  { --tone-grad: linear-gradient(125deg,#f59e0b,#fbbf24); --tone-soft: rgba(245,158,11,.14); --tone-shadow: rgba(245,158,11,.85); }
.tone-bad   { --tone-grad: linear-gradient(125deg,#ef4444,#f87171); --tone-soft: rgba(239,68,68,.13); --tone-shadow: rgba(239,68,68,.85); }
.tone-info  { --tone-grad: linear-gradient(125deg,#2e86ff,#22d3ee); --tone-soft: rgba(46,134,255,.13); --tone-shadow: rgba(46,134,255,.85); }
.tone-muted { --tone-grad: linear-gradient(125deg,#94a3b8,#cbd5e1); --tone-soft: rgba(148,163,184,.14); --tone-shadow: rgba(148,163,184,.7); }

/* ---------- 8. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .62rem 1.15rem;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font: inherit; font-size: .875rem; font-weight: 700;
  cursor: pointer;
  transition: var(--tr);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-brand { background: var(--grad-brand); color: #fff; box-shadow: 0 14px 28px -16px rgba(226,56,44,.95); }
.btn-brand:hover { transform: translateY(-2px); box-shadow: 0 18px 34px -16px rgba(226,56,44,1); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text-2); }
.btn-ghost:hover { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 45%, var(--line)); }
.btn-dark { background: var(--text); color: var(--surface); }
.btn-dark:hover { opacity: .88; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-bad { background: var(--bad); color: #fff; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-sm { padding: .4rem .8rem; font-size: .8rem; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-icon { padding: .48rem; width: 34px; height: 34px; border-radius: 11px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 9. Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .32rem;
  padding: .25rem .68rem;
  border-radius: var(--r-pill);
  font-size: .74rem; font-weight: 800;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.no-dot::before { display: none; }
.b-brand { background: color-mix(in srgb, var(--brand) 13%, transparent); color: var(--brand); }
.b-ok    { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.b-warn  { background: color-mix(in srgb, var(--warn) 16%, transparent); color: #b45309; }
.b-bad   { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }
.b-info  { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--accent); }
.b-muted { background: var(--surface-3); color: var(--text-3); }
[data-theme="dark"] .b-warn { color: #fbbf24; }

/* ---------- 10. Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.data th {
  text-align: start;
  padding: .8rem 1.1rem;
  font-size: .71rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data th a { display: inline-flex; align-items: center; gap: .25rem; }
table.data th a:hover { color: var(--brand); }
table.data td {
  padding: .82rem 1.1rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.data tbody tr { transition: background var(--tr); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: .82rem; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.cell-main { font-weight: 700; color: var(--text); }
.cell-sub { font-size: .77rem; color: var(--text-3); }

.empty {
  padding: 3.2rem 1.5rem;
  text-align: center;
  color: var(--text-3);
}
.empty svg { width: 54px; height: 54px; opacity: .3; margin-bottom: .85rem; }
.empty h4 { font-size: 1rem; margin-bottom: .3rem; color: var(--text-2); }
.empty p { font-size: .87rem; }

/* ---------- 11. Forms ---------- */
.field { margin-bottom: 1.05rem; }
.field > label, .form-label {
  display: block;
  font-size: .79rem;
  font-weight: 800;
  color: var(--text-2);
  margin-bottom: .38rem;
  letter-spacing: .01em;
}
.p-input {
  width: 100%;
  padding: .68rem .95rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: .89rem;
  transition: var(--tr);
}
.p-input:focus { outline: none; background: var(--surface); border-color: var(--brand); box-shadow: var(--ring); }
.p-input::placeholder { color: var(--text-3); }
.p-select { appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238d9ab3' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  background-size: 15px;
  padding-inline-end: 2.3rem;
}
html[dir="rtl"] .p-select { background-position: left .8rem center; }
select[multiple].p-select { background-image: none; padding-inline-end: .95rem; }
textarea.p-input { resize: vertical; min-height: 84px; }
.p-file { padding: .5rem .7rem; }
.p-check { width: 18px; height: 18px; accent-color: var(--brand); cursor: pointer; }

.check-row { display: flex; align-items: center; gap: .55rem; }
.check-row label { font-size: .86rem; font-weight: 600; color: var(--text-2); margin: 0; cursor: pointer; }

.help { font-size: .76rem; color: var(--text-3); margin-top: .3rem; }
.err { font-size: .77rem; color: var(--bad); margin-top: .3rem; font-weight: 600; }
.field.has-error .p-input { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 5%, var(--surface-2)); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.1rem; }
.form-grid .full { grid-column: 1 / -1; }

fieldset.fs { border: 0; padding: 0; margin: 0 0 1.6rem; }
fieldset.fs legend {
  font-size: .71rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase;
  color: var(--brand); padding: 0 0 .8rem; display: flex; align-items: center; gap: .5rem;
}
fieldset.fs legend::after { content: ''; height: 1px; flex: 1; background: var(--line); min-width: 40px; }

/* ---------- 12. Filters ---------- */
.toolbar {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.toolbar .p-input { background: var(--surface); width: auto; }
.toolbar-search { position: relative; flex: 1 1 210px; min-width: 180px; max-width: 340px; }
.toolbar-search svg { position: absolute; inset-inline-start: 13px; top: 50%; translate: 0 -50%;
  width: 16px; height: 16px; color: var(--text-3); }
.toolbar-search input { width: 100%; padding-inline-start: 39px; border-radius: var(--r-pill); }
.toolbar select,
.toolbar input[type="date"],
.toolbar input[type="number"] {
  min-width: 140px; max-width: 210px;
  border-radius: var(--r-pill); padding-block: .5rem;
}
.toolbar .pill-soft { white-space: nowrap; }

.chips { display: flex; gap: .45rem; flex-wrap: wrap; }
.chip {
  padding: .38rem .85rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .79rem; font-weight: 700; color: var(--text-2);
  transition: var(--tr);
  display: inline-flex; align-items: center; gap: .4rem;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--grad-brand); border-color: transparent; color: #fff; }
.chip b { font-weight: 800; }

/* ---------- 13. Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; padding: .95rem 1.25rem; border-top: 1px solid var(--line-soft); }
.pager-info { font-size: .81rem; color: var(--text-3); font-weight: 600; }
.pager-links { display: flex; gap: .3rem; }
.pager-links a, .pager-links span {
  min-width: 36px; height: 36px; padding: 0 .6rem;
  border-radius: 11px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; font-size: .82rem; font-weight: 700; color: var(--text-2);
  transition: var(--tr);
}
.pager-links a:hover { border-color: var(--brand); color: var(--brand); }
.pager-links .current { background: var(--grad-brand); border-color: transparent; color: #fff; }
.pager-links .disabled { opacity: .4; }

/* ---------- 14. Timeline ---------- */
.timeline { position: relative; padding-inline-start: 1.9rem; }
.timeline::before {
  content: ''; position: absolute; inset-block: .6rem; inset-inline-start: 7px;
  width: 2px; background: var(--line);
}
.tl-item { position: relative; padding-bottom: 1.35rem; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; inset-inline-start: -1.9rem; top: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--text-3);
}
.tl-item.is-brand .tl-dot { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.tl-item.is-ok .tl-dot { border-color: var(--ok); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 14%, transparent); }
.tl-item.is-warn .tl-dot { border-color: var(--warn); }
.tl-item.is-bad .tl-dot { border-color: var(--bad); }
.tl-item.is-info .tl-dot { border-color: var(--accent); }
.tl-title { font-weight: 800; font-size: .9rem; }
.tl-meta { font-size: .77rem; color: var(--text-3); }
.tl-note { font-size: .85rem; color: var(--text-2); margin-top: .2rem; }

/* ---------- 15. Progress ---------- */
.bar { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--grad-brand); transition: width .6s ease; }
.bar.ok > i { background: linear-gradient(90deg, #10b981, #34d399); }
.bar.warn > i { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar.bad > i { background: linear-gradient(90deg, #ef4444, #f87171); }
.bar.info > i { background: linear-gradient(90deg, #2e86ff, #22d3ee); }
.bar.sm { height: 6px; }

/* ---------- 16. Charts ---------- */
.chart-box { position: relative; width: 100%; }
.chart-box canvas { max-width: 100%; }
.chart-legend { display: flex; gap: 1.1rem; flex-wrap: wrap; margin-top: .9rem; }
.legend-item { display: inline-flex; align-items: center; gap: .42rem; font-size: .8rem;
  font-weight: 700; color: var(--text-2); }
.legend-item i { width: 11px; height: 11px; border-radius: 4px; }

/* ---------- 17. Alerts & messages ---------- */
.alert {
  display: flex; gap: .8rem; align-items: flex-start;
  padding: .95rem 1.1rem;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: .87rem;
}
.alert svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.alert b { display: block; font-size: .89rem; }
.alert.a-ok   { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); background: color-mix(in srgb, var(--ok) 8%, var(--surface)); color: var(--ok); }
.alert.a-warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--line)); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); color: #b45309; }
.alert.a-bad  { border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); background: color-mix(in srgb, var(--bad) 8%, var(--surface)); color: var(--bad); }
.alert.a-info { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); color: var(--accent); }
.alert p { color: inherit; opacity: .88; }
[data-theme="dark"] .alert.a-warn { color: #fbbf24; }

.toast-stack { position: fixed; top: 1.1rem; inset-inline-end: 1.1rem; z-index: 200;
  display: flex; flex-direction: column; gap: .6rem; max-width: 380px; }
.toast {
  display: flex; gap: .7rem; align-items: flex-start;
  padding: .85rem 1rem;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  font-size: .87rem; font-weight: 600;
  animation: slidein .3s cubic-bezier(.4,0,.2,1);
}
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } }
.toast.t-success { border-inline-start: 4px solid var(--ok); }
.toast.t-error   { border-inline-start: 4px solid var(--bad); }
.toast.t-warning { border-inline-start: 4px solid var(--warn); }
.toast.t-info    { border-inline-start: 4px solid var(--accent); }
.toast button { margin-inline-start: auto; background: none; border: 0; cursor: pointer;
  color: var(--text-3); padding: 0; }

/* ---------- 18. Board (kanban) ---------- */
.board { display: flex; gap: .9rem; overflow-x: auto; padding-bottom: .8rem; }
.board-col { min-width: 268px; flex: 1 0 268px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-lg); display: flex; flex-direction: column; }
.board-col-head { display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.board-col-head b { font-size: .85rem; }
.board-col-body { padding: .7rem; display: flex; flex-direction: column; gap: .6rem;
  max-height: 68vh; overflow-y: auto; }
.board-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: .8rem .9rem; transition: var(--tr); display: block;
}
.board-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); }
.board-card b { font-size: .83rem; font-family: ui-monospace, monospace; }
.board-card .route { font-size: .82rem; font-weight: 700; margin-top: .25rem; }
.board-card .meta { font-size: .74rem; color: var(--text-3); margin-top: .35rem;
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }

/* ---------- 19. Detail lists ---------- */
.dl { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: .55rem 1.1rem; font-size: .87rem; }
.dl dt { color: var(--text-3); font-weight: 700; font-size: .79rem; }
.dl dd { margin: 0; font-weight: 600; }

.stat-row { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.stat-row .s { display: flex; flex-direction: column; }
.stat-row .s b { font-size: 1.22rem; font-weight: 800; letter-spacing: -.02em; }
.stat-row .s span { font-size: .75rem; color: var(--text-3); font-weight: 700; }

.mini-list { display: flex; flex-direction: column; }
.mini-item { display: flex; align-items: center; gap: .75rem; padding: .7rem 0;
  border-bottom: 1px solid var(--line-soft); }
.mini-item:last-child { border-bottom: 0; }
.mini-item .mi-main { flex: 1; min-width: 0; }
.mini-item b { font-size: .86rem; display: block; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.mini-item small { font-size: .76rem; color: var(--text-3); }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1.3rem;
  overflow-x: auto; }
.tab {
  padding: .62rem 1.05rem; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: .87rem; font-weight: 700; color: var(--text-3);
  border-bottom: 2px solid transparent; transition: var(--tr); white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .2s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } }

/* ---------- 20. Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; }
.login-art {
  background: var(--grad-ink);
  background-image: radial-gradient(80% 60% at 20% 20%, rgba(226,56,44,.34), transparent 60%),
                    radial-gradient(70% 60% at 90% 90%, rgba(46,134,255,.28), transparent 62%),
                    var(--grad-ink);
  color: #fff; padding: clamp(2rem, 5vw, 4rem); display: flex; flex-direction: column;
  justify-content: space-between; position: relative; overflow: hidden;
}
.login-art h2 { color: #fff; font-size: clamp(1.7rem, 3vw, 2.5rem); line-height: 1.2; }
.login-art p { color: #a9bcd8; margin-top: .9rem; max-width: 42ch; }
.login-feat { display: flex; flex-direction: column; gap: .85rem; margin-top: 2rem; }
.login-feat div { display: flex; align-items: center; gap: .7rem; font-size: .9rem; font-weight: 600; color: #cfdcf0; }
.login-feat svg { width: 18px; height: 18px; color: var(--brand-2); }
.login-form { display: grid; place-items: center; padding: clamp(1.5rem, 4vw, 3rem); background: var(--bg); }
.login-card { width: 100%; max-width: 400px; }

/* ---------- 21. Misc ---------- */
.muted { color: var(--text-3); }
.small { font-size: .8rem; }
.tiny { font-size: .74rem; }
.bold { font-weight: 800; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.wrap { flex-wrap: wrap; }
.gap-1 { gap: .35rem; } .gap-2 { gap: .6rem; } .gap-3 { gap: 1rem; }
.mt-1 { margin-top: .4rem; } .mt-2 { margin-top: .8rem; } .mt-3 { margin-top: 1.25rem; }
.mb-1 { margin-bottom: .4rem; } .mb-2 { margin-bottom: .8rem; } .mb-3 { margin-bottom: 1.25rem; }
.w-100 { width: 100%; }
.text-end { text-align: end; }
.text-ok { color: var(--ok); } .text-bad { color: var(--bad); } .text-warn { color: var(--warn); }
.text-brand { color: var(--brand); }

.pill-soft { background: var(--surface-3); border-radius: var(--r-pill); padding: .22rem .7rem;
  font-size: .75rem; font-weight: 700; color: var(--text-2); }

.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-inline-start: -8px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-inline-start: 0; }

/* Raw e-mail text and model output: monospace, scrollable, never RTL-flipped
   because the message itself carries its own direction. */
.mail-body {
  margin: 0 0 .8rem; padding: .85rem 1rem; max-height: 420px; overflow: auto;
  white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace;
  font-size: .78rem; line-height: 1.6; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
}
html[dir="rtl"] .mail-body { direction: ltr; text-align: left; }

details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: '＋'; color: var(--text-3); font-size: 1.1rem; }
details.card[open] > summary::after { content: '−'; }

.scrim { position: fixed; inset: 0; background: rgba(7, 15, 30, .5); backdrop-filter: blur(2px);
  z-index: 55; display: none; }
.scrim.show { display: block; }

/* ---------- 22. Print ---------- */
@media print {
  .sidebar, .topbar, .page-actions, .no-print { display: none !important; }
  .main { margin: 0 !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #d8dfe9; }
}

/* ---------- 23. Responsive ---------- */
@media (max-width: 1320px) {
  .g-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-2-1, .g-1-2, .g-3-2 { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .sidebar { transform: translateX(-100%); }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-inline-start: 0 !important; }
  body.nav-collapsed .sidebar { width: var(--sidebar-w); }
  body.nav-collapsed .brand-text, body.nav-collapsed .nav-group-label,
  body.nav-collapsed .nav-text, body.nav-collapsed .nav-badge,
  body.nav-collapsed .site-link span { display: revert; }
  body.nav-collapsed .nav-link { justify-content: flex-start; padding-inline: .8rem; }
  body.nav-collapsed .sidebar-head { justify-content: flex-start; padding-inline: 1.25rem; }
}
@media (max-width: 760px) {
  .g-2, .g-3, .g-4, .g-5 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .search-box { display: none; }
  .user-chip .u-meta { display: none; }
  .page { padding: 1rem; }
  .toolbar { padding: .8rem; }
  .dropdown-menu { position: fixed; inset-inline: .8rem; top: auto; }
  .notif-menu { min-width: auto; }
}

/* ---------- 24. Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.reveal { animation: rise .4s cubic-bezier(.4,0,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.reveal:nth-child(2) { animation-delay: .04s; }
.reveal:nth-child(3) { animation-delay: .08s; }
.reveal:nth-child(4) { animation-delay: .12s; }
.reveal:nth-child(5) { animation-delay: .16s; }

/* =========================================================
   25. Right-to-left (Persian)
   ========================================================= */
html[dir="rtl"] {
  --font: 'Vazirmatn', 'Manrope', system-ui, 'Segoe UI', sans-serif;
}
html[dir="rtl"] body { font-size: 15px; }
html[dir="rtl"] h1, html[dir="rtl"] h2, html[dir="rtl"] h3,
html[dir="rtl"] h4, html[dir="rtl"] h5 { letter-spacing: 0; font-weight: 700; }
html[dir="rtl"] .nav-group-label,
html[dir="rtl"] .kpi-label,
html[dir="rtl"] table.data th,
html[dir="rtl"] fieldset.fs legend,
html[dir="rtl"] .search-group { letter-spacing: 0; }

/* Values that must stay left-to-right regardless of page direction. */
html[dir="rtl"] .mono,
html[dir="rtl"] .num,
html[dir="rtl"] .map-chip,
html[dir="rtl"] input[type="date"],
html[dir="rtl"] input[type="datetime-local"],
html[dir="rtl"] input[type="time"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="url"] { direction: ltr; }
html[dir="rtl"] .num { text-align: left; }

/* Numeric badges read as one LTR run but stay on the RTL side of their box. */
html[dir="rtl"] .kpi-value { direction: ltr; text-align: right; }
html[dir="rtl"] .delta,
html[dir="rtl"] .stat-row .s b,
html[dir="rtl"] .map-chip { direction: ltr; }
html[dir="rtl"] table.data td.num,
html[dir="rtl"] table.data th.num { text-align: left; }

/* Icons that encode a direction need mirroring. */
html[dir="rtl"] .pager-links svg,
html[dir="rtl"] .btn svg use[href="#i-right"],
html[dir="rtl"] .crumbs svg { scale: -1 1; }

html[dir="rtl"] .nav-link.active::before { border-radius: 4px 0 0 4px; }
html[dir="rtl"] .toast { animation-name: slideinRtl; }
@keyframes slideinRtl { from { opacity: 0; transform: translateX(-24px); } }
html[dir="rtl"] .timeline::before { inset-inline-start: 7px; }

/* ---------- 21. AI assistant ---------- */
.chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 1.05rem; }
.chat-card { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 11rem);
             min-height: 540px; }
/* An empty thread shows the welcome panel, which reads better at its natural
   height than squeezed into a scroll box that has nothing to scroll yet. */
.chat-card.is-empty { height: auto; min-height: 0; }

.chat-log { flex: 1; overflow-y: auto; padding: 1.15rem 1.25rem; display: flex;
            flex-direction: column; gap: .95rem; scroll-behavior: smooth; }
.chat-log::-webkit-scrollbar { width: 7px; }
.chat-log::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.bubble { max-width: 78%; display: flex; flex-direction: column; gap: .35rem; }
.bubble-body { padding: .75rem 1rem; border-radius: var(--r-md); font-size: .89rem;
               line-height: 1.62; overflow-wrap: anywhere; }
/* An answer can quote a Latin city or plate inside Persian prose, or arrive
   in a different script than the panel. `plaintext` lets every paragraph take
   its direction from its own first strong character, which keeps trailing
   punctuation where the reader expects it. */
.bubble-body p, .bubble-body li, .bubble-body h4 { unicode-bidi: plaintext; }
.bubble-body p + p { margin-top: .5rem; }
.bubble-body ul { margin: .45rem 0 .15rem; padding-inline-start: 1.15rem; }
.bubble-body li { margin-bottom: .28rem; }
.bubble-body h4 { font-size: .88rem; font-weight: 800; margin: .55rem 0 .3rem; }
.bubble-body code { background: rgba(127, 140, 170, .16); padding: .1rem .32rem;
                    border-radius: var(--r-xs); font-size: .84em; }

.b-user { align-self: flex-end; align-items: flex-end; }
.b-user .bubble-body { background: var(--grad-brand); color: #fff;
                       border-end-end-radius: var(--r-xs); }
.b-assistant { align-self: flex-start; }
.b-assistant .bubble-body { background: var(--surface-2); border: 1px solid var(--line);
                            border-end-start-radius: var(--r-xs); }

.bubble-meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center;
               font-size: .7rem; color: var(--text-3); padding-inline-start: .25rem; }
.chip-mini { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand);
             padding: .1rem .45rem; border-radius: var(--r-pill); font-weight: 700; }
.chip-mini.soft { background: var(--surface-3); color: var(--text-3); }

/* Typing indicator while the provider is being called. */
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3);
          animation: blink 1.15s infinite; }
.dots i:nth-child(2) { animation-delay: .18s; }
.dots i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.chat-welcome { margin: auto; text-align: center; max-width: 520px; padding: .75rem 0; }
.welcome-mark { width: 58px; height: 58px; border-radius: 20px; display: grid;
                place-items: center; margin: 0 auto .85rem; background: var(--grad-brand);
                color: #fff; box-shadow: 0 16px 32px -18px rgba(226, 56, 44, .95); }
.welcome-mark svg { width: 26px; height: 26px; }
.chat-welcome h4 { font-size: 1.05rem; margin-bottom: .35rem; }

.chat-compose { border-top: 1px solid var(--line-soft); padding: .9rem 1.25rem 1rem;
                background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.chat-compose form { display: flex; gap: .55rem; align-items: flex-end; }
.chat-compose textarea { flex: 1; resize: none; min-height: 44px; max-height: 170px;
                         padding: .68rem .9rem; font: inherit; font-size: .89rem;
                         color: var(--text); background: var(--surface);
                         border: 1px solid var(--line); border-radius: var(--r-md); }
.chat-compose textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.chat-compose .icon-btn { height: 44px; width: 44px; }

.chat-error { color: var(--bad); font-size: .82rem; margin-bottom: .5rem; }
.voice-hint { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem;
              font-size: .82rem; color: var(--text-2); }
/* An author `display` beats the user agent's [hidden] rule, so say it again. */
.voice-hint[hidden], .chat-error[hidden] { display: none; }
.rec-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--bad);
           animation: pulse 1.1s ease-in-out infinite; flex: none; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.8); } }
#chatMic.recording { color: #fff; background: var(--bad); border-color: var(--bad); }

.chat-rail { align-content: start; }
.thread-list { display: flex; flex-direction: column; gap: .2rem; max-height: 320px;
               overflow-y: auto; }
.thread { display: flex; align-items: center; gap: .3rem; border-radius: var(--r-md); }
.thread:hover { background: var(--surface-3); }
.thread.active { background: color-mix(in srgb, var(--brand) 8%, transparent); }
.thread a { flex: 1; min-width: 0; padding: .5rem .6rem; display: block; }
.thread b { font-size: .83rem; display: block; white-space: nowrap; overflow: hidden;
            text-overflow: ellipsis; }
.thread small { font-size: .71rem; }
.thread form { flex: none; opacity: 0; transition: opacity var(--tr); }
.thread:hover form { opacity: 1; }
.thread .btn-icon { width: 30px; height: 30px; padding: .35rem; }

@media (max-width: 1180px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-card { height: auto; min-height: 62vh; }
  .bubble { max-width: 92%; }
}

/* The bubble tails and the compose row follow the writing direction. */
html[dir="rtl"] .bubble-body ul { padding-inline-start: 1.15rem; }

/* ---------- 26. Daily log ---------- */
.jl-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem;
           margin-bottom: 1.1rem; }
.jl-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
          padding: .75rem .95rem; box-shadow: var(--shadow-sm); }
.jl-kpi b { display: block; font-size: 1.22rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; }
.jl-kpi b small { font-size: .85rem; color: var(--text-3); font-weight: 700; }
.jl-kpi span { font-size: .74rem; color: var(--text-3); font-weight: 700; }
.jl-kpi small { font-size: .72rem; color: var(--text-3); }

.month-nav { display: inline-flex; align-items: center; gap: .3rem; }
.month-nav input[type="month"] { width: auto; min-width: 150px; }

table.jl-table { font-size: .8rem; }
table.jl-table th { padding: .6rem .55rem; letter-spacing: .06em; }
table.jl-table td { padding: .42rem .55rem; }
table.jl-table td a { color: inherit; }
table.jl-table td a:hover { color: var(--brand); }
table.jl-table .mono { font-size: .76rem; }
table.jl-table .badge { font-size: .66rem; padding: .12rem .45rem; }
table.jl-table .row-actions { opacity: .35; transition: opacity var(--tr); }
table.jl-table tr:hover .row-actions { opacity: 1; }
table.jl-table .btn-icon { width: 28px; height: 28px; padding: .3rem; }
tr.jl-day td { background: var(--surface-2); font-weight: 800; font-size: .78rem; color: var(--text-2);
               padding: .5rem .7rem; border-top: 2px solid var(--line); }
tr.jl-day td a:hover { color: var(--brand); }
tr.jl-day .pill-soft { margin-inline-start: .4rem; }
tr.jl-cancelled td { opacity: .5; text-decoration: line-through; }
tr.jl-cancelled td:first-child, tr.jl-cancelled td:last-child { text-decoration: none; }
tr.jl-total td { font-weight: 800; background: var(--surface-2); border-top: 2px solid var(--line); }
.jl-notes { max-width: 220px; }
.jl-own { color: var(--ok); vertical-align: -2px; margin-inline-end: .2rem; }

tr.jl-quick td { background: color-mix(in srgb, var(--brand) 5%, var(--surface));
                 padding: .35rem .25rem; border-bottom: 2px solid color-mix(in srgb, var(--brand) 30%, var(--line)); }
tr.jl-quick .p-input { padding: .4rem .5rem; font-size: .78rem; border-radius: var(--r-xs);
                       min-width: 78px; background: var(--surface); }
tr.jl-quick .p-select { padding-inline-end: 1.6rem; background-position: right .4rem center; background-size: 12px; }
tr.jl-quick input[type="date"] { min-width: 120px; }
tr.jl-quick input[name="notes"] { min-width: 120px; }
tr.jl-quick .btn-sm { padding: .38rem .5rem; }
.jl-hint { color: var(--ok); font-weight: 700; }

.bulk-bar { display: none; align-items: center; gap: .5rem; padding: .6rem 1.1rem;
            background: color-mix(in srgb, var(--accent) 8%, var(--surface)); border-bottom: 1px solid var(--line); }
.bulk-bar.show { display: flex; flex-wrap: wrap; }
