/* ==========================================================================
   Codux Office — Indigo + Graphite design system
   Light theme is default. Dark theme via body[data-theme="dark"].
   ========================================================================== */

:root,
body[data-theme="light"] {
  /* Type */
  --font-sans: "Geist", "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --bg: #FAFAF9;
  --bg-elevated: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F4F4F5;
  --surface-3: #E4E4E7;
  --border: #E4E4E7;
  --border-strong: #D4D4D8;
  --border-subtle: #F1F1F2;

  --fg: #18181B;
  --fg-2: #3F3F46;
  --fg-3: #71717A;
  --fg-4: #A1A1AA;

  --indigo: #4F46E5;
  --indigo-hover: #4338CA;
  --indigo-soft: #EEF2FF;
  --indigo-border: #C7D2FE;
  --indigo-deep: #312E81;

  --emerald: #059669;
  --emerald-soft: #ECFDF5;
  --emerald-border: #A7F3D0;

  --amber: #B45309;
  --amber-soft: #FEF3C7;
  --amber-border: #FDE68A;

  --rose: #BE123C;
  --rose-soft: #FFE4E6;
  --rose-border: #FECDD3;

  --violet: #7C3AED;
  --violet-soft: #F5F3FF;

  --sidebar-bg: #FFFFFF;
  --sidebar-border: #ECECEE;
  --sidebar-fg: #52525B;
  --sidebar-fg-active: #18181B;
  --sidebar-bg-active: #F4F4F5;

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --radius: 10px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-sm: 0 1px 3px rgba(24, 24, 27, 0.06), 0 1px 2px rgba(24, 24, 27, 0.04);
  --shadow-md: 0 4px 12px rgba(24, 24, 27, 0.06), 0 2px 4px rgba(24, 24, 27, 0.04);
  --shadow-lg: 0 12px 32px rgba(24, 24, 27, 0.10), 0 4px 8px rgba(24, 24, 27, 0.04);
  --shadow-indigo: 0 4px 12px rgba(79, 70, 229, 0.22);
  --shadow: rgba(24, 24, 27, 0.10);

  /* Legacy aliases (back-compat with old renderer.js classnames) */
  --bg2: var(--surface);
  --bg3: var(--surface-2);
  --bg4: var(--surface-3);
  --border2: var(--border-strong);
  --text: var(--fg);
  --text2: var(--fg-3);
  --text3: var(--fg-4);
  --accent: var(--indigo);
  --accent2: var(--indigo-hover);
  --accent-fg: #FFFFFF;
  --green: var(--emerald);
  --red: var(--rose);
  --orange: var(--amber);
  --blue: var(--indigo);
  --mono: var(--font-mono);
  --sans: var(--font-sans);
}

/* Dark theme — keep tokens but on dark canvas */
body[data-theme="dark"] {
  --bg: #0A0A0B;
  --bg-elevated: #131316;
  --surface: #18181B;
  --surface-2: #1F1F23;
  --surface-3: #27272A;
  --border: #2A2A2E;
  --border-strong: #35353A;
  --border-subtle: #232327;

  --fg: #FAFAFA;
  --fg-2: #D4D4D8;
  --fg-3: #A1A1AA;
  --fg-4: #71717A;

  --indigo: #818CF8;
  --indigo-hover: #A5B4FC;
  --indigo-soft: rgba(99, 102, 241, 0.14);
  --indigo-border: rgba(129, 140, 248, 0.34);

  --emerald: #34D399;
  --emerald-soft: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(52, 211, 153, 0.32);

  --amber: #F59E0B;
  --amber-soft: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.34);

  --rose: #FB7185;
  --rose-soft: rgba(244, 63, 94, 0.12);
  --rose-border: rgba(251, 113, 133, 0.32);

  --violet: #A78BFA;
  --violet-soft: rgba(167, 139, 250, 0.12);

  --sidebar-bg: #131316;
  --sidebar-border: #2A2A2E;
  --sidebar-fg: #A1A1AA;
  --sidebar-fg-active: #FAFAFA;
  --sidebar-bg-active: #27272A;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.55), 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6), 0 4px 8px rgba(0, 0, 0, 0.4);
  --shadow-indigo: 0 4px 18px rgba(99, 102, 241, 0.4);
  --shadow: rgba(0, 0, 0, 0.6);

  --accent-fg: #0A0A0B;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.2s, color 0.2s;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-4); }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

#app {
  display: none;
  height: 100vh;
}
#app.authed { display: flex; }

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}
.auth-screen.show { display: flex; }

.auth-card {
  width: 380px;
  padding: 32px 28px 28px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
}

.auth-logo-img {
  width: 36px;
  height: 36px;
  /* Matches the rx=15/64 corner of logo.svg. */
  border-radius: 23.5%;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.18);
}

.auth-card h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 6px;
  text-align: center;
}

.auth-hint {
  font-size: 12.5px;
  color: var(--fg-3);
  text-align: center;
  margin-bottom: 22px;
  line-height: 1.5;
}

.auth-error {
  background: var(--rose-soft);
  border: 1px solid var(--rose-border);
  color: var(--rose);
  padding: 9px 12px;
  border-radius: var(--r-md);
  font-size: 12px;
  margin-bottom: 16px;
  display: none;
}
.auth-error.show { display: block; }

