/* ==========================================================================
   IshonchCall Work — Formal Enterprise & Spreadsheet Design System
   Clean Slate Neutrals + Executive Emerald Accent | Inter + JetBrains Mono
   Zero fluff, sharp geometry, strictly AI-free.
   ========================================================================== */

:root,
[data-theme="light"] {
  --bg: #eef5f0;
  --bg-soft: #e2efe6;
  --surface: #ffffff;
  --sidebar: #ffffff;
  --text: #102418;
  --ink: #0b1c12;
  --muted: #526e5c;
  --faint: #849e8d;
  --edge: #d4e5d9;
  --border: #d4e5d9;
  --border-strong: #b8d3c1;
  --soft: #e2efe6;

  --accent: #00a93b;
  --accent-hover: #008f32;
  --accent-soft: #e6f9ed;
  --accent-border: #9ee6b8;
  --accent-text: #ffffff;

  --btn: #00a93b;
  --btn-hover: #008f32;
  --btn-text: #ffffff;

  --ok: #00a93b;
  --ok-bg: #e6f9ed;
  --ok-border: #a3e8bc;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --bad: #be123c;
  --bad-bg: #fff1f2;
  --bad-border: #fecdd3;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 8px;
  --r-lg: 12px;
  --shadow: 0 1px 3px rgba(11, 28, 18, 0.05), 0 4px 14px rgba(11, 28, 18, 0.03);
  --shadow-lg: 0 14px 36px rgba(11, 28, 18, 0.14);
  --sticky-shadow: -6px 0 12px -6px rgba(11, 28, 18, 0.12);
  --focus-ring: 0 0 0 2px #ffffff, 0 0 0 4px rgba(0, 169, 59, 0.28);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b110d;
  --bg-soft: #121d16;
  --surface: #111b15;
  --sidebar: #0f1812;
  --text: #dce8e0;
  --ink: #f2f9f4;
  --muted: #8aa493;
  --faint: #5c7565;
  --edge: #1d2e23;
  --border: #1d2e23;
  --border-strong: #2b4434;
  --soft: #16241b;

  --accent: #00c445;
  --accent-hover: #00a93b;
  --accent-soft: rgba(0, 169, 59, 0.16);
  --accent-border: rgba(0, 196, 69, 0.36);
  --accent-text: #ffffff;

  --btn: #00a93b;
  --btn-hover: #008f32;
  --btn-text: #ffffff;

  --ok: #00c445;
  --ok-bg: rgba(0, 169, 59, 0.16);
  --ok-border: rgba(0, 196, 69, 0.34);
  --warn: #fbbf24;
  --warn-bg: rgba(251, 191, 36, 0.12);
  --warn-border: rgba(251, 191, 36, 0.28);
  --bad: #fb7185;
  --bad-bg: rgba(251, 113, 133, 0.12);
  --bad-border: rgba(251, 113, 133, 0.28);
  --info: #60a5fa;
  --info-bg: rgba(96, 165, 250, 0.12);
  --info-border: rgba(96, 165, 250, 0.28);

  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.58);
  --sticky-shadow: -8px 0 16px -8px rgba(0, 0, 0, 0.58);
  --focus-ring: 0 0 0 2px #111b15, 0 0 0 4px rgba(0, 196, 69, 0.35);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   BRAND
   ========================================================================== */
.brand {
  display: inline-flex;
  align-items: center;
  flex: none;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.025em;
}

.brand b {
  color: var(--accent);
  font-weight: 700;
}

.brand-sep {
  color: var(--border-strong);
  margin: 0 8px;
}

.brand-ctx {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
}

/* ==========================================================================
   ADMIN SHELL — FORMAL LEFT SIDEBAR
   ========================================================================== */
.admin-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  padding: 14px;
  gap: 14px;
  background: transparent;
}

.admin-shell::before,
.ws-shell::before {
  content: "";
  position: fixed;
  inset: -16px;
  z-index: -2;
  background: url("/static/login-bg.jpg?v=26") center / cover no-repeat;
  filter: blur(8px) saturate(1.06);
  transform: scale(1.03);
  pointer-events: none;
}

.admin-shell::after,
.ws-shell::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: rgba(235, 245, 238, 0.34);
  pointer-events: none;
}

