/*
  Folio Desk (templates/folio)
  Swiss drafting ledger design system: warm archival white paper, graphite ink,
  cobalt active states, emerald billable indicators, crimson overages, and fine ruled grids.
*/

:root {
  /* Color palette */
  --bg-paper: #faf8f4;
  --bg-sheet: #ffffff;
  --bg-subtle: #f4f1ea;
  --bg-hover: #efeae0;
  --ink: #18181b;
  --ink-secondary: #52525b;
  --ink-muted: #6e6e77;
  --border: #dcd7cc;
  --border-strong: #18181b;
  --cobalt: #2563eb;
  --cobalt-hover: #1d4ed8;
  --cobalt-tint: #eff6ff;
  --emerald: #16a34a;
  --emerald-btn: #15803d;
  --emerald-hover: #166534;
  --emerald-text: #166534;
  --emerald-tint: #f0fdf4;
  --crimson: #dc2626;
  --crimson-text: #b91c1c;
  --crimson-tint: #fef2f2;
  --amber: #b45309;
  --amber-tint: #fffbeb;

  /* Typography */
  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  /* Radii */
  --radius-none: 0px;
  --radius-sm: 2px;
  --radius-md: 4px;

  /* Elevation */
  --shadow-modal: 0 20px 48px rgba(24, 24, 27, 0.16);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background-color: var(--bg-paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  accent-color: var(--cobalt);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-paper);
  color: var(--ink);
  overflow-x: clip;
}

::selection {
  background-color: var(--cobalt);
  color: #ffffff;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

::-webkit-scrollbar-track {
  background: var(--bg-paper);
}

::-webkit-scrollbar-thumb {
  background: #c5bfb2;
  border: 2px solid var(--bg-paper);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--ink-secondary);
}

/* Focus visibility */
:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: 200;
  background: var(--ink);
  color: var(--bg-paper);
  padding: var(--space-2) var(--space-4);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: var(--space-3);
}

.tabular-num,
.mono-cell,
.timer-clock,
.kpi-value,
.retainer-pct,
.tab-count {
  font-variant-numeric: tabular-nums;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0.1rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
}

/* Sticky Topbar & Live Studio Stopwatch */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 248, 244, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-strong);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.period-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

.timer-bar {
  flex: 1 1 560px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: var(--bg-sheet);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.5rem;
}

.timer-fields {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.timer-select,
.timer-input {
  height: 36px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 var(--space-2);
}

.timer-select {
  max-width: 220px;
  font-weight: 600;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding-right: var(--space-3);
  cursor: pointer;
  text-overflow: ellipsis;
}

.timer-input {
  flex: 1;
  min-width: 140px;
}

.timer-input:hover,
.timer-select:hover {
  background: var(--bg-subtle);
}

.timer-input:focus,
.timer-select:focus {
  background: var(--bg-paper);
  border-color: var(--cobalt);
  outline: none;
}

.billable-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  height: 36px;
  padding: 0 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.billable-toggle.is-active {
  color: var(--emerald-text);
  background: var(--emerald-tint);
  border-color: #86efac;
}

.timer-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  padding-left: var(--space-2);
  border-left: 1px solid var(--border);
}

.timer-readout {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0 var(--space-2);
}

.timer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-muted);
  flex-shrink: 0;
}

.timer-dot.is-running {
  background: var(--cobalt);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  animation: pulse-dot 1.8s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.86);
  }
}