.auth-submit {
  width: 100%;
  padding: 11px 16px;
  margin-top: 8px;
  font-size: 13.5px;
  justify-content: center;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: 232px;
  min-width: 232px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 16px 8px;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 14px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  /* Matches the rx=15/64 corner of logo.svg. */
  border-radius: 23.5%;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.20);
  flex-shrink: 0;
}

.logo-text-wrap {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.logo-text {
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--sidebar-fg-active);
}

.logo-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--sidebar-fg);
  letter-spacing: 0.02em;
}

.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-fg);
  opacity: 0.7;
  padding: 12px 10px 6px 10px;
}

.nav {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--sidebar-fg);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.12s ease;
  margin-bottom: 1px;
}

.nav-item:hover {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-fg-active);
}

.nav-item.active {
  background: var(--indigo-soft);
  color: var(--indigo);
}

.nav-icon {
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.9;
  color: inherit;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.75;
}

.nav-item.active .nav-icon { opacity: 1; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-right: 6px;
  flex-shrink: 0;
  color: inherit;
}

.btn-icon svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.75;
}

.search-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: inherit;
  margin-right: 6px;
}

.search-icon svg {
  width: 100%;
  height: 100%;
  stroke-width: 1.75;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-row {
  display: flex;
  gap: 6px;
}

.settings-btn {
  flex: 1;
  padding: 7px 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-2);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.settings-btn:hover {
  color: var(--indigo);
  border-color: var(--indigo-border);
  background: var(--indigo-soft);
}

.settings-btn.active {
  color: var(--indigo);
  border-color: var(--indigo-border);
  background: var(--indigo-soft);
}

.lang-btn {
  font-weight: 600;
  letter-spacing: 0.05em;
}

.btn-export {
  width: 100%;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg-2);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  letter-spacing: -0.005em;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-export:hover {
  border-color: var(--indigo-border);
  color: var(--indigo);
  background: var(--indigo-soft);
}

/* ============================================================
   MAIN
   ============================================================ */
.main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.view { display: none; flex-direction: column; height: 100%; }
.view.active { display: flex; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px 18px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  flex-shrink: 0;
  gap: 16px;
  min-height: 64px;
}

.view-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.view-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-4);
  letter-spacing: -0.005em;
}

.count-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 6px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0 12px;
  height: 36px;
  color: var(--fg-3);
  font-size: 13px;
  transition: all 0.15s;
}

.search-box:focus-within {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 13.5px;
  padding: 8px 0;
  width: 220px;
}

.search-box input::placeholder { color: var(--fg-4); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  background: var(--indigo);
  color: #FFFFFF;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 0 14px;
  height: 36px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-indigo);
  white-space: nowrap;
}
.btn-primary:hover { background: var(--indigo-hover); }
.btn-primary:active { transform: translateY(1px); }

.btn-wide {
  padding: 0 20px;
  min-width: 160px;
}

.btn-secondary {
  background: var(--surface);
  color: var(--fg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 0 14px;
  height: 36px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-xs);
  white-space: nowrap;
}

.btn-secondary:hover {
  color: var(--fg);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn-sm { padding: 0 10px; height: 30px; font-size: 13px; border-radius: 8px; }

.btn-danger {
  background: var(--rose);
  color: #FFFFFF;
  border: none;
  border-radius: var(--r-md);
  padding: 0 14px;
  height: 36px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-danger:hover { filter: brightness(1.06); }

/* ============================================================
   EXPORT DROPDOWN
   ============================================================ */
.export-menu { position: relative; }

.export-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  min-width: 180px;
  z-index: 50;
  overflow: hidden;
}

.export-dropdown.open { display: flex; }

.export-dropdown button {
  background: none;
  border: none;
  color: var(--fg);
  padding: 9px 14px;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.1s;
}

.export-dropdown button:hover {
  background: var(--surface-2);
  color: var(--indigo);
}

/* ============================================================
   CLIENT GRID + CARD
   ============================================================ */
.client-grid {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
  align-content: start;
}

.client-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.client-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.client-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.client-card-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}

.status-active   { background: var(--emerald); box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15); }
.status-inactive { background: var(--fg-4);   box-shadow: 0 0 0 3px rgba(161, 161, 170, 0.15); }
.status-paused   { background: var(--amber);  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.15); }

.client-card-url {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tech-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--fg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.client-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.client-hours {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-3);
  font-weight: 500;
}

.card-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.client-card:hover .card-actions { opacity: 1; }

.card-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg-3);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.12s;
}

.card-btn:hover { color: var(--fg); background: var(--surface-3); }
.card-btn.del:hover { color: var(--rose); border-color: var(--rose-border); background: var(--rose-soft); }

.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 80px 20px;
  color: var(--fg-4);
}

.empty-state .icon { font-size: 40px; margin-bottom: 16px; opacity: 0.6; }
.empty-state p { font-size: 14px; }

/* ============================================================
   SUMMARY / KPI CARDS
   ============================================================ */
.hours-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg);
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}

.summary-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.summary-label {
  font-size: 11.5px;
  color: var(--fg-3);
  margin-bottom: 6px;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.summary-value {
  font-size: 22px;
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--fg);
  line-height: 1.1;
}

.summary-value.multi {
  font-size: 13px;
  line-height: 1.5;
}

/* ============================================================
   HOURS / PROJECTS TABLE
   ============================================================ */
.hours-table-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 20px 32px 32px;
}

.hours-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  font-size: 13.5px;
}

.hours-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-4);
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.hours-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  vertical-align: middle;
}