[data-theme="dark"] .admin-shell::after,
[data-theme="dark"] .ws-shell::after {
  background: rgba(7, 13, 10, 0.68);
}

.admin-sidebar {
  width: 232px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(11, 28, 18, 0.12);
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 14px;
  height: calc(100vh - 28px);
  z-index: 45;
}

[data-theme="dark"] .admin-sidebar,
[data-theme="dark"] .ws-sidebar {
  background: rgba(15, 24, 18, 0.84);
  border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-head {
  padding: 2px 4px 6px;
  border-bottom: 1px solid var(--edge);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-nav {
  padding: 2px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}

.nav-tab {
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 0 11px;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.nav-tab svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.12s;
}

.nav-tab:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.nav-tab:hover svg {
  color: var(--accent);
}

.nav-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 169, 59, 0.25);
}

.nav-tab.active svg {
  color: var(--accent-text);
}

.nav-tab-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-count {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
}

.nav-tab.active .tab-count {
  background: rgba(255, 255, 255, 0.22);
  color: var(--accent-text);
}

.sidebar-foot {
  padding-top: 10px;
  border-top: 1px solid var(--edge);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-foot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.admin-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(11, 28, 18, 0.12);
  overflow: hidden;
}

[data-theme="dark"] .admin-workspace {
  background: rgba(17, 27, 21, 0.74);
  border-color: rgba(255, 255, 255, 0.1);
}

.admin-topbar {
  min-height: 54px;
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--edge);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

[data-theme="dark"] .admin-topbar {
  background: rgba(17, 27, 21, 0.84);
}

.admin-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-page-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
}

.admin-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.mobile-menu-btn {
  display: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  z-index: 44;
}

.admin-main {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px 48px;
  flex: 1;
}

.tab-panel {
  display: none !important;
}

.tab-panel.active {
  display: flex !important;
  flex-direction: column;
  gap: 16px;
}