.timer-clock {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  min-width: 5.5rem;
  text-align: right;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 36px;
  padding: 0 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.btn-cobalt {
  background: var(--cobalt);
  color: #ffffff;
  border-color: var(--cobalt);
}

.btn-cobalt:hover {
  background: var(--cobalt-hover);
  border-color: var(--cobalt-hover);
}

.btn-emerald {
  background: var(--emerald-btn);
  color: #ffffff;
  border-color: var(--emerald-btn);
}

.btn-emerald:hover {
  background: var(--emerald-hover);
  border-color: var(--emerald-hover);
}

.btn-ink {
  background: var(--ink);
  color: var(--bg-paper);
  border-color: var(--ink);
}

.btn-ink:hover {
  background: #2e2e34;
}

.btn-ghost {
  background: var(--bg-sheet);
  color: var(--ink);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  border-color: var(--ink-secondary);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: var(--bg-sheet);
  color: var(--ink);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 140ms ease;
}

.btn-icon:hover {
  background: var(--bg-subtle);
}

.mono-key {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 700;
}

.btn-link {
  background: none;
  border: none;
  padding: 0.25rem 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--cobalt);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-link:hover {
  color: var(--cobalt-hover);
}

.btn-inline {
  background: var(--bg-sheet);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.6rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.btn-inline:hover {
  background: var(--bg-subtle);
  border-color: var(--ink);
}

/* Main Desk Layout */
.desk-shell {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.ledger-header {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.ledger-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2) var(--space-6);
  border-bottom: 2px solid var(--border-strong);
  padding-bottom: var(--space-3);
}

.ledger-title-row h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.ledger-subtitle {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--ink-secondary);
}

/* Accounting KPI Strip (single ruled horizontal sheet, no nested cards) */
.kpi-strip {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--bg-sheet);
  border: 1px solid var(--border-strong);
}

.kpi-cell {
  padding: var(--space-4) var(--space-5);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.kpi-cell:last-child {
  border-right: none;
}

.kpi-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.kpi-value {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(1.35rem, 2vw, 1.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.2;
}

.kpi-value.kpi-emerald {
  color: var(--emerald-text);
}

.kpi-value.kpi-crimson {
  color: var(--crimson-text);
}

.kpi-meta {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

/* Asymmetric Two-Column Workspace */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: var(--space-6);
  align-items: start;
}

.ledger-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-width: 0;
}

/* Ledger Sheet Surface */
.ledger-sheet {
  background: var(--bg-sheet);
  border: 1px solid var(--border-strong);
  min-width: 0;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-subtle);
}

.sheet-title-wrap {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}

.sheet-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.sheet-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-secondary);
}

.sheet-shortcut-hint {
  font-size: 0.8125rem;
  color: var(--ink-secondary);
}

.sheet-hint {
  margin: 0;
  padding: var(--space-3) var(--space-5);
  font-size: 0.8125rem;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--border);
}

/* Client Retainer Burn List */
.retainer-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.retainer-item {
  border-bottom: 1px solid var(--border);
}

.retainer-item:last-child {
  border-bottom: none;
}

.retainer-btn {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  transition: background-color 140ms ease;
}

.retainer-btn:hover {
  background: var(--bg-paper);
}

.retainer-btn[aria-pressed="true"] {
  background: var(--cobalt-tint);
  box-shadow: inset 3px 0 0 var(--cobalt);
}

.retainer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.retainer-name-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.client-code,
.client-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.client-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.retainer-pct {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--emerald-text);
}

.retainer-pct.is-warn {
  color: var(--cobalt);
}

.retainer-pct.is-over {
  color: var(--crimson-text);
}

.retainer-meta,
.retainer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: 0.8125rem;
  color: var(--ink-secondary);
}

.retainer-foot {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.retainer-foot .is-over {
  color: var(--crimson-text);
  font-weight: 600;
}

.burn-track {
  position: relative;
  width: 100%;
  height: 9px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  overflow: hidden;
}

.burn-fill {
  height: 100%;
  transition: width 260ms ease, background-color 200ms ease;
}

.burn-fill.is-healthy {
  background: var(--emerald);
}

.burn-fill.is-warn {
  background: var(--cobalt);
}

.burn-fill.is-over {
  background: var(--crimson);
}

.retainer-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--bg-paper);
  font-size: 0.75rem;
  color: var(--ink-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  display: inline-block;
}

.legend-swatch.is-healthy {
  background: var(--emerald);
}

.legend-swatch.is-warn {
  background: var(--cobalt);
}

.legend-swatch.is-over {
  background: var(--crimson);
}

/* Quick-Entry Form */
.entry-form {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.entry-grid {
  display: grid;
  grid-template-columns: 165px minmax(180px, 1fr) 140px 104px;
  gap: var(--space-3);
  align-items: start;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-group label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-secondary);
}

.field-group input,
.field-group select {
  height: 38px;
  padding: 0 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--bg-paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 100%;
}

.field-group input[type="number"],
.field-group input[type="date"] {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
}