.hours-table tbody tr:last-child td { border-bottom: 0; }
.hours-table tbody tr { transition: background 0.12s; }
.hours-table tbody tr:hover td { background: var(--surface-2); }

.hours-table .mono { font-family: var(--font-mono); font-size: 12.5px; }

.hours-table td.col-paid { color: var(--fg); }
.hours-table td.col-outstanding { color: var(--amber); }
.hours-table td.col-outstanding.zero { color: var(--fg-4); }

.hours-table tr.row-done td { opacity: 0.7; }
.hours-table tr.row-done td:nth-child(2) {
  text-decoration: line-through;
  text-decoration-color: var(--fg-4);
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 232px;
  background: rgba(15, 15, 18, 0.42);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

body[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.65);
}

.modal-overlay.open { display: flex; }

/* Opened from within another modal (tax obligation view/edit) — must stack above it */
#taxSlipViewModal { z-index: 200; }

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.15s ease;
  overflow: hidden;
}

.modal-wide { width: 720px; }
.modal-sm { width: 440px; }
.modal-xl { width: min(920px, 92vw); }

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.97) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-3);
  font-size: 16px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: all 0.1s;
}

.modal-close:hover { color: var(--fg); background: var(--surface-2); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

/* ============================================================
   FORM TABS
   ============================================================ */
.form-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  flex-wrap: wrap;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--fg-3);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.12s, border-color 0.12s;
  border-radius: 8px 8px 0 0;
  position: relative;
}

.tab-btn:hover { color: var(--fg); }

.tab-btn.active {
  color: var(--indigo);
  border-bottom-color: var(--indigo);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   FORM FIELDS
   ============================================================ */
.form-group { margin-bottom: 16px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: block;
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--fg-3);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

input, textarea, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 13.5px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  letter-spacing: -0.005em;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}

input::placeholder, textarea::placeholder { color: var(--fg-4); }

select { cursor: pointer; padding-right: 32px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A1A1AA' stroke-width='2.5' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

textarea {
  resize: vertical;
  min-height: 110px;
  font-family: var(--font-sans);
}

.rate-row {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 6px;
}

.currency-select {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
}

.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 40px; }

.toggle-pass {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: 0.5;
  color: var(--fg-3);
  transition: opacity 0.15s;
  padding: 4px;
}
.toggle-pass:hover { opacity: 1; }

.select-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--fg);
  font-size: 13.5px;
  padding: 0 32px 0 12px;
  height: 36px;
  outline: none;
  cursor: pointer;
  min-width: 150px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A1A1AA' stroke-width='2.5' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.select-input:focus {
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}

/* ============================================================
   CLIENT DETAIL MODAL
   ============================================================ */
.detail-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.detail-section {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
}

.detail-section.full { grid-column: 1 / -1; }

.detail-section h3 {
  font-size: 11px;
  font-family: var(--font-sans);
  font-weight: 600;
  color: var(--fg-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 8px;
}

.detail-row:last-child { margin-bottom: 0; }

.detail-key {
  font-size: 12px;
  color: var(--fg-3);
  flex-shrink: 0;
}

.detail-val {
  font-size: 12.5px;
  color: var(--fg);
  text-align: right;
  word-break: break-all;
  font-family: var(--font-mono);
  font-weight: 500;
}

.detail-val.copy-val {
  cursor: pointer;
  color: var(--indigo);
}
.detail-val.copy-val:hover { text-decoration: underline; }

.detail-notes {
  grid-column: 1 / -1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  white-space: pre-wrap;
  font-size: 13px;
  color: var(--fg-2);
  line-height: 1.6;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--fg);
  padding: 11px 18px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s;
  z-index: 999;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   PROJECTS
   ============================================================ */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  font-size: 13.5px;
  color: var(--fg);
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-sans);
  font-weight: 400;
  cursor: pointer;
  margin-bottom: 0;
}

.check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--indigo);
  cursor: pointer;
  margin: 0;
  padding: 0;
}

.proj-check {
  width: 16px;
  height: 16px;
  accent-color: var(--indigo);
  cursor: pointer;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  border: 1px solid;
  text-transform: none;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-open {
  color: var(--amber);
  border-color: var(--amber-border);
  background: var(--amber-soft);
}

.badge-done {
  color: var(--emerald);
  border-color: var(--emerald-border);
  background: var(--emerald-soft);
}

.badge-partial {
  color: var(--indigo);
  border-color: var(--indigo-border);
  background: var(--indigo-soft);
}

/* Detail view: projects mini-list */
.proj-mini {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.proj-mini:last-child { border-bottom: none; }
.proj-mini-name { color: var(--fg); font-weight: 500; }
.proj-mini-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-3); }
.proj-mini.done .proj-mini-name {
  color: var(--fg-3);
  text-decoration: line-through;
  text-decoration-color: var(--fg-4);
}

.outstanding-hint {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--fg-2);
  margin: -8px 0 16px;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.outstanding-hint.hidden { display: none; }
.outstanding-hint .out-val {
  color: var(--amber);
  font-weight: 600;
  font-family: var(--font-mono);
}
.outstanding-hint .out-val.zero { color: var(--emerald); }

/* ============================================================
   TASKS / KANBAN
   ============================================================ */
.tasks-container {
  flex: 1;
  display: flex;
  gap: 0;
}