.stack-md {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

/* ==========================================================================
   OPERATOR WORKSPACE — LEFT SIDEBAR + FRAMED EXCEL SPREADSHEET
   ========================================================================== */
.ws-shell {
  position: relative;
  z-index: 1;
  height: 100vh;
  display: flex;
  flex-direction: row;
  padding: 14px;
  gap: 14px;
  overflow: hidden;
  background: transparent;
}

.ws-sidebar {
  width: 232px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(11, 28, 18, 0.12);
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 45;
}

.ws-sidebar-top {
  padding: 2px 4px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ws-dataset-card {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ws-dataset-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.ws-dataset-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ws-nav-item {
  width: 100%;
  min-height: 38px;
  padding: 0 11px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.ws-nav-item:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.ws-nav-left {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.ws-nav-left svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.12s;
}

.ws-nav-item:hover .ws-nav-left svg {
  color: var(--accent);
}

.ws-sidebar-status {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ws-status-badge {
  width: 100%;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  justify-content: flex-start;
  font-size: 12.5px;
  font-weight: 600;
}

.ws-user-chip {
  width: 100%;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--edge);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ws-user-chip svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--muted);
}

.ws-user-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-sidebar-foot {
  padding-top: 10px;
  border-top: 1px solid var(--edge);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ws-theme-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.ws-logout-btn {
  flex: 1;
  min-height: 34px;
  border-radius: 9px;
  justify-content: center;
  font-weight: 600;
}

.ws-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(11, 28, 18, 0.12);
  overflow: hidden;
}

[data-theme="dark"] .ws-main {
  background: rgba(17, 27, 21, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
}

.ws-toolbar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--edge);
  background: rgba(255, 255, 255, 0.84);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

[data-theme="dark"] .ws-toolbar {
  background: rgba(17, 27, 21, 0.86);
}

.ws-progress-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ws-meter-wrap {
  width: 96px;
}

.ws-table-area {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: transparent;
}

.ws-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--edge);
  background: rgba(238, 245, 240, 0.84);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

[data-theme="dark"] .ws-footer {
  background: rgba(15, 24, 18, 0.86);
}

.page-nav {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 31px;
  height: 29px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.page-btn:hover:not(:disabled):not(.is-active) {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.page-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 1px 2px rgba(13, 122, 74, 0.22);
  cursor: default;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-btn.page-arrow {
  letter-spacing: -0.06em;
  font-weight: 700;
  color: var(--muted);
}

.page-ellipsis {
  min-width: 24px;
  height: 29px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  user-select: none;
}

/* ==========================================================================
   KPI STRIP & EXECUTIVE CARDS
   ========================================================================== */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.kpi-cell {
  padding: 14px 18px;
  border-right: 1px solid var(--edge);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  transition: background 0.12s;
}

.kpi-cell:last-child {
  border-right: none;
}

.kpi-cell.tile-clickable {
  cursor: pointer;
}

.kpi-cell.tile-clickable:hover {
  background: var(--bg);
}

.tile-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.kpi-cell b {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.025em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.kpi-cell b.accent,
.kpi-cell b.ok {
  color: var(--accent);
}

.tile-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.tile-sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-body {
  padding: 16px 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--edge);
}

.card-header-plain {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.card-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 6px;
  font-variant-numeric: tabular-nums;
}

.card-footer {
  padding: 10px 18px;
  border-top: 1px solid var(--edge);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.meter {
  height: 5px;
  border-radius: 3px;
  background: var(--bg-soft);
  overflow: hidden;
}

.meter > div {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.25s ease;
}

.mini-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 135px;
}

.mini-progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.mini-progress-label strong {
  color: var(--ink);
  font-weight: 600;
}

/* ==========================================================================
   ANALYTICS CHARTS (Clean Executive Bar Charts — Zero Fluff)
   ========================================================================== */
.analytics-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 165px;
  padding-top: 18px;
}

.bar-col {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
}

.bar-val {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.bar-track {
  width: 100%;
  max-width: 30px;
  flex: 1;
  background: var(--bg-soft);
  border-radius: 4px;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

.bar-fill {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
  transition: height 0.25s ease;
}

.bar-fill.muted-bar {
  background: var(--btn);
  opacity: 0.72;
}

.bar-lbl {
  font-size: 10.5px;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
}

.dist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.dist-col-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dist-col-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
}

.dist-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dist-item-head {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text);
}

.dist-item-head span:last-child {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 13px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--btn);
  color: var(--btn-text);
  border-color: var(--btn);
}

.btn-primary:hover:not(:disabled) {
  background: var(--btn-hover);
  border-color: var(--btn-hover);
}

.btn-default {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--border-strong);
}

.btn-default:hover:not(:disabled) {
  background: var(--bg-soft);
}

.btn-soft-green {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}

.btn-soft-green:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-danger {
  background: var(--surface);
  color: var(--bad);
  border-color: var(--bad-border);
}

.btn-danger:hover:not(:disabled) {
  background: var(--bad-bg);
}

.btn-sm {
  min-height: 29px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-wide {
  width: 100%;
  min-height: 38px;
  font-size: 13.5px;
  font-weight: 600;
}

.theme-toggle {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.theme-toggle svg {
  width: 14px;
  height: 14px;
}

[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ==========================================================================
   FORMS & INPUTS (Crisp bordered executive inputs)
   ========================================================================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.input,
.select {
  width: 100%;
  min-height: 35px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.input::placeholder {
  color: var(--faint);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-wrap .input {
  padding-right: 78px;
}

.pw-toggle {
  position: absolute;
  right: 5px;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  padding: 4px 7px;
  border-radius: 4px;
  cursor: pointer;
}

.pw-toggle:hover {
  color: var(--ink);
  background: var(--bg-soft);
}

.form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-row > .form-group {
  flex: 1;
  min-width: 150px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 230px;
  max-width: 100%;
}

.search-icon {
  position: absolute;
  left: 9px;
  width: 14px;
  height: 14px;
  color: var(--faint);
  pointer-events: none;
}

.search-box .input {
  min-height: 32px;
  height: 32px;
  padding: 0 26px 0 30px;
  font-size: 13px;
}

.search-clear {
  position: absolute;
  right: 4px;
  width: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 4px;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  font-size: 14px;
}

.search-clear:hover {
  background: var(--bg-soft);
  color: var(--ink);
}

.filter-group,
.date-presets {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--edge);
}

.filter-btn,
.date-preset-btn {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 11px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.filter-btn:hover,
.date-preset-btn:hover {
  color: var(--ink);
}

.filter-btn.active,
.date-preset-btn.active {
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(13, 122, 74, 0.2);
}

.save-status-pill {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.save-status-pill:empty {
  display: none;
}

.save-status-pill.saving {
  color: var(--warn);
}

.save-status-pill.saved {
  color: var(--ok);
}

/* Option Builder & Upload Box */
.option-builder {
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.option-builder-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
}

.option-presets {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.preset-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--muted);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
}

.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.option-input-row {
  display: flex;
  gap: 6px;
}

.option-input-row .input {
  min-height: 31px;
  padding: 4px 9px;
  font-size: 12.5px;
}

.option-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.option-empty-hint {
  font-size: 11.5px;
  color: var(--muted);
}

.upload-box {
  position: relative;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: 24px 16px;
  text-align: center;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}

.upload-box:hover,
.upload-box.drag-over,
.upload-box.loaded {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-box.loaded {
  border-style: solid;
}

.upload-box-title {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.upload-box-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.upload-box-hint:empty {
  display: none;
}

.upload-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ==========================================================================
   FORMAL STATUS BADGES & AVATARS (Crisp 5px tags — not candy pills)
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.45;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.pulse-dot {
  animation: pulseDot 2s ease-in-out infinite;
}

.badge-green {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--ok-border);
}

.badge-blue {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info-border);
}

.badge-amber {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn-border);
}

.badge-red {
  background: var(--bad-bg);
  color: var(--bad);
  border-color: var(--bad-border);
}

.badge-gray {
  background: var(--bg-soft);
  color: var(--muted);
  border-color: var(--edge);
}

.avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--edge);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 9px;
}

/* ==========================================================================
   TABLES (Crisp corporate data grid)
   ========================================================================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--edge);
  white-space: nowrap;
}

.ws-table-area .data-table thead th,
.ws-table-area .data-table tbody td {
  border-right: 1px solid var(--edge);
}

.ws-table-area .data-table thead th:last-child,
.ws-table-area .data-table tbody td:last-child {
  border-right: none;
}

.data-table thead th.col-editable-hdr {
  color: var(--accent);
  background: var(--accent-soft);
}

.data-table tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--edge);
  vertical-align: middle;
  background: var(--surface);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--bg);
}

.data-table tbody tr.row-active td {
  background: var(--accent-soft);
}

.data-table tbody tr.row-active td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

.data-table tbody tr.row-completed td {
  background: color-mix(in srgb, var(--ok-bg) 55%, var(--surface));
}

.data-table tbody tr.row-locked td {
  background: var(--warn-bg);
}

.data-table tbody tr.row-active-dataset td {
  background: color-mix(in srgb, var(--accent-soft) 50%, var(--surface));
}

.data-table th.col-sticky-right {
  position: sticky;
  right: 0;
  z-index: 8;
  box-shadow: var(--sticky-shadow);
  border-left: 1px solid var(--edge);
}

.data-table td.col-sticky-right {
  position: sticky;
  right: 0;
  z-index: 4;
  box-shadow: var(--sticky-shadow);
  border-left: 1px solid var(--edge);
  white-space: nowrap;
}

.cell-base {
  color: var(--text);
  font-size: 13px;
  min-width: 76px;
  max-width: 240px;
  word-break: normal;
  overflow-wrap: break-word;
  line-height: 1.4;
}

.cell-input {
  width: 100%;
  min-width: 165px;
  height: 33px;
  padding: 5px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  transition: border-color 0.1s, box-shadow 0.1s, background 0.1s;
}

.cell-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.cell-input.is-dirty {
  border-color: var(--warn);
}

.cell-input.is-saved {
  border-color: var(--ok);
  background: var(--ok-bg);
}

.save-hint {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
  min-height: 13px;
}

.save-hint.saved {
  color: var(--ok);
}

.lock-banner {
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--warn);
  font-weight: 600;
  white-space: nowrap;
}

/* ==========================================================================
   LIVE MONITOR CARDS
   ========================================================================== */
.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.live-card {
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  padding: 13px 14px;
  transition: border-color 0.15s, background 0.2s;
}

.live-card.is-typing {
  border-color: var(--accent);
}

.live-card.flash-highlight {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.live-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}

.live-user-identity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.live-user-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-user-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 7px;
}

.live-preview-box {
  background: var(--bg);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 8px 10px;
  min-height: 40px;
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.live-preview-box.is-empty {
  color: var(--faint);
  font-size: 12px;
}

.live-preview-box.highlight-text {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.live-card-footer {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.live-link-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
}

.live-link-btn:hover {
  background: var(--accent-soft);
}

/* ==========================================================================
   CHIPS & COLUMN PICKER
   ========================================================================== */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
}

.chip-remove {
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-weight: 700;
  padding: 0 2px;
  line-height: 1;
}

.col-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.col-picker-item {
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: background 0.12s, border-color 0.12s;
}

.col-picker-item.is-editable {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.col-picker-item.is-ignored {
  opacity: 0.55;
  background: var(--bg);
}

.col-picker-name {
  font-weight: 700;
  font-size: 12.5px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-picker-item.is-editable .col-picker-name {
  color: var(--accent);
}

.col-role-group {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 4px;
}

.col-role-btn {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.col-role-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.col-role-btn.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
}

.col-picker-item.is-editable .col-role-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.admin-step-box {
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--edge);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.step-hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.simple-details {
  border: 1px solid var(--edge);
  border-radius: 9px;
  background: var(--bg);
  padding: 9px 12px;
}

.simple-details > summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.simple-details > summary:hover {
  color: var(--ink);
}

.simple-details-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--edge);
}

/* ==========================================================================
   LOGIN PAGE (IshonchCall Editorial Background + Formal Card)
   ========================================================================== */
.auth-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg) url("/static/login-bg.jpg?v=23") center / cover no-repeat;
}

.auth-page::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.08) 0%, rgba(0, 0, 0, 0.24) 100%);
  pointer-events: none;
}