.field-group input:focus,
.field-group select:focus {
  background: var(--bg-sheet);
  border-color: var(--cobalt);
  outline: none;
}

.field-group input[aria-invalid="true"] {
  border-color: var(--crimson);
  background: var(--crimson-tint);
}

.field-error {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--crimson-text);
  line-height: 1.3;
}

.field-error:empty {
  display: none;
}

.entry-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.entry-submit-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Timesheet Controls */
.timesheet-controls {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 0.65rem;
  color: var(--ink-muted);
  pointer-events: none;
}

.search-input {
  height: 36px;
  width: 220px;
  padding: 0 0.75rem 0 2.1rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--ink);
  background: var(--bg-sheet);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.search-input:focus {
  border-color: var(--cobalt);
  outline: none;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sheet);
  overflow: hidden;
}

.seg-btn {
  height: 34px;
  padding: 0 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-secondary);
  background: transparent;
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
}

.seg-btn:last-child {
  border-right: none;
}

.seg-btn:hover {
  background: var(--bg-paper);
  color: var(--ink);
}

.seg-btn.is-active {
  background: var(--ink);
  color: var(--bg-paper);
}

.active-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  background: var(--cobalt-tint);
  border-bottom: 1px solid #bfdbfe;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--cobalt);
}

/* Ruled Accounting Tables */
.table-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.invoice-table th,
.invoice-table td {
  padding-inline: 0.6rem;
}

.ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.ledger-table thead th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-secondary);
  background: var(--bg-paper);
  border-bottom: 1px solid var(--border-strong);
  padding: 0.65rem var(--space-4);
  white-space: nowrap;
}

.ledger-table tbody td {
  padding: 0.75rem var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.ledger-table tbody tr:hover {
  background: var(--bg-paper);
}

.ledger-table tbody tr.is-new-row {
  animation: flash-row 1.2s ease;
}

@keyframes flash-row {
  0% {
    background: var(--emerald-tint);
  }
  100% {
    background: transparent;
  }
}

.ledger-table tfoot td {
  padding: 0.75rem var(--space-4);
  background: var(--bg-subtle);
  border-top: 1px solid var(--border-strong);
  font-weight: 700;
  font-size: 0.875rem;
}

.ledger-table thead th.num-col,
.ledger-table thead th.action-col {
  text-align: right;
}

.num-col {
  text-align: right;
}

.client-cell-value {
  display: inline-block;
  white-space: nowrap;
}

.client-cell-value .client-tag {
  margin-right: 0.35rem;
}

.mono-cell {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  white-space: nowrap;
}

.action-col {
  text-align: right;
  white-space: nowrap;
}

.sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
}

.sort-btn-right {
  justify-content: flex-end;
  width: 100%;
}

.sort-btn:hover,
.sort-btn.is-active {
  color: var(--ink);
}

.sort-arrow {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  line-height: 1;
  text-transform: none;
  color: var(--cobalt);
}

/* Status Pills */
.status-pill,
.inv-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill-billable {
  color: var(--emerald-text);
  background: var(--emerald-tint);
  border-color: #bbf7d0;
  cursor: pointer;
}

.pill-internal {
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  border-color: var(--border);
  cursor: pointer;
}

.inv-pill.is-draft {
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  border-color: var(--border);
}

.inv-pill.is-sent {
  color: var(--cobalt);
  background: var(--cobalt-tint);
  border-color: #bfdbfe;
}

.inv-pill.is-paid {
  color: var(--emerald-text);
  background: var(--emerald-tint);
  border-color: #bbf7d0;
}

.inv-pill.is-overdue {
  color: var(--crimson-text);
  background: var(--crimson-tint);
  border-color: #fecaca;
}

.row-delete-btn {
  background: none;
  border: none;
  padding: 0.25rem 0.4rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-muted);
  cursor: pointer;
}

.row-delete-btn:hover {
  color: var(--crimson);
  text-decoration: underline;
}

.muted-action {
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

/* Invoice Filter Tabs */
.invoice-filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  height: 34px;
  padding: 0 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-secondary);
  background: var(--bg-sheet);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.filter-tab:hover {
  color: var(--ink);
  border-color: var(--ink-secondary);
}

