/* Gexart CRM — single stylesheet. Brand: Gexart orange + navy. Light, dark and system themes. */
:root {
  --bg: #f6f7f9; --panel: #fff; --line: #e5e7eb; --line2: #eef0f3; --text: #1e293b; --text-strong: #0f172a; --text2: #334155; --muted: #64748b; --soft: #94a3b8;
  --side: #ffffff; --side-t: #1e293b; --side-sec: #94a3b8; --nav-on: #fff1e7; --nav-on-t: #c2410c;
  --primary: #f26a1b; --primary-d: #d9570c; --accent: #1d3557; --accent-bg: #fff4ec; --brand: #14213d; --brand-solid: #14213d; --orange: #f26a1b;
  --hover: #f4f6f9; --stripe: #f8fafc; --row-hover: #fff7f0; --soft-bg: #f8fafc; --bg2: #eef1f5; --input: #fff; --focus: rgba(242, 106, 27, .16);
  --red: #dc2626; --red-bg: #fef2f2; --amber: #b45309; --amber-bg: #fffbeb; --green: #15803d; --green-bg: #f0fdf4;
  --r: 10px; --sh: 0 1px 2px rgba(16, 24, 40, .04); --sh2: 0 12px 32px rgba(16, 24, 40, .18);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  color-scheme: light;
}
/* Dark palette (navy based). Applied for data-theme="dark", or "system" when the OS is dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1220; --panel: #111a2e; --line: #23314c; --line2: #1a2540; --text: #e2e8f0; --text-strong: #f8fafc; --text2: #cbd5e1; --muted: #94a3b8; --soft: #64748b;
    --side: #0e1628; --side-t: #cbd5e1; --side-sec: #64748b; --nav-on: #2b1a10; --nav-on-t: #fb923c;
    --primary: #f47b20; --primary-d: #e0660f; --accent: #fb923c; --accent-bg: #24170f; --brand: #e2e8f0; --brand-solid: #1e2d4d;
    --hover: #17223a; --stripe: #0f1729; --row-hover: #1c2438; --soft-bg: #0f1729; --bg2: #0f1729; --input: #0d1526; --focus: rgba(244, 123, 32, .25);
    --red: #f87171; --red-bg: #2a1215; --amber: #fbbf24; --amber-bg: #2a1f0b; --green: #4ade80; --green-bg: #0f2418;
    --sh: 0 1px 2px rgba(0, 0, 0, .3); --sh2: 0 12px 32px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1220; --panel: #111a2e; --line: #23314c; --line2: #1a2540; --text: #e2e8f0; --text-strong: #f8fafc; --text2: #cbd5e1; --muted: #94a3b8; --soft: #64748b;
  --side: #0e1628; --side-t: #cbd5e1; --side-sec: #64748b; --nav-on: #2b1a10; --nav-on-t: #fb923c;
  --primary: #f47b20; --primary-d: #e0660f; --accent: #fb923c; --accent-bg: #24170f; --brand: #e2e8f0; --brand-solid: #1e2d4d;
  --hover: #17223a; --stripe: #0f1729; --row-hover: #1c2438; --soft-bg: #0f1729; --bg2: #0f1729; --input: #0d1526; --focus: rgba(244, 123, 32, .25);
  --red: #f87171; --red-bg: #2a1215; --amber: #fbbf24; --amber-bg: #2a1f0b; --green: #4ade80; --green-bg: #0f2418;
  --sh: 0 1px 2px rgba(0, 0, 0, .3); --sh2: 0 12px 32px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
/* Logo variants: dark wordmark on light backgrounds, light wordmark in dark mode */
.only-dark { display: none !important; }
:root[data-theme="dark"] .only-light { display: none !important; }
:root[data-theme="dark"] .only-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .only-light { display: none !important; }
  :root:not([data-theme="light"]) .only-dark { display: block !important; }
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; color: var(--text-strong); }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 16px; } h4 { font-size: 13px; }
p { margin: 0 0 8px; }
small, .muted { color: var(--muted); }
.ic { width: 18px; height: 18px; flex: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

/* ---------- Boot / auth ---------- */
.boot { display: grid; place-items: center; height: 100vh; }
.gx-mark { display: inline-grid; background: var(--brand-solid) !important; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: #fff; font-weight: 800; letter-spacing: -1px; font-size: 16px; flex: none; }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--brand-solid); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { font-size: 28px; line-height: 1.2; max-width: 420px; margin-top: 24px; color: #fff; }
.auth-side p { color: #c7d4e5; max-width: 420px; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; background: var(--panel); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card form { display: grid; gap: 12px; margin-top: 20px; }
.logo-img { height: 36px; width: auto; display: block; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 300px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-t); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); }
.side-logo { display: flex; align-items: center; gap: 14px; padding: 22px 22px 20px; border-bottom: 1px solid var(--line2); min-height: 96px; }
.side-logo .org { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 17px; color: #fff; flex: none;
  background: linear-gradient(135deg, #1d3557, #14213d); box-shadow: inset 0 0 0 3px var(--orange); }
.side-logo .gx-mark { width: 42px; height: 42px; font-size: 15px; }
.side-logo b { display: block; color: var(--brand); font-size: 19px; font-weight: 600; line-height: 1.2; }
.side-logo small { display: block; color: #6b7a90; font-size: 14px; margin-top: 2px; }
.side-logo .names { min-width: 0; }
.side-logo .names b, .side-logo .names small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-scroll { overflow-y: auto; flex: 1; padding-bottom: 12px; }
.nav { display: grid; gap: 2px; padding: 4px 12px; }
.nav-sec { font-size: 14px; text-transform: uppercase; letter-spacing: .02em; color: var(--side-sec); padding: 22px 12px 8px; }
.nav a, .nav button.navbtn { display: flex; align-items: center; gap: 14px; padding: 13px 12px; border-radius: 8px; color: var(--side-t); font-weight: 450; font-size: 15px; border: 0; background: none; width: 100%; cursor: pointer; text-align: left; }
.nav a:hover, .nav button.navbtn:hover { background: var(--hover); text-decoration: none; }
.nav a.on { background: var(--nav-on); color: var(--nav-on-t); box-shadow: inset 3px 0 0 var(--nav-on-t); }
.nav .sub a { padding-left: 38px; }
.nav .chev { margin-left: auto; transition: transform .15s; }
.nav .open .chev { transform: rotate(180deg); }
.nav a .cnt { margin-left: auto; font-size: 11px; background: var(--bg2); color: var(--text2); border-radius: 10px; padding: 1px 8px; }
.ws-box { margin: 14px 12px 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft-bg); }
.ws-box small { color: var(--muted); display: block; font-size: 12px; }
.ws-box b { color: var(--brand); }
.ws-box a { font-size: 13px; display: inline-flex; gap: 4px; align-items: center; margin-top: 6px; }
.side-bottom { border-top: 1px solid var(--line2); padding: 10px 12px 14px; display: grid; gap: 2px; }
.side-bottom a, .side-bottom button { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 8px; color: var(--side-t); font-size: 15px; background: none; border: 0; cursor: pointer; width: 100%; text-align: left; }
.side-bottom a:hover, .side-bottom button:hover { background: var(--hover); text-decoration: none; }
.side-bottom a.on { background: var(--nav-on); color: var(--nav-on-t); box-shadow: inset 3px 0 0 var(--nav-on-t); }
.side-bottom button { color: var(--muted); }
/* Collapsed sidebar: icons only */
.app.collapsed { grid-template-columns: 76px 1fr; }
.app.collapsed .side-logo { padding: 22px 17px; justify-content: center; }
.app.collapsed .side-logo .names, .app.collapsed .nav-sec, .app.collapsed .nav span, .app.collapsed .side-bottom span, .app.collapsed .ws-box, .app.collapsed .chev, .app.collapsed .cnt { display: none; }
.app.collapsed .nav a, .app.collapsed .nav button.navbtn, .app.collapsed .side-bottom a, .app.collapsed .side-bottom button { justify-content: center; padding: 13px 0; }
.app.collapsed .nav .sub a { padding-left: 0; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 0 28px; background: var(--panel); border-bottom: 1px solid var(--line); min-height: 80px; }
.top h1 { font-size: 22px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .sp { flex: 1; }
.top select.switcher { max-width: 230px; height: 40px; }
.icon-btn.burger { display: none; }
.view { padding: 22px 28px; min-width: 0; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; position: relative; color: var(--text2); }
.icon-btn:hover { background: var(--hover); }
.icon-btn .dot { position: absolute; top: 2px; right: 0; background: var(--red); color: #fff; font-size: 10px; border-radius: 9px; min-width: 17px; height: 17px; display: grid; place-items: center; padding: 0 4px; font-weight: 600; }
.umenu { position: relative; }
.avatar-btn { width: 50px; height: 50px; border-radius: 50%; border: 1px solid var(--line); background: var(--accent-bg); color: var(--nav-on-t); font-weight: 600; font-size: 17px; cursor: pointer; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; }
.create-btn { height: 46px; padding: 0 18px; border-radius: 6px; font-size: 16px; font-weight: 600; }
.pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--sh2); min-width: 230px; z-index: 50; padding: 6px; }
.pop a, .pop button.item { display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 12px; border-radius: 6px; color: var(--text); background: none; border: 0; cursor: pointer; text-align: left; font-size: 14px; }
.pop a:hover, .pop button.item:hover { background: var(--accent-bg); text-decoration: none; }
.pop .who { padding: 8px 10px; border-bottom: 1px solid var(--line2); margin-bottom: 4px; }
.pop .sec { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 12px 4px; }
.notif-pop { width: 380px; max-width: calc(100vw - 24px); max-height: 70vh; overflow: auto; padding: 0; }
.notif-pop .nh { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.notif { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line2); color: var(--text); cursor: pointer; }
.notif:hover { background: var(--bg); text-decoration: none; }
.notif.unread { background: var(--accent-bg); }
.notif b { display: block; font-weight: 600; font-size: 13px; }
.notif small { display: block; }

/* ---------- Settings layout (inner nav like Docfyn) ---------- */
.settings-wrap { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 30px; align-items: start; }
.settings-wrap > * { min-width: 0; }
.snav { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 26px 20px; position: sticky; top: 100px; }
.snav h2 { font-size: 22px; padding: 0 14px 14px; }
.snav .sec { font-size: 15px; text-transform: uppercase; color: var(--side-sec); padding: 22px 14px 10px; letter-spacing: .01em; }
.snav a { display: block; padding: 14px; border-radius: 8px; color: var(--side-t); font-size: 15px; }
.snav a:hover { background: var(--hover); text-decoration: none; }
.snav a.on { background: var(--nav-on); color: var(--nav-on-t); }
.shead { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 20px; min-height: 76px; flex-wrap: wrap; }
.shead h2 { font-size: 21px; font-weight: 500; }
.shead .sp { flex: 1; }
.shead p { margin: 0; width: 100%; color: var(--muted); font-size: 13px; }
.scard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.scard + .scard { margin-top: 20px; }
.scard .sbody { padding: 18px; }
.matrix td.c, .matrix th.c { text-align: center; }
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.app-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.app-card .logo { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px; }
.app-card p { color: var(--muted); font-size: 13px; flex: 1; margin: 0; }
.list-edit { display: grid; gap: 8px; }
.list-edit .li { display: grid; grid-template-columns: auto 1fr 140px 52px auto; gap: 8px; align-items: center; }

/* ---------- Page bits ---------- */
.page-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.page-h .sp { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
.card + .card { margin-top: 14px; }
.card-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line2); flex-wrap: wrap; }
.card-h .sp { flex: 1; }
.card-b { padding: 14px; }
.card-b.flush { padding: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.stat-l { font-size: 12px; color: var(--muted); }
.stat-v { font-size: 22px; font-weight: 650; margin-top: 2px; letter-spacing: -.02em; }
.stat-s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.stat.red .stat-v { color: var(--red); } .stat.amber .stat-v { color: var(--amber); } .stat.green .stat-v { color: var(--green); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 10px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.hr { height: 1px; background: var(--line2); margin: 14px 0; }
.loading { padding: 24px; color: var(--muted); text-align: center; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty .ic { width: 28px; height: 28px; color: var(--soft); }
.empty p { margin: 8px 0 12px; }
.chart-empty { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }
.note { padding: 10px 12px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; }
.note.warn { background: var(--amber-bg); border-color: #fde68a; } .note.err { background: var(--red-bg); border-color: #fecaca; }
.note.info { background: var(--accent-bg); border-color: var(--line); }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 550; white-space: nowrap; color: var(--text); }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { background: var(--panel); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: 6px; }
.btn.xs { height: 24px; padding: 0 7px; font-size: 12px; border-radius: 6px; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0 4px; height: auto; }
.btn.green { background: var(--green); color: #fff; border-color: var(--green); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--input); color: var(--text); min-height: 34px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--primary); }
input[type=color] { padding: 2px; height: 34px; width: 48px; }
textarea { resize: vertical; }
.field { display: grid; gap: 5px; font-size: 13px; min-width: 0; }
.field > span { font-weight: 550; color: var(--text2); font-size: 12.5px; }
.field small { font-size: 11.5px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fgrid .full { grid-column: 1 / -1; }
.fgrid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.form-err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 0; }
.form-err:empty { display: none; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters select, .filters input { width: auto; min-width: 120px; height: 32px; min-height: 32px; padding: 4px 8px; font-size: 13px; border-radius: 16px; background: var(--panel); }
.filters input[type=search] { min-width: 220px; }
.filters .on { border-color: var(--primary); background: var(--accent-bg); }
.range { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.range input, .range select { width: auto; height: 32px; min-height: 32px; padding: 4px 8px; font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; font-size: 14px; color: var(--text-strong); padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line2); vertical-align: middle; font-size: 14px; }
.tbl tbody tr:nth-child(even) { background: var(--stripe); }
.tbl tbody tr:hover { background: var(--row-hover); }
.tbl tr.click { cursor: pointer; }
.tbl td { white-space: nowrap; }
.tbl td .cell-sub, .tbl td.wrap { white-space: normal; min-width: 120px; max-width: 340px; }
.tbl tr.sel { background: var(--accent-bg); }
.tbl .num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .nowrap { white-space: nowrap; }
.tbl td.chk, .tbl th.chk { width: 34px; }
.cell-main { font-weight: 550; }
.cell-sub { font-size: 12px; color: var(--muted); }
.more { padding: 12px; text-align: center; border-top: 1px solid var(--line2); }
.late { color: var(--red); font-weight: 550; }
.bulkbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 12px; background: var(--brand-solid); color: #fff; border-radius: 8px; margin-bottom: 10px; }
.bulkbar select { width: auto; height: 30px; min-height: 30px; padding: 2px 8px; }

/* ---------- Badges, tabs ---------- */
.badge { --b: #64748b; display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 550; white-space: nowrap;
  color: var(--b); background: color-mix(in srgb, var(--b) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--b) 30%, var(--panel)); }
.badge.solid { background: var(--b); color: #fff; border-color: var(--b); }
.flag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; margin: 1px 2px 1px 0; font-weight: 550; }
.flag.red { background: var(--red-bg); color: var(--red); } .flag.amber { background: var(--amber-bg); color: var(--amber); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tab { padding: 9px 12px; border: 0; background: none; cursor: pointer; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.on { color: var(--nav-on-t); border-bottom-color: var(--nav-on-t); }
.tab b { background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 0 6px; font-size: 11px; margin-left: 4px; }
.pbar { height: 6px; background: var(--line2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.pbar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ---------- Modal, drawer, toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(9, 9, 11, .45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--sh2); }
.modal.wide { max-width: 760px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line2); }
.modal-b { padding: 16px; overflow: auto; display: grid; gap: 12px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line2); }
.drawer-wrap { position: fixed; inset: 0; background: rgba(9, 9, 11, .3); z-index: 90; display: flex; justify-content: flex-end; }
.drawer { width: 100%; max-width: 560px; background: var(--panel); height: 100%; display: flex; flex-direction: column; box-shadow: var(--sh2); animation: slide .18s ease-out; }
.drawer.wide { max-width: 760px; }
@keyframes slide { from { transform: translateX(30px); opacity: .6; } }
.drawer-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); gap: 10px; }
.drawer-b { overflow-y: auto; padding: 16px; flex: 1; }
#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--brand-solid); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--sh2); font-size: 13px; transition: opacity .4s; max-width: 90vw; }
.toast.err { background: var(--red); } .toast.out { opacity: 0; }

/* ---------- Timeline ---------- */
.timeline { display: grid; gap: 0; }
.tl { display: grid; grid-template-columns: 28px 1fr; gap: 8px; padding: 8px 0; border-bottom: 1px dashed var(--line2); }
.tl-i { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--bg); color: var(--muted); }
.tl-i .ic { width: 14px; height: 14px; }
.tl.call .tl-i { background: var(--accent-bg); color: var(--accent); } .tl.stage .tl-i { background: var(--green-bg); color: var(--green); }
.tl.whatsapp .tl-i { background: #ecfdf5; color: #059669; }
.tl-t { font-size: 13px; } .tl-t small { display: block; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 10px; fill: var(--muted); }
.chart .gl { stroke: var(--line2); }
.hbars { display: grid; gap: 7px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 34%) 1fr 48px; gap: 8px; align-items: center; font-size: 12.5px; }
.hbar-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-t { height: 10px; background: var(--line2); border-radius: 5px; overflow: hidden; }
.hbar-t i { display: block; height: 100%; border-radius: 5px; }
.hbar b { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.donut { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.donut ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: 12.5px; }
.donut li i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.donut li b { margin-left: 4px; }
.dn-v { font-size: 22px; font-weight: 650; fill: var(--text); } .dn-l { font-size: 10px; fill: var(--muted); }

/* ---------- Board ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--bg2); border-radius: 10px; padding: 8px; min-height: 120px; }
.col h4 { display: flex; justify-content: space-between; padding: 4px 6px 8px; color: var(--text2); }
.tcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; cursor: pointer; box-shadow: var(--sh); }
.tcard:hover { border-color: #cbd5e1; }
.tcard .t { font-weight: 550; font-size: 13px; margin-bottom: 4px; }
.tcard .m { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 11.5px; color: var(--muted); }

/* ---------- HR grid ---------- */
.att { border-collapse: collapse; font-size: 11.5px; }
.att th, .att td { border: 1px solid var(--line2); padding: 0; text-align: center; min-width: 28px; height: 28px; }
.att th { background: var(--soft-bg); font-weight: 600; padding: 3px; }
.att td.name { text-align: left; padding: 4px 8px; white-space: nowrap; min-width: 140px; position: sticky; left: 0; background: var(--panel); font-size: 12.5px; }
.att td.c { cursor: pointer; font-weight: 600; }
.att td.c:hover { outline: 2px solid var(--primary); outline-offset: -2px; }
.a-present { background: #dcfce7; color: #166534; } .a-wfh { background: #dbeafe; color: #1e40af; } .a-half_day { background: #fef3c7; color: #92400e; }
.a-absent { background: #fee2e2; color: #991b1b; } .a-leave { background: #ede9fe; color: #5b21b6; } .a-holiday { background: var(--bg2); color: #71717a; } .a-off { background: var(--soft-bg); color: #d4d4d8; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; margin-top: 10px; }
.legend span { display: inline-flex; gap: 5px; align-items: center; }
.legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.checkin { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .settings-wrap { grid-template-columns: 240px minmax(0, 1fr); gap: 18px; } .app { grid-template-columns: 250px 1fr; } }
@media (max-width: 900px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .settings-wrap { grid-template-columns: minmax(0, 1fr); } .snav { position: static; padding: 12px; } .snav .sec { padding: 10px 14px 4px; } .snav a { padding: 9px 14px; }
  .top { padding: 0 12px; min-height: 64px; gap: 8px; } .top h1 { font-size: 18px; } .create-btn { height: 40px; padding: 0 12px; } .create-btn .lbl { display: none; } .avatar-btn { width: 40px; height: 40px; }
  .collapse-btn { display: none !important; } .side-logo { min-height: 72px; padding: 16px; }
  .list-edit .li { grid-template-columns: auto 1fr 52px auto; } .list-edit .li .key { display: none; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 80; transform: translateX(-100%); transition: transform .2s; }
  .app.nav-open .side { transform: none; box-shadow: var(--sh2); }
  .app.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 70; }
  .icon-btn.burger { display: inline-grid; }
  .top { padding: 8px 12px; }
  .view { padding: 14px 12px; }
  .g2, .g3, .g4, .fgrid, .fgrid3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; } .auth-side { display: none; }
  .umenu-btn .uname, .top select.switcher { display: none; }
  .top .switcher-m { display: inline-grid; }
  .kv { grid-template-columns: 110px 1fr; }
  .filters input[type=search] { min-width: 0; flex: 1 1 100%; }
}
@media (min-width: 901px) { .top .switcher-m { display: none; } }

/* ---------- Brand logo ---------- */
.side-logo .logo-full { height: 40px; width: auto; display: block; }
.side-logo .logo-mark { height: 42px; width: 42px; display: none; }
.app.collapsed .side-logo .logo-full { display: none !important; }
.app.collapsed .side-logo .logo-mark { display: block; }
.auth-logo { height: 46px; width: auto; display: block; }
.powered { display: flex; align-items: center; gap: 8px; padding: 8px 12px 0; font-size: 11.5px; color: var(--muted); }
.powered img { height: 18px; width: 18px; }
.app.collapsed .powered span { display: none; }
.theme-switch { display: flex; gap: 4px; padding: 6px 10px; }
.theme-switch button { flex: 1; border: 1px solid var(--line); background: var(--panel); border-radius: 6px; padding: 6px 4px; cursor: pointer; font-size: 12px; color: var(--text); }
.theme-switch button.on { border-color: var(--primary); color: var(--nav-on-t); background: var(--nav-on); }
/* attendance colours in dark mode */
:root[data-theme="dark"] .att td.name { background: var(--panel); }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--bg2); }
.status-pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--soft); }
.status-pill.in i { background: var(--green); } .status-pill.break i { background: var(--amber); } .status-pill.out i { background: var(--muted); }
.ticket-msg { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--panel); }
.ticket-msg.internal { background: var(--amber-bg); border-color: var(--amber); }
.ticket-msg.client { background: var(--accent-bg); }
/* Client workspace header: Gexart mark next to the client's name */
.side-logo .org-logo { width: 44px; height: 44px; flex: none; object-fit: contain; }