[data-theme="dark"] .auth-page::before {
  background: rgba(8, 12, 10, 0.62);
}

.auth-top-actions {
  position: fixed;
  top: 16px;
  right: 18px;
  z-index: 5;
}

.auth-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 28px 28px 24px;
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.auth-card h1 {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--ink);
}

/* ==========================================================================
   ALERTS, TOASTS, MODALS & DIFFS
   ========================================================================== */
.alert {
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
}

.alert-error {
  background: var(--bad-bg);
  color: var(--bad);
  border-color: var(--bad-border);
}

.alert-info {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-border);
}

.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 350px;
}

.toast {
  background: var(--ink);
  color: var(--surface);
  padding: 9px 13px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 12.5px;
  font-weight: 500;
}

.toast.toast-error {
  background: var(--bad);
  color: #ffffff;
}

.toast.toast-success {
  background: var(--ok);
  color: #ffffff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 90;
}

.modal-box {
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 20px 22px;
}

.modal-box.modal-wide {
  max-width: 1060px;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 13px;
}

.diff-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
}

.diff-old {
  background: var(--bad-bg);
  color: var(--bad);
  padding: 1px 6px;
  border-radius: 4px;
  text-decoration: line-through;
}

.diff-new {
  background: var(--ok-bg);
  color: var(--ok);
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* ==========================================================================
   PHONE COPY & CALL CELL (1-Click Copy + tel: Link)
   ========================================================================== */
.phone-cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 240px;
}