.tasks-board {
  flex: 1;
  overflow-y: auto;
  padding: 20px 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tasks-sidebar-wrapper {
  width: 280px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.tasks-sidebar-header {
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.tasks-sidebar-header h3 {
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-3);
  margin: 0;
}

.tasks-sidebar {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tasks-sidebar-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: grab;
  transition: all 0.12s ease;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}

.tasks-sidebar-item:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

.tasks-sidebar-item.dragging {
  opacity: 0.5;
  background: var(--surface);
}

.tasks-sidebar-item.drag-over-top::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--indigo);
  border-radius: 2px;
}

.tasks-sidebar-item.drag-over-bottom::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--indigo);
  border-radius: 2px;
}

.tasks-sidebar-project {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--fg-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tasks-sidebar-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg);
  word-break: break-word;
}

.tasks-sidebar-date {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-4);
  margin-top: 2px;
}

.tasks-sidebar-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  color: var(--fg-4);
}

.tasks-empty {
  text-align: center;
  color: var(--fg-4);
  padding: 80px 20px;
}

.tasks-empty .icon { font-size: 40px; margin-bottom: 16px; opacity: 0.6; }

.task-project-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: opacity 0.1s, border-color 0.1s;
}

.task-project-block.dragging { opacity: 0.4; }

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--fg-4);
  font-size: 13px;
  cursor: grab;
  user-select: none;
  border-radius: 6px;
  letter-spacing: -2px;
  transition: color 0.1s, background 0.1s;
}

.drag-handle:hover { color: var(--indigo); background: var(--indigo-soft); }
.drag-handle:active { cursor: grabbing; }

.task-project-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  gap: 12px;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s;
}
.task-project-header:hover { background: var(--surface-3); }
.task-project-block.collapsed .task-project-header { border-bottom: 0; }

.task-project-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.task-project-chevron {
  font-size: 13px;
  color: var(--fg-4);
  transition: transform 0.18s;
  margin-left: 2px;
  line-height: 1;
}
.task-project-block.collapsed .task-project-chevron { transform: rotate(-90deg); }

.task-project-block.collapsed .task-columns { display: none; }

.proj-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 5px;
  line-height: 18px;
}
.proj-pill.amber   { background: var(--amber-soft);   color: var(--amber); }
.proj-pill.indigo  { background: var(--indigo-soft);  color: var(--indigo); }
.proj-pill.emerald { background: var(--emerald-soft); color: var(--emerald); }

.task-project-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.task-project-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.01em;
}

.task-project-client {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-3);
}

.task-project-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-4);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
}

.task-columns {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0;
}

.task-column {
  padding: 12px;
  border-right: 1px solid var(--border);
  min-height: 120px;
  transition: background 0.1s;
}

.task-column:last-child { border-right: 0; }

.task-column.drag-over {
  background: var(--indigo-soft);
}

.task-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  padding: 2px 4px 10px;
}

.task-column-header .col-add {
  background: none;
  border: 1px dashed var(--border-strong);
  color: var(--fg-4);
  width: 20px;
  height: 20px;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
}
.task-column-header .col-add:hover {
  color: var(--indigo);
  border-color: var(--indigo);
  background: var(--indigo-soft);
}

.task-column-count {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg-3);
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  text-transform: none;
  letter-spacing: 0;
}

.task-column[data-status="todo"] .task-column-header { color: var(--amber); }
.task-column[data-status="in_progress"] .task-column-header { color: var(--indigo); }
.task-column[data-status="done"] .task-column-header { color: var(--emerald); }

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--fg-4);
  border-radius: 10px;
  padding: 11px 12px;
  margin-bottom: 8px;
  cursor: grab;
  transition: all 0.15s;
}

.task-card[data-status="todo"]        { border-left-color: var(--amber); }
.task-card[data-status="in_progress"] { border-left-color: var(--indigo); }
.task-card[data-status="done"]        { border-left-color: var(--emerald); opacity: 0.78; }

.task-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.task-card:active { cursor: grabbing; }
.task-card.dragging { opacity: 0.4; }

.task-card[data-status="done"] .task-card-title {
  text-decoration: line-through;
  color: var(--fg-3);
}

.task-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}

.task-card-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  word-break: break-word;
  letter-spacing: -0.01em;
  flex: 1;
}

.task-card-desc {
  font-size: 12.5px;
  color: var(--fg-3);
  line-height: 1.45;
  margin-bottom: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.task-card-footer {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-4);
}

.task-card-date::before { content: '◷ '; }

.task-card-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  opacity: 1;
  transition: opacity 0.15s;
}

.task-card:hover .task-card-actions { opacity: 1; }

.task-card-actions button {
  background: none;
  border: none;
  color: var(--fg-4);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 4px;
}

.task-card-actions button:hover { color: var(--indigo); background: var(--indigo-soft); }
.task-card-actions button.del:hover { color: var(--rose); background: var(--rose-soft); }

.task-column-empty {
  text-align: center;
  color: var(--fg-4);
  font-size: 12px;
  padding: 18px 8px;
  font-family: var(--font-sans);
  border: 1.5px dashed var(--border);
  border-radius: 9px;
}

/* ============================================================
   DASHBOARD (HOME)
   ============================================================ */
.dashboard-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: all 0.15s;
}

.kpi:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.kpi-flag {
  position: absolute;
  top: 0; right: 0;
  width: 3px; height: 100%;
  background: var(--indigo);
}