/* ---- v3 ---- */
.pw { position: relative; display: block; }
.pw input { width: 100%; padding-right: 38px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; }
.pw-eye:hover { background: var(--hover); color: var(--text); }
.pw-eye .ic { width: 17px; height: 17px; }
.permx { width: 100%; }
.permx th, .permx td { padding: 8px 10px; text-align: center; }
.permx th:first-child, .permx td:first-child { text-align: left; }
.permx tbody tr:nth-child(even) { background: var(--stripe); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kv2 { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 13px; }
.kv2 dt { color: var(--muted); } .kv2 dd { margin: 0; }
.code-box { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; word-break: break-all; font-size: 12.5px; }
.tpl-box { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }

/* chat dock + nav badges */
.nav-badge { margin-left: auto; background: var(--primary); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 6px; line-height: 17px; font-weight: 650; }
#chatdock { position: fixed; bottom: 0; right: 18px; z-index: 40; display: flex; align-items: flex-end; gap: 10px; pointer-events: none; }
#chatdock > * { pointer-events: auto; }
.cd-wins { display: flex; gap: 10px; align-items: flex-end; }
.cd-bar { position: relative; }
.cd-head { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border: 1px solid var(--line); border-bottom: 0; background: var(--panel); color: var(--text-strong); border-radius: 10px 10px 0 0; cursor: pointer; box-shadow: var(--sh2); font: inherit; }
.cd-head .ic { width: 17px; height: 17px; color: var(--primary); }
.cd-badge { background: #dc2626; color: #fff; font-size: 11px; border-radius: 10px; padding: 0 6px; line-height: 17px; font-weight: 700; margin-left: auto; }
.cd-list { position: absolute; right: 0; bottom: 38px; width: 280px; max-height: 360px; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px 10px 0 0; box-shadow: var(--sh2); }
.cd-new { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line2); }
.cd-row { display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line2); }
.cd-row:hover { background: var(--hover); } .cd-row small { grid-column: 1 / -1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cd-win { width: 300px; height: 380px; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; box-shadow: var(--sh2); }
.cd-win.min { height: 38px; } .cd-win.min .cd-msgs, .cd-win.min .cd-in { display: none; }
.cd-wh { display: flex; justify-content: space-between; align-items: center; padding: 0 10px; height: 38px; background: var(--brand-solid); color: #fff; border-radius: 10px 10px 0 0; flex: none; cursor: pointer; }
.cd-wh button { background: none; border: 0; color: #fff; cursor: pointer; font-size: 15px; padding: 2px 6px; }
.cd-msgs { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.cd-m { max-width: 82%; align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px 10px; font-size: 13px; word-break: break-word; }
.cd-m.me { align-self: flex-end; background: var(--accent-bg); border-color: #fed7aa; } .cd-m small { display: block; color: var(--muted); font-size: 10.5px; }
.cd-in { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); flex: none; align-items: center; }
.cd-in input[name=b] { flex: 1; min-width: 0; } .cd-clip { cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.cd-in button { height: 32px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--primary); color: #fff; cursor: pointer; }
@media (max-width: 720px) { .cd-win { width: 92vw; } #chatdock { right: 4px; } .mail-wrap { grid-template-columns: 1fr !important; } }

/* ================= polish: motion, depth, details ================= */
:root { --sh: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06); --sh2: 0 24px 60px rgba(16, 24, 40, .28); }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
.view > * { animation: gx-in .24s ease both; }
@keyframes gx-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes gx-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.card, .scard, .stat { border-radius: 14px; box-shadow: var(--sh); transition: box-shadow .18s, transform .18s, border-color .18s; }
.stat:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(16, 24, 40, .12); border-color: var(--primary); }
.stat { position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--primary), transparent 70%); opacity: .0; transition: opacity .18s; }
.stat:hover::after { opacity: 1; }
.btn { border-radius: 10px; transition: transform .12s, box-shadow .15s, background .15s, filter .15s; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn.primary { background: linear-gradient(180deg, #f98a4b, var(--primary)); border-color: transparent; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 6px 16px rgba(242, 106, 27, .30); }
.btn.primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.nav a { border-radius: 10px; position: relative; transition: background .12s, color .12s, padding .12s; }
.nav a.on::before { content: ""; position: absolute; left: -6px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--primary); }
.nav-find { position: relative; padding: 2px 4px 10px; }
.nav-find .ic { position: absolute; left: 15px; top: 11px; width: 15px; height: 15px; color: var(--soft); pointer-events: none; }
.nav-find input { width: 100%; height: 34px; padding-left: 32px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; }
.ver { font-size: 11px; color: var(--soft); padding: 0 14px 8px; letter-spacing: .02em; }
.tbl thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.tbl tbody tr { transition: background .1s; }
.badge { border-radius: 999px; }
.modal { border-radius: 18px; box-shadow: var(--sh2); animation: gx-pop .2s ease; }
.overlay { backdrop-filter: blur(4px); }
.drawer { box-shadow: -20px 0 60px rgba(16, 24, 40, .25); }
input, select, textarea { border-radius: 9px; transition: border-color .12s, box-shadow .12s, background .12s; }
.page-h h1 { letter-spacing: -.02em; }
.empty { padding: 40px 16px; }
.chip { transition: border-color .15s, transform .15s, box-shadow .15s; }
.chip:hover { border-color: var(--primary) !important; transform: translateY(-1px); box-shadow: var(--sh); }
.toast { border-radius: 12px; box-shadow: var(--sh2); }
.avatar-btn { background: linear-gradient(135deg, #f98a4b, var(--primary)); color: #fff; font-weight: 650; box-shadow: 0 2px 8px rgba(242, 106, 27, .35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--soft); background-clip: content-box; border: 2px solid transparent; }
.auth-side { background: radial-gradient(900px 420px at 0% 0%, rgba(242, 106, 27, .35), transparent 60%), radial-gradient(700px 400px at 100% 100%, rgba(29, 53, 87, .6), transparent 60%), #0b1220 !important; }
.auth-main { background: var(--bg); }
.auth-card { max-width: 420px; padding: 38px 34px 30px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--sh2); animation: gx-pop .3s ease; }
@media (max-width: 480px) { .auth-card { padding: 28px 22px 24px; } }
.cd-head, .cd-win { box-shadow: var(--sh2); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* phone fixes */
.g2 > *, .g3 > *, .grid > *, .stats > * { min-width: 0; }
.card-h { flex-wrap: wrap; }
.card-b { overflow-x: auto; }
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .range { flex-wrap: wrap; }
  .page-h { flex-wrap: wrap; }
  .bars { overflow-x: auto; }
  .tabs { max-width: 100%; }
  .filters { flex-wrap: wrap; }
  .table-wrap { max-width: 100%; overflow-x: auto; }
}