.phone-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 500;
  padding: 2px 6px;
  margin: -2px 0 -2px -6px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.phone-copy-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.phone-call-link {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--edge);
  background: var(--surface);
  color: var(--accent);
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.phone-call-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.phone-call-link svg {
  width: 13px;
  height: 13px;
}

/* ==========================================================================
   TOOLBAR POPOVERS (Column Filters & Excel-style Hide/Show Columns)
   ========================================================================== */
.popover-wrap {
  position: relative;
  display: inline-flex;
}

.popover-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  width: 270px;
  max-height: 380px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.popover-head {
  padding: 9px 12px;
  border-bottom: 1px solid var(--edge);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.popover-body {
  padding: 10px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.popover-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 4px;
}

.popover-check-row:hover {
  background: var(--bg-soft);
}

.popover-check-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
}

.popover-filter-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.popover-filter-row label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.popover-filter-row .select {
  min-height: 30px;
  padding: 3px 8px;
  font-size: 12.5px;
}

.pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.pill-count.is-alert {
  background: var(--bad);
  color: #ffffff;
}

.pill-count:empty,
.pill-count[data-count="0"] {
  display: none;
}

/* ==========================================================================
   CALLBACK DATE INPUT IN TABLE
   ========================================================================== */
.cell-date {
  width: 136px;
  height: 31px;
  padding: 3px 7px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.cell-date:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.cell-date.is-today {
  border-color: var(--warn);
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 600;
}

.cell-date.is-overdue {
  border-color: var(--bad);
  background: var(--bad-bg);
  color: var(--bad);
  font-weight: 600;
}

/* ==========================================================================
   SLIDE-OVER DRAWERS (Reminders & Operator <-> Admin Chat)
   ========================================================================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.36);
  z-index: 80;
  display: flex;
  justify-content: flex-end;
}

.side-drawer {
  width: 100%;
  max-width: 400px;
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--edge);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.drawer-head {
  height: 52px;
  padding: 0 16px;
  border-bottom: 1px solid var(--edge);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.drawer-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--edge);
  background: var(--bg);
  flex-shrink: 0;
}

.reminder-item {
  border: 1px solid var(--edge);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reminder-item.is-overdue {
  border-left-color: var(--bad);
  background: color-mix(in srgb, var(--bad-bg) 45%, var(--surface));
}

.reminder-item.is-today {
  border-left-color: var(--warn);
  background: color-mix(in srgb, var(--warn-bg) 50%, var(--surface));
}

.reminder-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.reminder-summary {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}

.reminder-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ==========================================================================
   MESSAGING / CHAT (Operator Drawer & Admin 2-Pane Tab)
   ========================================================================== */
.chat-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  border: 1px solid var(--edge);
  border-radius: var(--r-lg);
  background: var(--surface);
  height: calc(100vh - 120px);
  min-height: 460px;
  overflow: hidden;
}