.kpi-flag.amber { background: var(--amber); }
.kpi-flag.emerald { background: var(--emerald); }
.kpi-flag.violet { background: var(--violet); }

.kpi-label {
  font-size: 12.5px;
  color: var(--fg-3);
  font-weight: 500;
}

.kpi-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--fg);
  line-height: 1.1;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.kpi-value .unit {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-3);
  margin-left: 5px;
}

.kpi-sub {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-4);
  margin-top: 2px;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 500;
}
.kpi-delta.up { color: var(--emerald); }
.kpi-delta.down { color: var(--rose); }
.kpi-delta.warn { color: var(--amber); }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
}

@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

.card-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.panel-title-block .panel-cap {
  font-size: 12.5px;
  color: var(--fg-3);
}

.panel-title-block .panel-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 2px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.panel-title-block .panel-value .muted {
  font-size: 13px;
  font-weight: 400;
  color: var(--fg-4);
  margin-left: 6px;
  font-family: var(--font-sans);
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 160px;
  padding-top: 8px;
}

.chart-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.chart-stack {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  width: 100%;
  height: 130px;
  gap: 1.5px;
}

.chart-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 2px;
  transition: opacity 0.15s;
}
.chart-bar:hover { opacity: 0.8; }
.chart-bar.indigo  { background: var(--indigo); }
.chart-bar.violet  { background: var(--violet); }
.chart-bar.emerald { background: var(--emerald); }
.chart-bar.amber   { background: var(--amber); }
.chart-bar.zinc    { background: var(--fg-4); }

.chart-bar-empty {
  width: 4px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  align-self: center;
  margin-top: auto;
  margin-bottom: 4px;
}

.chart-day-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-4);
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--fg-2);
}

.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.chart-legend-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-4);
}

.pipeline-list { display: flex; flex-direction: column; gap: 12px; }

.pipeline-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pipeline-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.pipeline-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.pipeline-client {
  font-size: 11.5px;
  color: var(--fg-4);
  font-family: var(--font-mono);
}

.pipeline-amount {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
}
.pipeline-amount.unpaid { color: var(--rose); }
.pipeline-amount.paid { color: var(--emerald); }

.progress {
  height: 6px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--indigo);
  border-radius: 999px;
  transition: width 0.3s;
}

.progress-bar.emerald { background: var(--emerald); }
.progress-bar.amber { background: var(--amber); }
.progress-bar.rose { background: var(--rose); }

.todo-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 360px;
  overflow-y: auto;
}

.todo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 8px;
  cursor: default;
  transition: background 0.12s;
}

.todo-row:hover { background: var(--surface-2); }

.todo-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 5px;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.todo-checkbox.doing {
  border-color: var(--indigo);
  background: var(--indigo-soft);
}
.todo-checkbox.doing::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--indigo);
}

.todo-checkbox.done {
  border-color: var(--emerald);
  background: var(--emerald);
  color: white;
}
.todo-checkbox.done::after {
  content: '✓';
  font-size: 10px;
  font-weight: 700;
  color: white;
}

.todo-text {
  flex: 1;
  min-width: 0;
}

.todo-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--fg);
}
.todo-row.done .todo-title { text-decoration: line-through; color: var(--fg-3); }

.todo-meta {
  font-size: 11px;
  color: var(--fg-4);
  font-family: var(--font-mono);
  margin-top: 1px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 8px;
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.pill.indigo  { background: var(--indigo-soft);  color: var(--indigo);  border-color: var(--indigo-border); }
.pill.amber   { background: var(--amber-soft);   color: var(--amber);   border-color: var(--amber-border); }
.pill.emerald { background: var(--emerald-soft); color: var(--emerald); border-color: var(--emerald-border); }
.pill.rose    { background: var(--rose-soft);    color: var(--rose);    border-color: var(--rose-border); }

.card-panel--tasks {
  border-left: 3px solid var(--indigo);
}

.task-status-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 999px;
  border: 1px solid transparent;
  margin-left: 6px;
  vertical-align: middle;
  font-family: var(--font-sans);
}
.task-status-badge.doing { background: var(--indigo-soft); color: var(--indigo); border-color: var(--indigo-border); }
.task-status-badge.todo  { background: var(--amber-soft);  color: var(--amber);  border-color: var(--amber-border); }

.activity {
  display: flex;
  flex-direction: column;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border-bottom: 0; }

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 7px;
  flex-shrink: 0;
}
.activity-dot.indigo  { background: var(--indigo); }
.activity-dot.emerald { background: var(--emerald); }
.activity-dot.amber   { background: var(--amber); }
.activity-dot.violet  { background: var(--violet); }
.activity-dot.rose    { background: var(--rose); }

.activity-body { flex: 1; min-width: 0; }

.activity-title {
  font-size: 13px;
  color: var(--fg);
  line-height: 1.4;
}

.activity-title b { font-weight: 600; }

.activity-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-4);
  margin-top: 2px;
}

.dashboard-empty {
  text-align: center;
  color: var(--fg-4);
  padding: 32px 16px;
  font-size: 12.5px;
}

.dashboard-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--indigo);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.12s;
}
.dashboard-cta:hover { background: var(--indigo-soft); }

/* ============================================================
   WP MAINTENANCE
   ============================================================ */

.wp-detail-meta { margin-bottom: 20px; }