.filter-tab.is-active {
  background: var(--ink);
  color: var(--bg-paper);
  border-color: var(--ink);
}

.tab-count {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  opacity: 0.8;
}

/* Empty State */
.empty-state {
  padding: var(--space-8) var(--space-5);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  color: var(--ink-secondary);
}

.empty-state[hidden] {
  display: none;
}

.empty-title {
  margin: var(--space-2) 0 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.empty-desc {
  margin: 0;
  max-width: 440px;
  font-size: 0.875rem;
  color: var(--ink-secondary);
}

.empty-actions {
  margin-top: var(--space-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Footer */
.desk-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-paper);
}

.desk-footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: 0.8125rem;
  color: var(--ink-muted);
}

/* Keyboard Shortcuts Popover Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(24, 24, 27, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-sheet);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-modal);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg-subtle);
}

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.shortcut-list {
  margin: 0;
  padding: var(--space-2) var(--space-5) var(--space-4);
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-row dt {
  color: var(--ink);
}

.shortcut-row dd {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.key-sep {
  font-size: 0.75rem;
  color: var(--ink-muted);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 130;
  background: var(--ink);
  color: var(--bg-paper);
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 28px rgba(24, 24, 27, 0.22);
  max-width: min(380px, calc(100vw - 2rem));
}

.toast[hidden] {
  display: none;
}

/* Responsive Breakpoints */
@media (max-width: 1120px) {
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .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(--border);
  }
}

@media (max-width: 820px) {
  .topbar {
    position: static;
  }

  .topbar-inner {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }

  .brand-group {
    order: 1;
  }

  .topbar-actions {
    order: 2;
    margin-left: auto;
  }

  .timer-bar {
    order: 3;
    flex: 1 1 100%;
    flex-direction: column;
    align-items: stretch;
    padding: var(--space-2);
  }

  .timer-fields {
    flex-wrap: wrap;
  }

  .timer-select {
    max-width: none;
    flex: 1 1 180px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .timer-input {
    flex: 1 1 200px;
  }

  .timer-controls {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: var(--space-2);
    justify-content: space-between;
  }

  .entry-grid {
    grid-template-columns: 1fr 1fr;
  }

  .field-task {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .desk-shell {
    padding: var(--space-4) var(--space-3) var(--space-6);
  }

  .kpi-strip {
    grid-template-columns: 1fr;
  }

  .kpi-cell {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .kpi-cell:last-child {
    border-bottom: none;
  }

  .entry-grid {
    grid-template-columns: 1fr;
  }

  .search-input {
    width: 100%;
  }

  .timesheet-controls {
    width: 100%;
  }

  .search-wrap {
    flex: 1 1 100%;
  }

  /* 44px touch targets on mobile */
  .btn,
  .btn-icon,
  .billable-toggle,
  .filter-tab,
  .seg-btn,
  .timer-select,
  .timer-input,
  .field-group input,
  .field-group select,
  .search-input {
    min-height: 44px;
  }

  .btn-icon {
    min-width: 44px;
  }

  /* Stack table rows cleanly on narrow screens */
  .ledger-table thead {
    display: none;
  }

  .ledger-table,
  .ledger-table tbody,
  .ledger-table tr,
  .ledger-table td,
  .ledger-table tfoot {
    display: block;
    width: 100%;
  }

  .ledger-table tbody tr {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-strong);
  }

  .ledger-table tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3);
    padding: 0.3rem 0;
    border-bottom: none;
    text-align: right;
  }

  .ledger-table tbody td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--ink-muted);
    text-align: left;
    flex-shrink: 0;
    padding-top: 0.1rem;
  }

  .ledger-table tbody td.action-col {
    align-items: center;
  }

  .ledger-table tbody td.action-col::before {
    content: "";
    padding-top: 0;
  }

  .ledger-table tfoot .ledger-total-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
  }

  .ledger-table tfoot td {
    width: auto;
    padding: 0.2rem 0;
    border-top: none;
  }

  .ledger-table tfoot td:empty {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .timer-dot.is-running,
  .ledger-table tbody tr.is-new-row {
    animation: none;
  }

  .burn-fill,
  .btn,
  .retainer-btn,
  .filter-tab,
  .billable-toggle {
    transition: none;
  }
}