.chat-threads {
  border-right: 1px solid var(--edge);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.chat-thread-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--edge);
  background: transparent;
  padding: 11px 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: inherit;
  transition: background 0.12s;
}

.chat-thread-item:hover {
  background: var(--bg-soft);
}

.chat-thread-item.active {
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--accent);
}

.chat-thread-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.chat-thread-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}

.online-dot.is-online {
  background: var(--ok);
}

.chat-thread-preview {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

.chat-pane-head {
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--edge);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
}

.chat-msg {
  max-width: 82%;
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.mine {
  align-self: flex-end;
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.chat-msg-meta {
  margin-top: 4px;
  font-size: 10.5px;
  opacity: 0.72;
  font-family: var(--mono);
  text-align: right;
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-form .input {
  flex: 1;
  min-height: 36px;
}

.export-col-filters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}

.export-col-filters:empty {
  display: none;
}

/* ==========================================================================
   EXCEL-STYLE SPREADSHEET GRID, AUTOFILTER, CONTEXT MENU & FREEZE PANES
   ========================================================================== */
.phone-tg-link {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--edge);
  background: var(--surface);
  color: #0284c7;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.phone-tg-link:hover {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}

.phone-tg-link svg {
  width: 13px;
  height: 13px;
}

.xl-pills-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.xl-pills-bar:empty {
  display: none;
}

.xl-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 8px;
  border-radius: 4px;
  border: 1px solid var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.xl-chip:hover {
  background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 18%);
}

.xl-chip.is-neutral {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--ink);
}

.xl-chip.is-neutral:hover {
  background: var(--bg-soft);
}

.xl-chip-x {
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
  opacity: 0.75;
}

/* Excel Sheet Table Appearance */
.ws-table-area.xl-sheet {
  background: transparent;
}

.xl-sheet .data-table tbody td:not(.xl-rownum-td):not(.xl-frozen):not(.col-sticky-right) {
  background: rgba(255, 255, 255, 0.8);
}

[data-theme="dark"] .xl-sheet .data-table tbody td:not(.xl-rownum-td):not(.xl-frozen):not(.col-sticky-right) {
  background: rgba(17, 27, 21, 0.8);
}

.xl-sheet .data-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
}

/* Row 1: Excel Column Letter Strip (A, B, C...) */
.xl-sheet .data-table thead tr.xl-letters-row th {
  position: sticky;
  top: 0;
  z-index: 12;
  height: 22px;
  padding: 0 6px;
  background: #f3f4f6;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
  text-transform: none;
  letter-spacing: 0;
  border-right: 1px solid #d1d5db;
  border-bottom: 1px solid #d1d5db;
  user-select: none;
}