.wp-year-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.wp-year-label {
  font-size: 16px;
  font-weight: 600;
  min-width: 60px;
  text-align: center;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.month-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.month-tile:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.month-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.month-tile-name {
  font-weight: 600;
  font-size: 13.5px;
}

.month-tile.done .status-dot { background: var(--emerald); box-shadow: 0 0 0 3px var(--emerald-soft); }
.month-tile.partial .status-dot { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.month-tile.empty .status-dot { background: var(--fg-4); box-shadow: 0 0 0 3px rgba(161, 161, 170, 0.15); }

.month-tile-summary {
  font-size: 11.5px;
  color: var(--fg-3);
  line-height: 1.5;
}

.month-tile-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.15s;
}

.month-tile:hover .month-tile-actions { opacity: 1; }

.plugin-rows-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.plugin-row {
  display: grid;
  grid-template-columns: 20px 1.4fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.plugin-row-num {
  font-size: 12.5px;
  color: var(--fg-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.plugin-row input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font-size: 12.5px;
}

.plugin-row-del {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--fg-3);
  border-radius: 6px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  transition: all 0.12s;
}

.plugin-row-del:hover { color: var(--rose); border-color: var(--rose-border); background: var(--rose-soft); }

.quote-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: var(--r-md) var(--r-md) 0 0;
  background: var(--surface-2);
}

.quote-editor-toolbar button {
  width: 32px;
  height: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.12s;
}

.quote-editor-toolbar button#quoteAddRowBtn,
.quote-editor-toolbar button#quoteAddColBtn {
  width: auto;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 600;
}

.quote-editor-toolbar button:hover {
  background: var(--indigo-soft);
  color: var(--indigo);
  border-color: var(--indigo-border);
}

.quote-editor-toolbar select {
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-size: 12.5px;
  width: auto;
  margin-left: auto;
}

.quote-editor-body {
  min-height: 300px;
  max-height: 500px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: 0 0 var(--r-md) var(--r-md);
  padding: 14px 16px;
  background: var(--surface);
  color: var(--fg);
  font-size: 13.5px;
  line-height: 1.6;
}

.quote-editor-body:focus { outline: none; border-color: var(--indigo-border); }
.quote-editor-body ol, .quote-editor-body ul { margin: 6px 0; padding-left: 26px; }
.quote-editor-body li { margin: 2px 0; }
.quote-editor-body p { margin: 0 0 8px; }
.quote-editor-body blockquote { margin: 0 0 8px 0; padding-left: 14px; border-left: 3px solid var(--border-strong); }

.quote-editor-body table.quote-table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
}

.quote-editor-body table.quote-table td {
  border: 1px solid var(--border-strong);
  padding: 6px 10px;
  min-width: 40px;
}

.quote-editor-body table.quote-table th {
  border: 1px solid var(--indigo-border);
  padding: 6px 10px;
  min-width: 40px;
  background: var(--indigo-soft);
  color: var(--indigo);
  font-weight: 700;
  text-align: left;
}

/* ============================================================
   VIEW TOGGLE (cards / table)
   ============================================================ */
.view-toggle {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  overflow: hidden;
  height: 36px;
}

.view-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  background: var(--surface);
  border: none;
  color: var(--fg-3);
  cursor: pointer;
  transition: all 0.12s;
}

.view-toggle-btn + .view-toggle-btn { border-left: 1px solid var(--border-strong); }
.view-toggle-btn:hover { background: var(--surface-2); color: var(--fg); }
.view-toggle-btn.active { background: var(--indigo-soft); color: var(--indigo); }

.view-toggle-btn svg { width: 16px; height: 16px; }

#agencyViewToggle .view-toggle-btn {
  width: auto;
  padding: 0 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

#view-wp .hours-table-wrap { display: none; }
#view-wp.table-mode .client-grid { display: none; }
#view-wp.table-mode #wpSiteTableWrap { display: block; }
#view-wp.matrix-mode .client-grid { display: none; }
#view-wp.matrix-mode #wpMatrixWrap { display: block; }

.wp-matrix-table th:first-child,
.wp-matrix-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
  text-align: center;
  width: 32px;
  min-width: 32px;
  z-index: 2;
}

.wp-matrix-table thead th:first-child { background: var(--surface-2); }

.wp-matrix-table th:nth-child(2),
.wp-matrix-table td:nth-child(2) {
  position: sticky;
  left: 32px;
  background: var(--surface);
  text-align: left;
  min-width: 180px;
  z-index: 1;
}

.wp-matrix-table thead th:nth-child(2) { background: var(--surface-2); }

.wp-matrix-table th,
.wp-matrix-table td {
  text-align: center;
  white-space: nowrap;
}

.wp-matrix-table th.current-month { background: var(--indigo-soft); color: var(--indigo); }
.wp-matrix-table td.current-month { background: var(--indigo-soft); }

.wp-matrix-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.row-num-col,
.hours-table td.row-num {
  width: 36px;
  text-align: center !important;
  color: var(--fg-4);
  font-variant-numeric: tabular-nums;
}

.wp-name-cell {
  cursor: pointer;
}

.wp-name-cell:hover {
  color: var(--indigo);
  text-decoration: underline;
}

#wpSiteTableBody tr[draggable="true"],
#wpMatrixBody tr[draggable="true"] {
  cursor: grab;
}

#wpSiteTableBody tr.dragging,
#wpMatrixBody tr.dragging {
  opacity: 0.5;
}

#wpSiteTableBody tr.drag-over-top td,
#wpMatrixBody tr.drag-over-top td {
  box-shadow: inset 0 2px 0 var(--indigo);
}

