/* نظام متابعة المهام — الأنماط */

:root {
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --border: #e1e6ed;
  --border-strong: #c9d1dc;
  --text: #17202e;
  --text-2: #556173;
  --text-3: #8792a3;
  --primary: #0b3a6b;
  --primary-hover: #0e4a87;
  --primary-ink: #ffffff;
  --accent: #1f6fd1;
  --accent-soft: #e7f0fc;
  --head-bg: #0a2c52;
  --head-ink: #eaf2fb;
  --row-alt: #f7f9fc;
  --row-hover: #edf3fb;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warning: #a86200;
  --warning-soft: #fdf2df;
  --success: #23794a;
  --success-soft: #e4f4ea;
  --focus: 0 0 0 3px rgba(31, 111, 209, .25);
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  color-scheme: light;
}

/* Chip colors: soft background, dark text, solid bar color */
.c-gray   { --c-bg: #eef0f3; --c-fg: #3b4452; --c-solid: #8b95a5; }
.c-blue   { --c-bg: #e3effc; --c-fg: #0c447c; --c-solid: #2f7fd6; }
.c-amber  { --c-bg: #fdf0d9; --c-fg: #7a4705; --c-solid: #e39a24; }
.c-green  { --c-bg: #e2f3e6; --c-fg: #1d5a32; --c-solid: #3c9a5f; }
.c-red    { --c-bg: #fbe4e4; --c-fg: #8a1f1f; --c-solid: #d94141; }
.c-purple { --c-bg: #ecebfd; --c-fg: #3c3489; --c-solid: #7f77dd; }
.c-teal   { --c-bg: #ddf3ee; --c-fg: #0b5243; --c-solid: #1d9e80; }
.c-pink   { --c-bg: #fbe7ef; --c-fg: #7a2444; --c-solid: #d4537e; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131a; --surface: #151c26; --surface-2: #1a2230; --surface-3: #202a39;
    --border: #263142; --border-strong: #354256;
    --text: #e6ebf2; --text-2: #a5b0c0; --text-3: #7a8698;
    --primary: #2f6fb8; --primary-hover: #3a7fcf; --accent: #5b9be6; --accent-soft: #1b2b42;
    --head-bg: #0f2744; --head-ink: #dfeaf7;
    --row-alt: #18202b; --row-hover: #1e2a3a;
    --danger: #f07167; --danger-soft: #3a1d1d; --warning: #f0b458; --warning-soft: #3a2a12;
    --success: #6fcf97; --success-soft: #14301f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .c-gray   { --c-bg: #2a323e; --c-fg: #d3d9e2; }
  :root:not([data-theme="light"]) .c-blue   { --c-bg: #13304f; --c-fg: #b9d7f6; }
  :root:not([data-theme="light"]) .c-amber  { --c-bg: #3b2a0e; --c-fg: #f6cd8a; }
  :root:not([data-theme="light"]) .c-green  { --c-bg: #15331f; --c-fg: #a6e0b8; }
  :root:not([data-theme="light"]) .c-red    { --c-bg: #3d1a1a; --c-fg: #f6b4b4; }
  :root:not([data-theme="light"]) .c-purple { --c-bg: #26224f; --c-fg: #cecbf6; }
  :root:not([data-theme="light"]) .c-teal   { --c-bg: #103a31; --c-fg: #9fe1cb; }
  :root:not([data-theme="light"]) .c-pink   { --c-bg: #3d1a29; --c-fg: #f4c0d1; }
}
:root[data-theme="dark"] {
  --bg: #0e131a; --surface: #151c26; --surface-2: #1a2230; --surface-3: #202a39;
  --border: #263142; --border-strong: #354256;
  --text: #e6ebf2; --text-2: #a5b0c0; --text-3: #7a8698;
  --primary: #2f6fb8; --primary-hover: #3a7fcf; --accent: #5b9be6; --accent-soft: #1b2b42;
  --head-bg: #0f2744; --head-ink: #dfeaf7;
  --row-alt: #18202b; --row-hover: #1e2a3a;
  --danger: #f07167; --danger-soft: #3a1d1d; --warning: #f0b458; --warning-soft: #3a2a12;
  --success: #6fcf97; --success-soft: #14301f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
:root[data-theme="dark"] .c-gray   { --c-bg: #2a323e; --c-fg: #d3d9e2; }
:root[data-theme="dark"] .c-blue   { --c-bg: #13304f; --c-fg: #b9d7f6; }
:root[data-theme="dark"] .c-amber  { --c-bg: #3b2a0e; --c-fg: #f6cd8a; }
:root[data-theme="dark"] .c-green  { --c-bg: #15331f; --c-fg: #a6e0b8; }
:root[data-theme="dark"] .c-red    { --c-bg: #3d1a1a; --c-fg: #f6b4b4; }
:root[data-theme="dark"] .c-purple { --c-bg: #26224f; --c-fg: #cecbf6; }
:root[data-theme="dark"] .c-teal   { --c-bg: #103a31; --c-fg: #9fe1cb; }
:root[data-theme="dark"] .c-pink   { --c-bg: #3d1a29; --c-fg: #f4c0d1; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
/* Form controls do not inherit the page font by default; force it so Arabic letters join correctly. */
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.35; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.ico { width: 18px; height: 18px; flex: none; display: inline-block; vertical-align: middle; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.boot { padding: 80px 16px; text-align: center; color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-3); }
.btn:focus-visible, .icon-btn:focus-visible, .tab:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; height: 44px; font-size: 15px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }

input[type=text], input[type=search], input[type=password], input[type=number], input[type=date], input:not([type]), select, textarea {
  width: 100%; min-height: 38px; padding: 7px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--focus); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text-2); }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-left: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238792a3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 10px center; background-size: 16px;
}
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.hint { font-size: 12.5px; color: var(--text-3); }
.err-text { font-size: 13px; color: var(--danger); }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px;
  background: var(--c-bg, var(--surface-3)); color: var(--c-fg, var(--text-2));
  font-size: 12.5px; font-weight: 500; white-space: nowrap; line-height: 1.7;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c-solid, var(--text-3)); display: inline-block; flex: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px; padding: 10px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; flex: none;
}
.brand-mark .ico, .brand-mark svg { width: 21px; height: 21px; }
.brand-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.tabs { display: flex; gap: 4px; margin-inline-start: 12px; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text-2);
  font-weight: 500; font-size: 14px; cursor: pointer;
}
.tab:hover { background: var(--surface-3); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }
.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--text);
}
.user-btn:hover { background: var(--surface-3); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex: none;
}
.user-name { display: flex; flex-direction: column; text-align: start; font-size: 13.5px; font-weight: 500; line-height: 1.3; }
.user-name small { font-size: 11.5px; color: var(--text-3); font-weight: 400; }
.dropdown {
  position: absolute; top: calc(100% + 6px); inset-inline-end: 0; min-width: 200px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 6px;
}
.dropdown button, .dropdown a {
  display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border: 0; border-radius: 6px;
  background: transparent; cursor: pointer; color: var(--text); font-size: 14px; text-align: start;
}
.dropdown button:hover, .dropdown a:hover { background: var(--surface-3); text-decoration: none; }
.dropdown form { margin: 0; }

.container { max-width: 1480px; margin: 0 auto; padding: 20px 24px 60px; }

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(116px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi {
  position: relative; text-align: start; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s; color: var(--text);
}
.kpi:hover { border-color: var(--border-strong); }
.kpi.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--text-3); }
.kpi.static { cursor: default; }
.kpi .kpi-value.c-color { color: var(--c-solid); }

/* ---------- Dashboard ---------- */
.dash-wrap { margin-bottom: 16px; }
.dash-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dash-head h2 { font-size: 16px; }
.dash-head .muted { font-size: 12.5px; }
.dash-head .btn { margin-inline-start: auto; }
.dash { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.panel h3 { font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.panel h3 .muted { font-weight: 400; font-size: 12px; margin-inline-start: auto; }
.emp-rows { display: flex; flex-direction: column; gap: 7px; max-height: 330px; overflow-y: auto; padding-inline-end: 4px; }
.emp-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 70px; gap: 10px; align-items: center; font-size: 13px; }
.emp-row .name {
  border: 0; background: transparent; padding: 0; color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer;
  text-align: start; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.emp-row .name:hover { color: var(--accent); text-decoration: underline; }
.emp-row.active .name { color: var(--accent); }
.stack { display: flex; height: 12px; border-radius: 4px; overflow: hidden; background: var(--surface-3); }
.stack i { display: block; height: 100%; background: var(--c-solid); }
.stack i + i { border-inline-start: 1px solid var(--surface); }
.emp-row .meta { font-size: 12px; color: var(--text-2); text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 10px; font-size: 12px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: minmax(70px, auto) minmax(0, 1fr) 58px; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.bar-row:hover .bar-label { color: var(--accent); }
.bar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 10px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--c-solid); border-radius: 4px; }
.bar-row .meta { font-size: 12px; color: var(--text-2); text-align: end; font-variant-numeric: tabular-nums; }
.alerts { display: flex; flex-direction: column; gap: 6px; }
.alert-item {
  display: flex; align-items: flex-start; gap: 8px; padding: 8px 10px; border-radius: var(--radius-sm);
  border: 0; background: var(--surface-2); text-align: start; cursor: pointer; font-size: 13px; color: var(--text); width: 100%;
}
.alert-item:hover { background: var(--surface-3); }
.alert-item.danger .ico { color: var(--danger); }
.alert-item.warn .ico { color: var(--warning); }
.alert-item.info .ico { color: var(--accent); }
.alert-item b { font-variant-numeric: tabular-nums; }
.alert-item small { display: block; color: var(--text-3); font-size: 12px; }
.empty-note { font-size: 13px; color: var(--text-3); padding: 6px 0; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0;
  padding: 12px; border-bottom: 0;
}
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1 1 640px; }
.filters select { width: auto; min-width: 130px; max-width: 190px; height: 36px; min-height: 36px; font-size: 13.5px; }
.filters select.on { border-color: var(--accent); background-color: var(--accent-soft); color: var(--accent); font-weight: 500; }
.search { position: relative; flex: 1 1 220px; min-width: 180px; max-width: 340px; }
.search .ico { position: absolute; top: 50%; right: 10px; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search input { padding-right: 36px; height: 36px; min-height: 36px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.result-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border); border-top: 1px solid var(--border); border-bottom: 0;
}
.result-bar .fchip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 4px 1px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 500;
}
.result-bar .fchip button { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 2px; display: inline-flex; }
.result-bar .fchip .ico { width: 14px; height: 14px; }
.result-bar .tip { margin-inline-start: auto; color: var(--text-3); font-size: 12px; }

/* ---------- Sheet table ---------- */
.table-wrap {
  overflow: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow);
  max-height: calc(100vh - 150px); min-height: 200px;
}
table.sheet { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; min-width: 1080px; }
.sheet th {
  position: sticky; top: 0; z-index: 2; background: var(--head-bg); color: var(--head-ink);
  font-weight: 600; text-align: start; padding: 10px 10px; font-size: 13.5px; white-space: nowrap;
  user-select: none; cursor: pointer;
}
.sheet th:hover { background: color-mix(in srgb, var(--head-bg) 85%, #fff); }
.sheet th .sort { opacity: .55; font-size: 11px; margin-inline-start: 4px; }
.sheet th.sorted .sort { opacity: 1; }
.sheet th.c-actions { cursor: default; }
.sheet td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.sheet tbody tr:nth-child(even) td { background: var(--row-alt); }
.sheet tbody tr:hover td { background: var(--row-hover); }
.sheet tbody tr.flash td { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); } }
.sheet .c-num { width: 44px; color: var(--text-3); font-size: 12.5px; text-align: center; font-variant-numeric: tabular-nums; }
.sheet .c-title { min-width: 260px; max-width: 420px; }
.sheet .c-title .t-text { font-weight: 500; }
.sheet .c-title .t-note { display: block; font-size: 12px; color: var(--warning); }
.sheet .c-emp { min-width: 140px; }
.sheet .c-progress { min-width: 220px; }
.sheet .c-date { white-space: nowrap; min-width: 110px; }
.sheet .c-updated { white-space: nowrap; font-size: 12.5px; color: var(--text-2); }
.sheet .c-actions { width: 44px; text-align: center; }

/* Editable cells: look like plain text until hovered */
.cell-edit {
  display: block; width: 100%; min-height: 30px; padding: 4px 6px; margin: -4px -6px; border-radius: 6px;
  border: 1px dashed transparent; cursor: text; text-align: start; background: transparent; color: inherit;
}
.cell-edit.pick { cursor: pointer; }
.can-edit .cell-edit:hover { border-color: var(--border-strong); background: var(--surface); }
.cell-edit .placeholder { color: var(--text-3); font-size: 13px; }
.cell-input { width: 100%; min-height: 32px; padding: 4px 8px; font-size: 14px; }
.emp-names { display: flex; flex-wrap: wrap; gap: 4px; }
.emp-tag { font-size: 13px; background: var(--surface-3); color: var(--text); padding: 1px 8px; border-radius: 6px; white-space: nowrap; }

.status-select {
  width: auto; min-width: 112px; min-height: 28px; height: 28px; padding: 0 10px 0 26px; border-radius: 999px; border: 1px solid transparent;
  background-color: var(--c-bg, var(--surface-3)); color: var(--c-fg, var(--text-2)); font-size: 12.5px; font-weight: 600;
  background-position: left 7px center; background-size: 13px;
}
.status-select:hover { border-color: var(--c-solid, var(--border-strong)); }
.status-select option { background: var(--surface); color: var(--text); }

.prog { display: flex; flex-direction: column; gap: 3px; }
.prog .step { font-size: 13.5px; line-height: 1.45; }
.prog .step.empty { color: var(--text-3); font-size: 13px; }
.prog-line { display: flex; align-items: center; gap: 8px; }
.pbar { flex: 1; height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.pbar i { display: block; height: 100%; border-radius: 4px; background: var(--accent); transition: width .3s; }
.pbar.done i { background: var(--success); }
.pbar.late i { background: var(--danger); }
.prog .pct { font-size: 12px; color: var(--text-2); min-width: 34px; text-align: end; font-variant-numeric: tabular-nums; }
.late-tag { display: block; font-size: 12px; color: var(--danger); font-weight: 500; }
.stale-tag { color: var(--warning); display: inline-flex; align-items: center; gap: 3px; }
.stale-tag .ico { width: 14px; height: 14px; }

/* Quick add row */
.quick-add td { background: var(--surface-2) !important; border-bottom: 2px solid var(--border-strong); padding: 8px 10px; }
.quick-add input, .quick-add select { min-height: 34px; height: 34px; font-size: 13.5px; }
.quick-add select { min-width: 100px; }
.quick-add input[type=date] { min-width: 130px; }
.quick-add .qa-plus { color: var(--accent); }

.empty-state { text-align: center; padding: 50px 16px; color: var(--text-2); }
.empty-state h3 { font-size: 17px; color: var(--text); margin-bottom: 6px; }
.empty-state .btn { margin: 14px 4px 0; }

/* ---------- Popover editors ---------- */
.popover {
  position: absolute; z-index: 60; width: 300px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 12px;
}
.popover h4 { margin: 0 0 8px; font-size: 13.5px; font-weight: 600; }
.pop-list { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.pop-list label { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.pop-list label:hover { background: var(--surface-3); }
.pop-row { display: flex; gap: 6px; margin-top: 8px; }
.pop-row input { min-height: 34px; height: 34px; }
.pop-foot { display: flex; gap: 6px; justify-content: flex-start; margin-top: 10px; }
.quick-pcts { display: flex; gap: 4px; margin-top: 6px; }
.quick-pcts button {
  flex: 1; height: 28px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); cursor: pointer;
  font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums;
}
.quick-pcts button:hover, .quick-pcts button.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 18, 30, .5);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 560px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); display: flex; flex-direction: column;
}
.modal.lg { max-width: 860px; }
.modal.xl { max-width: 1040px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 17px; flex: 1; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.modal-foot .spacer { flex: 1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.section-title { font-size: 13px; font-weight: 600; color: var(--accent); padding-top: 6px; border-top: 1px dashed var(--border); margin-top: 2px; }
.emp-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.emp-picker button {
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}
.emp-picker button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 500; }
.emp-picker button:disabled { cursor: default; }
.inline-add { display: flex; gap: 6px; margin-top: 8px; max-width: 360px; }
.inline-add input { min-height: 34px; height: 34px; }
.range-row { display: flex; align-items: center; gap: 10px; }
.range-row b { min-width: 42px; text-align: end; font-variant-numeric: tabular-nums; }

.history { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 14px; }
.history h3 { font-size: 14px; display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
.timeline li { position: relative; padding: 0 22px 14px 0; font-size: 13.5px; }
.timeline li::before { content: ''; position: absolute; right: 5px; top: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ''; position: absolute; right: 9px; top: 18px; bottom: 0; width: 1px; background: var(--border-strong); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: 12px; color: var(--text-3); }
.timeline .what { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.timeline .note { margin-top: 3px; color: var(--text-2); white-space: pre-wrap; }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card.span-2 { grid-column: 1 / -1; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 16px; flex: 1; }
.list-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.list-table th { text-align: start; font-size: 12.5px; color: var(--text-2); font-weight: 500; padding: 6px 6px; border-bottom: 1px solid var(--border); }
.list-table td { padding: 6px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.list-table input, .list-table select { min-height: 34px; height: 34px; font-size: 13.5px; }
.list-table .w-color { width: 120px; }
.list-table .w-small { width: 70px; text-align: center; }
.list-table .w-actions { width: 104px; white-space: nowrap; text-align: end; }
.list-table tr.add-row td { background: var(--surface-2); }
.list-table .count { color: var(--text-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.general-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto; gap: 12px; align-items: end; }

/* ---------- Import / export ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 34px 16px; cursor: pointer;
  background: var(--surface-2); color: var(--text-2); transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .ico { width: 34px; height: 34px; color: var(--accent); }
.dropzone b { color: var(--text); font-size: 15px; }
.map-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.map-table th { text-align: start; font-size: 12.5px; color: var(--text-2); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--border-strong); }
.map-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.map-table .src { font-weight: 600; }
.map-table .arrow { color: var(--text-3); width: 24px; }
.map-table select { min-height: 34px; height: 34px; font-size: 13.5px; }
.map-table select.matched { border-color: color-mix(in srgb, var(--success) 55%, var(--border)); }
.map-table .sample { color: var(--text-2); font-size: 12.5px; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-table tr.ignored .src, .map-table tr.ignored .sample { opacity: .5; }
.opt-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 14px 0; }
.radio-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.radio-card { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 10px; cursor: pointer; font-size: 13.5px; }
.radio-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.radio-card input { margin-top: 4px; accent-color: var(--accent); }
.radio-card small { display: block; color: var(--text-2); font-size: 12px; }
.summary-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13.5px; display: flex; flex-direction: column; gap: 4px; }
.summary-box .warn { color: var(--warning); }
.preview-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.preview-table th { background: var(--surface-3); padding: 5px 7px; text-align: start; font-weight: 600; white-space: nowrap; }
.preview-table td { padding: 5px 7px; border-bottom: 1px solid var(--border); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cols-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.cols-list .col-item { display: flex; align-items: center; gap: 8px; }
.cols-list .col-item input[type=text] { min-height: 32px; height: 32px; font-size: 13px; }
.cols-list .col-item.off input[type=text] { opacity: .45; }
.label-sm { font-size: 13px; font-weight: 600; margin: 14px 0 8px; display: block; }

/* ---------- Toast ---------- */
#toasts { position: fixed; bottom: 20px; left: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 220px; max-width: 380px; padding: 10px 14px; border-radius: var(--radius-sm); background: #17202e; color: #fff;
  box-shadow: var(--shadow-lg); font-size: 14px; transition: opacity .4s, transform .4s;
}
.toast.ok { background: #1f6b43; }
.toast.err { background: #a8322a; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---------- Login and install ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 28px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.install-card { max-width: 560px; }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand .brand-mark { margin: 0 auto 10px; width: 48px; height: 48px; border-radius: 12px; }
.auth-brand h1 { font-size: 20px; }
.auth-brand p { margin: 4px 0 0; color: var(--text-2); font-size: 14px; }
.alert { padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 12px; }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.alert-ok { background: var(--success-soft); color: var(--success); }
.form-section { font-size: 15px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.checks { list-style: none; margin: 0 0 14px; padding: 0; font-size: 13.5px; display: grid; gap: 3px; }
.checks .ok { color: var(--success); }
.checks .bad { color: var(--danger); }
.steps-list { padding-inline-start: 20px; line-height: 2; }
textarea.code { font-family: Consolas, monospace; font-size: 12.5px; }

/* ---------- Small screens ---------- */
@media (max-width: 1100px) {
  .dash { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .dash .panel:first-child { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .topbar { padding: 8px 16px; flex-wrap: wrap; gap: 8px; }
  .brand-sub, .user-name { display: none; }
  .tabs { order: 3; width: 100%; margin: 0; }
  .container { padding: 14px 16px 40px; }
  .dash, .settings-grid { grid-template-columns: minmax(0, 1fr); }
  .emp-row { grid-template-columns: 96px minmax(0, 1fr) 56px; }
  .filters select { flex: 1 1 140px; max-width: none; }
  .search { max-width: none; }
  .form-grid, .cols-list, .radio-cards, .general-form { grid-template-columns: minmax(0, 1fr); }
  .modal-backdrop { padding: 12px 8px; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 8px 10px; }
  .kpi-label { font-size: 12px; }
  .kpi-value { font-size: 20px; }
  .kpi-sub { display: none; }
  .dash-head .muted { display: none; }
  #toasts { left: 12px; right: 12px; }
}