[data-theme="dark"] .xl-sheet .data-table thead tr.xl-letters-row th {
  background: #141a22;
  border-right-color: #26303d;
  border-bottom-color: #26303d;
}

.xl-sheet .data-table thead tr.xl-letters-row th.xl-col-active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* Row 2: Excel Column Names + AutoFilter Dropdown Arrow */
.xl-sheet .data-table thead tr.xl-headers-row th {
  position: sticky;
  top: 22px;
  z-index: 11;
  height: 32px;
  padding: 0 26px 0 9px;
  background: #f8f9fa;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  border-right: 1px solid #d1d5db;
  border-bottom: 1.5px solid #cbd5e1;
  user-select: none;
  white-space: nowrap;
}

[data-theme="dark"] .xl-sheet .data-table thead tr.xl-headers-row th {
  background: #19212b;
  border-right-color: #26303d;
  border-bottom-color: #334155;
}

.xl-sheet .data-table thead tr.xl-headers-row th.col-editable-hdr {
  background: color-mix(in srgb, var(--accent-soft) 72%, #f8f9fa);
  color: var(--accent);
}

[data-theme="dark"] .xl-sheet .data-table thead tr.xl-headers-row th.col-editable-hdr {
  background: color-mix(in srgb, var(--accent-soft) 80%, #19212b);
}

.xl-sheet .data-table thead tr.xl-headers-row th.xl-col-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.xl-th-inner {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.xl-th-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.xl-sort-mark {
  font-size: 10px;
  color: var(--accent);
  flex-shrink: 0;
}

/* Classic Excel Square AutoFilter Button on right of header */
.xl-filter-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: var(--surface);
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

[data-theme="dark"] .xl-filter-btn {
  border-color: #334155;
}

.xl-filter-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.xl-filter-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.xl-filter-btn svg {
  width: 11px;
  height: 11px;
}

/* Column Resize Handle (right border of header) */
.xl-resize-handle {
  position: absolute;
  right: -2px;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: 4;
}

.xl-resize-handle:hover,
.xl-resize-handle.is-resizing {
  background: var(--accent);
}

/* Excel Hidden Column Double-Line Indicator (||) on letter header */
.xl-unhide-gap {
  position: absolute;
  left: -4px;
  top: 0;
  bottom: 0;
  width: 8px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.xl-unhide-gap::before,
.xl-unhide-gap::after {
  content: "";
  width: 1.5px;
  height: 14px;
  background: var(--accent);
  border-radius: 1px;
}

.xl-unhide-gap:hover {
  background: var(--accent-soft);
}

/* Sticky Row Numbers Column (Leftmost Excel Gutter) */
.xl-sheet .data-table th.xl-corner-th {
  position: sticky;
  left: 0;
  z-index: 15 !important;
  width: 48px;
  min-width: 48px;
  padding: 0 6px;
  text-align: center;
}

.xl-sheet .data-table td.xl-rownum-td {
  position: sticky;
  left: 0;
  z-index: 5;
  width: 48px;
  min-width: 48px;
  padding: 4px 6px;
  background: #f3f4f6;
  color: var(--muted);
  text-align: center;
  border-right: 1px solid #cbd5e1;
  user-select: none;
}

[data-theme="dark"] .xl-sheet .data-table td.xl-rownum-td {
  background: #141a22;
  border-right-color: #26303d;
}

.xl-sheet .data-table tbody tr.row-active td.xl-rownum-td {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);
}

/* Frozen Columns (Sticky Left) */
.xl-sheet .data-table th.xl-frozen {
  z-index: 14 !important;
}

.xl-sheet .data-table td.xl-frozen {
  position: sticky;
  z-index: 4;
}

.xl-sheet .data-table th.xl-frozen-edge,
.xl-sheet .data-table td.xl-frozen-edge {
  border-right: 2px solid var(--accent) !important;
  box-shadow: 2px 0 6px rgba(15, 23, 42, 0.08);
}

/* Sticky Right Holat Column */
.xl-sheet .data-table thead th.col-sticky-right {
  z-index: 14 !important;
}

/* Crisp Excel Grid Cells & Seamless Cell Editing */
.xl-sheet .data-table tbody td {
  padding: 4px 8px;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  height: 36px;
}

[data-theme="dark"] .xl-sheet .data-table tbody td {
  border-right-color: #232c38;
  border-bottom-color: #232c38;
}

.xl-sheet.is-compact .data-table tbody td {
  padding: 2px 6px;
  height: 29px;
  font-size: 12.5px;
}

.xl-sheet.is-compact .cell-input,
.xl-sheet.is-compact .cell-date {
  height: 26px;
  font-size: 12.5px;
}

.xl-sheet .data-table tbody td.xl-edit-td {
  padding: 0;
  position: relative;
}

.xl-sheet .data-table tbody td.xl-edit-td .cell-input {
  border: 1px solid transparent;
  border-radius: 0;
  height: 35px;
  min-width: 150px;
  padding: 4px 8px;
  background: transparent;
}

.xl-sheet.is-compact .data-table tbody td.xl-edit-td .cell-input {
  height: 28px;
  padding: 2px 6px;
}

.xl-sheet .data-table tbody td.xl-edit-td .cell-input:hover {
  background: color-mix(in srgb, var(--accent-soft) 40%, transparent);
}

.xl-sheet .data-table tbody td.xl-edit-td .cell-input:focus {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
  background: var(--surface);
}

.xl-sheet .data-table tbody td.xl-edit-td .cell-input.is-dirty {
  box-shadow: inset 0 0 0 1.5px var(--warn);
}

.xl-sheet .data-table tbody td.xl-edit-td .cell-input.is-saved {
  box-shadow: inset 0 0 0 1.5px var(--ok);
  background: var(--ok-bg);
}

/* Excel AutoFilter Floating Popup */
.xl-filter-popup {
  position: fixed;
  z-index: 95;
  width: 264px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 12.5px;
}

.xl-menu-section {
  padding: 4px;
  border-bottom: 1px solid var(--edge);
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.xl-menu-btn {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  padding: 6px 9px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.xl-menu-btn:hover:not(:disabled) {
  background: var(--bg-soft);
  color: var(--ink);
}

.xl-menu-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.xl-menu-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.xl-filter-search-wrap {
  padding: 8px 8px 6px;
}

.xl-filter-search-wrap .input {
  min-height: 30px;
  height: 30px;
  padding: 0 8px;
  font-size: 12.5px;
}

.xl-filter-values-box {
  margin: 0 8px;
  border: 1px solid var(--edge);
  border-radius: 4px;
  background: var(--bg);
  max-height: 195px;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.xl-filter-note {
  padding: 4px 8px 0;
  font-size: 11px;
  color: var(--muted);
}

.xl-filter-footer {
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

/* Excel Header Right-Click Context Menu */
.xl-context-menu {
  position: fixed;
  z-index: 98;
  width: 224px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.xl-context-sep {
  height: 1px;
  background: var(--edge);
  margin: 3px 4px;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1080px) {
  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .kpi-cell:nth-child(2) {
    border-right: none;
  }
  .kpi-cell:nth-child(1),
  .kpi-cell:nth-child(2) {
    border-bottom: 1px solid var(--edge);
  }
}

@media (max-width: 900px) {
  .admin-sidebar,
  .ws-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    border-radius: 0 14px 14px 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .admin-sidebar.open,
  .ws-sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop.open {
    display: block;
  }
  .mobile-menu-btn {
    display: inline-flex;
  }
  .admin-topbar {
    padding: 0 14px;
  }
  .admin-main {
    padding: 16px 14px 36px;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .chat-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .chat-threads {
    border-right: none;
    border-bottom: 1px solid var(--edge);
    max-height: 200px;
  }
  .chat-pane {
    height: 420px;
  }
  .ws-shell {
    padding: 6px;
    gap: 6px;
  }
}

@media (max-width: 540px) {
  .kpi-strip {
    grid-template-columns: 1fr;
  }
  .kpi-cell {
    border-right: none;
    border-bottom: 1px solid var(--edge);
  }
  .kpi-cell:last-child {
    border-bottom: none;
  }
  .data-table th.col-sticky-right,
  .data-table td.col-sticky-right {
    position: static;
    box-shadow: none;
  }
}