#wpSiteTableBody tr.drag-over-bottom td,
#wpMatrixBody tr.drag-over-bottom td {
  box-shadow: inset 0 -2px 0 var(--indigo);
}

/* ============================================================
   INVOICE ITEM ROWS
   ============================================================ */
.invoice-item-rows-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.invoice-item-row {
  display: grid;
  grid-template-columns: 2fr 0.7fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.invoice-item-row input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg);
  font-size: 12.5px;
}

.invoice-item-row .invoice-item-amount {
  height: 34px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 12.5px;
  font-family: var(--font-mono);
  color: var(--fg-3);
  background: var(--surface-2);
  border-radius: var(--r-md);
}

/* ============================================================
   AGENCY — ANNUAL LIMIT + TAXES
   ============================================================ */
.limit-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  margin: 0 32px 20px;
}

.limit-summary .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-4);
  margin-bottom: 4px;
}

.limit-summary .stat-value {
  font-size: 20px;
  font-weight: 600;
  font-family: var(--font-mono);
}

.limit-summary .stat-value.warn { color: var(--amber); }
.limit-summary .stat-value.danger { color: var(--rose); }

.limit-bar-wrap {
  grid-column: 1 / -1;
  height: 10px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.limit-bar {
  height: 100%;
  border-radius: 999px;
  background: var(--emerald);
  transition: width 0.2s ease;
}

.limit-bar.warn { background: var(--amber); }
.limit-bar.danger { background: var(--rose); }

.rate-missing-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--amber);
  font-size: 11.5px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
}

.tax-block {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.tax-block h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
}

.tax-slip-preview {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tax-slip-preview img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.tax-slip-preview .no-slip {
  font-size: 11.5px;
  color: var(--fg-4);
}

.tax-row-overdue td { color: var(--rose); }

/* ============================================================
   AGENCY — DASHBOARD
   ============================================================ */

/* Filled, color-coded toggle buttons (dashboard / KPO / porezi) */
#agencyViewToggle .view-toggle-btn[data-mode="dashboard"].active { background: var(--indigo); color: #fff; }
#agencyViewToggle .view-toggle-btn[data-mode="limit"].active { background: var(--emerald); color: #fff; }
#agencyViewToggle .view-toggle-btn[data-mode="invoices"].active { background: var(--violet); color: #fff; }
#agencyViewToggle .view-toggle-btn[data-mode="taxes"].active { background: var(--amber); color: #fff; }

.agency-panel-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 32px;
}

.agency-greeting {
  padding: 0 32px;
  margin-bottom: 18px;
}

.agency-greeting h2 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 2px;
}

.agency-greeting .sub {
  font-size: 13px;
  color: var(--fg-3);
}

.agency-bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  padding: 0 32px;
  margin-bottom: 18px;
}

.agency-mini-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
}

.agency-mini-bar .mini-bar-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-2);
  white-space: nowrap;
}

.agency-mini-bar .mini-bar-pct {
  font-size: 11.5px;
  color: var(--fg-4);
  white-space: nowrap;
}

.agency-mini-bar .mini-bar-track {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.agency-mini-bar .mini-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--emerald);
  transition: width 0.2s ease;
}

.agency-mini-bar .mini-bar-fill.warn { background: var(--amber); }
.agency-mini-bar .mini-bar-fill.danger { background: var(--rose); }

.agency-mini-bar .mini-bar-value {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--fg-3);
  white-space: nowrap;
}

.agency-warning-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 32px 18px;
  padding: 12px 16px;
  background: var(--amber-soft);
  border: 1px solid var(--amber-border);
  border-radius: var(--r-md);
  color: var(--amber);
  font-size: 13px;
}

.agency-warning-banner button {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--amber-border);
  color: var(--amber);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.agency-warning-banner button:hover { background: rgba(0,0,0,0.04); }

.agency-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  padding: 0 32px;
  margin-bottom: 18px;
}

.agency-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
}

.agency-stat-card .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-4);
  margin-bottom: 6px;
}

.agency-stat-card .stat-value {
  font-size: 19px;
  font-weight: 600;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.agency-stat-card .stat-sub {
  font-size: 11.5px;
  color: var(--fg-4);
  margin-top: 4px;
}

.agency-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 32px;
  margin-bottom: 22px;
}

.quick-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  padding: 0 16px;
  height: 38px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: #fff;
  cursor: pointer;
  transition: filter 0.12s, transform 0.05s;
}

.quick-action-btn:hover { filter: brightness(1.08); }
.quick-action-btn:active { transform: translateY(1px); }
.quick-action-btn.blue { background: var(--indigo); }
.quick-action-btn.green { background: var(--emerald); }
.quick-action-btn.purple { background: var(--violet); }

.agency-panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 0 32px 32px;
}

@media (max-width: 1100px) {
  .agency-panel-grid { grid-template-columns: 1fr; }
}

.agency-panel-sub {
  font-size: 11.5px;
  color: var(--fg-4);
}

.agency-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}

.agency-list-item:last-child { border-bottom: 0; }

.agency-list-item .agency-list-main { min-width: 0; }

.agency-list-item .agency-list-title {
  font-weight: 500;
  color: var(--fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agency-list-item .agency-list-meta {
  font-size: 11px;
  color: var(--fg-4);
  margin-top: 1px;
}

.agency-list-item .agency-list-value {
  flex-shrink: 0;
  font-family: var(--font-mono);
  color: var(--fg-3);
  white-space: nowrap;
}

/* ── Web: session, roles, optional features ── */
.admin-only, .web-reset-only { display: none; }
body[data-role="admin"] .admin-only { display: flex; }
body[data-reset-email="on"] .web-reset-only { display: block; }
a.btn-export { text-decoration: none; }
.auth-link {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--fg-3);
  text-decoration: none;
}
.auth-link:hover, .auth-link:focus-visible { color: var(--accent); text-decoration: underline; }
.session-user {
  font-size: 12px;
  color: var(--sidebar-fg);
  opacity: 0.75;
  padding: 0 4px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-user:empty { display: none; }
.logo-field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-preview { height: 40px; width: auto; max-width: 180px; object-fit: contain; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.logo-field [hidden] { display: none; }
/* Shortcuts into modules the admin turned off for this user. */
body[data-modules-off~="tasks"] [data-go="tasks"],
body[data-modules-off~="tasks"] #agencyGoTasks,
body[data-modules-off~="hours"] #dashGoHours,
body[data-modules-off~="clients"] #dashGoClients,
body[data-modules-off~="clients"] #agencyQuickClient { display: none !important; }

/* ── Company settings modal: grouped sections, two columns ── */
.company-settings .modal-body { padding: 6px 28px 10px; }
.settings-section { padding: 20px 0 6px; border-top: 1px solid var(--border); }
.settings-section:first-child { border-top: 0; }
.settings-section-head { margin-bottom: 14px; }
.settings-section-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--fg);
}
.settings-section-head p { margin: 3px 0 0; font-size: 12px; color: var(--fg-3); }
.company-settings .form-row { gap: 16px; }
.company-settings textarea { resize: vertical; min-height: 64px; }
.company-settings .logo-field { padding-bottom: 14px; }
@media (max-width: 720px) {
  .company-settings .form-row { grid-template-columns: 1fr; gap: 0; }
  .company-settings .modal-body { padding: 4px 18px 8px; }
}

/* ============================================================
   PHONE / TABLET (≤ 860px)
   Sidebar becomes a drawer behind a top bar; content goes single
   column; modals go full screen. Desktop styles are untouched.
   ============================================================ */
.mobile-bar, .sidebar-backdrop { display: none; }

@media (max-width: 860px) {
  body { height: 100dvh; }
  #app { height: 100dvh; flex-direction: column; }

  /* Top bar */
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 12px;
    flex-shrink: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
  }
  .mobile-menu-btn {
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
  }
  .mobile-menu-btn span { display: block; height: 2px; border-radius: 2px; background: var(--fg); }
  .mobile-menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  .mobile-bar-logo { width: 28px; height: 28px; border-radius: 23.5%; }
  .mobile-bar-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Drawer */
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 300;
    width: min(288px, 86vw);
    min-width: 0;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18); }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 290;
    background: rgba(15, 15, 18, 0.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }
  body.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .main { min-height: 0; }

  /* View headers: wrap actions under the title */
  .view-header { flex-wrap: wrap; padding: 12px 16px; min-height: 0; gap: 10px; }
  .view-title { flex-shrink: 1; min-width: 0; flex-wrap: wrap; }
  .header-actions { flex-wrap: wrap; width: 100%; }
  .header-actions > * { flex: 1 1 auto; }
  .view-toggle { max-width: 100%; overflow-x: auto; }
  .view-toggle-btn { flex: 1 0 auto; }

  /* Content areas: tighter gutters */
  .client-grid,
  .hours-summary,
  .hours-table-wrap,
  .tasks-board,
  .dashboard-body,
  .agency-panel-toolbar,
  .agency-greeting,
  .agency-bars,
  .agency-stat-grid,
  .agency-quick-actions,
  .agency-panel-grid { padding-left: 16px; padding-right: 16px; }
  .agency-panel-toolbar, .agency-quick-actions { flex-wrap: wrap; }
  .dashboard-grid > *, .agency-panel-grid > * { min-width: 0; }
  .card-panel { overflow-x: auto; }
  .agency-warning-banner { margin-left: 16px; margin-right: 16px; }
  .agency-mini-bar { flex-wrap: wrap; row-gap: 6px; }
  .agency-mini-bar .mini-bar-track { flex: 1 1 100%; order: 3; }
  .agency-mini-bar .mini-bar-value { order: 4; }
  .client-grid { grid-template-columns: 1fr; }
  .dashboard-grid, .agency-panel-grid { grid-template-columns: 1fr; }

  /* Wide tables scroll inside their card instead of stretching the page */
  .hours-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .hours-table { min-width: 640px; }

  /* Modals: full screen, single-column forms */
  .modal-overlay { left: 0; padding: 0; align-items: stretch; }
  .modal, .modal-wide, .modal-sm, .modal-xl { width: 100%; max-height: none; height: 100%; border: 0; border-radius: 0; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .invoice-item-row { grid-template-columns: 1fr 1fr; }
  .invoice-item-row > :first-child { grid-column: 1 / -1; }
  .plugin-row { grid-template-columns: 20px 1fr auto; }

  /* iOS zooms into inputs smaller than 16px */
  input, select, textarea { font-size: 16px; }

  /* Login card */
  .auth-card { width: calc(100vw - 32px); max-width: 380px; padding: 28px 20px 22px; }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
