/* ===== Nobody-Tech Invoice — developer-grade theme ===== */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #eceef1;
  --text: #11151c;
  --text-muted: #5c6573;
  --text-faint: #8b93a1;
  --line: #e4e7ec;
  --line-strong: #d3d8e0;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0fe;
  --accent-text: #4338ca;

  --danger: #dc2626;
  --danger-soft: #fdecec;
  --danger-text: #b42121;
  --success: #059669;
  --success-soft: #e6f6f0;
  --success-text: #047857;
  --warning: #d97706;
  --warning-soft: #fdf1e0;
  --warning-text: #b45c08;

  --radius-sm: 7px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.22);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);

  --sidebar-w: 232px;
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Cascadia Code", ui-monospace, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  --bg: #0b0d11;
  --surface: #14171d;
  --surface-2: #1a1e26;
  --surface-3: #222732;
  --text: #e7eaf0;
  --text-muted: #9aa3b2;
  --text-faint: #6b7382;
  --line: #262b34;
  --line-strong: #323845;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: #1c2030;
  --accent-text: #aab1ff;

  --danger: #ef4444;
  --danger-soft: #2a181a;
  --danger-text: #f8a5a5;
  --success: #10b981;
  --success-soft: #14241f;
  --success-text: #6ee7b7;
  --warning: #f59e0b;
  --warning-soft: #2a2114;
  --warning-text: #fcd34d;

  --ring: 0 0 0 3px rgba(99, 102, 241, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: .95rem; margin: 0 0 .7rem; }

input, textarea, select, button { font: inherit; }

label {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  font-size: .8rem;
  font-weight: 550;
  color: var(--text-muted);
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: .5rem .6rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .12s ease, box-shadow .12s ease;
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

input[readonly] { background: var(--surface-2); color: var(--text-muted); }
textarea { resize: vertical; }

/* ===== Buttons ===== */
button {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .5rem .9rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: background .12s ease, border-color .12s ease, color .12s ease, transform .05s ease;
}

button:hover { background: var(--accent-hover); }
button:active { transform: translateY(.5px); }
button:focus-visible { outline: none; box-shadow: var(--ring); }

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

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: .34rem .66rem; font-size: .8rem; }

.remove-item-btn {
  background: transparent;
  color: var(--danger-text);
  border-color: var(--line);
}
.remove-item-btn:hover { background: var(--danger-soft); border-color: var(--danger-soft); }

/* ===== Auth ===== */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--bg);
}

.auth-card {
  width: min(100%, 400px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow);
}

.auth-mark {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.2rem;
  margin-bottom: 1rem;
}

.auth-card h1 { margin: 0 0 .15rem; font-size: 1.3rem; }
.auth-subtitle { margin: 0 0 1.5rem; color: var(--text-muted); font-size: .9rem; }
.auth-form h2 { margin: 0 0 1rem; font-size: 1.05rem; }
.auth-form label { margin-bottom: .8rem; }
.auth-form button { width: 100%; margin-top: .5rem; }
.auth-hint { margin: 0 0 1rem; color: var(--text-muted); font-size: .85rem; }
.form-error { color: var(--danger-text); font-size: .82rem; margin-top: .6rem; }

/* ===== App shell ===== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  padding: 1rem .75rem;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .35rem .5rem 1rem;
}

.brand-mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem;
}

.brand-name { font-weight: 700; letter-spacing: -0.01em; }

.sidebar-nav { display: flex; flex-direction: column; gap: .15rem; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text-muted);
  border: 0;
  border-radius: var(--radius-sm);
  padding: .5rem .6rem;
  font-weight: 550;
}

.nav-item svg { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 650;
}

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

.footer-btn {
  display: flex;
  align-items: center;
  gap: .55rem;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--line);
  font-weight: 550;
  font-size: .82rem;
}
.footer-btn:hover { background: var(--surface-2); color: var(--text); }
.footer-btn svg { width: 17px; height: 17px; fill: currentColor; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: inline-block; }

.user-chip {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text);
  padding: .1rem .15rem;
}

.user-avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .75rem;
  text-transform: uppercase;
}

.footer-actions { display: flex; gap: .4rem; }
.footer-actions .btn-sm { flex: 1; }

/* ===== Content ===== */
.app-content { min-width: 0; }

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1.75rem 3rem;
  display: grid;
  gap: 1.1rem;
}

.workspace-view { display: none; }
.workspace-view.active { display: grid; gap: 1.1rem; }

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-subtitle {
  margin: .25rem 0 0;
  color: var(--text-muted);
  font-size: .85rem;
  font-weight: 450;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .8rem;
  margin-bottom: .85rem;
}
.section-heading.compact { margin-bottom: .35rem; }
.section-heading h2, .section-heading h3 { margin: 0; }

.grid { display: grid; gap: .85rem; margin-bottom: .9rem; }
.grid:last-child { margin-bottom: 0; }
.two-col { grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); }
.three-col { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }
.four-col { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ===== Dashboard ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .85rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  position: relative;
  box-shadow: var(--shadow);
}

.stat-card::before {
  content: "";
  position: absolute;
  left: 0; top: 1rem; bottom: 1rem;
  width: 3px;
  border-radius: 3px;
  background: var(--text-faint);
}
.stat-primary::before { background: var(--accent); }
.stat-danger::before { background: var(--danger); }
.stat-success::before { background: var(--success); }
.stat-neutral::before { background: var(--warning); }

.stat-label {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .35rem;
  padding-left: .6rem;
}
.stat-card strong { display: block; font-size: 1.5rem; font-weight: 650; padding-left: .6rem; }

.task-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .85rem;
}

.action-tile {
  display: block;
  text-align: left;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.action-tile:hover { border-color: var(--accent); background: var(--surface); }

.tile-icon {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-text);
  margin-bottom: .6rem;
}
.tile-icon svg { width: 18px; height: 18px; fill: currentColor; }
.action-tile strong { display: block; font-size: .92rem; margin-bottom: .2rem; }
.tile-copy { display: block; font-size: .8rem; color: var(--text-muted); font-weight: 400; }

.dashboard-panels { margin-bottom: 0; }
.list-panel { background: var(--surface); }

.task-list, .compact-list { list-style: none; margin: 0; padding: 0; }

.task-list li, .compact-list li {
  border-bottom: 1px solid var(--line);
  padding: .65rem 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .7rem;
  font-size: .86rem;
}
.task-list li:last-child, .compact-list li:last-child { border-bottom: 0; }
.compact-list li { color: var(--text-muted); }

.task-item-main { display: grid; gap: .2rem; }
.task-item-title { font-weight: 600; color: var(--text); }
.task-item-meta { color: var(--text-muted); font-size: .8rem; }
.task-item-actions { display: flex; gap: .35rem; flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning-text);
  padding: .2rem .55rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* ===== Documents and forms ===== */
.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(130px, auto) minmax(140px, auto);
  gap: .55rem;
  margin-bottom: 1rem;
}

.documents-list { list-style: none; margin: 0; padding: 0; }

.documents-list li {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: .55rem;
  padding: .8rem .9rem;
  background: var(--surface);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .95rem;
  flex-wrap: wrap;
  transition: border-color .12s ease;
}
.documents-list li:last-child { margin-bottom: 0; }
.documents-list li:hover { border-color: var(--line-strong); }

.documents-list strong { font-size: .9rem; }
.doc-meta { color: var(--text-muted); font-size: .82rem; margin-top: .15rem; }
.doc-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.doc-id-label { font-size: .78rem; color: var(--text-faint); font-family: var(--mono); word-break: break-all; }

.editor-panel .form-block {
  border-top: 1px solid var(--line);
  margin-top: 1.1rem;
  padding-top: 1.1rem;
}
.editor-panel .form-block:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }

.items-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  margin-bottom: .8rem;
}

table { width: 100%; border-collapse: collapse; }

th, td {
  border-bottom: 1px solid var(--line);
  padding: .5rem .6rem;
  vertical-align: top;
}
tr:last-child td { border-bottom: 0; }

th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: .74rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  text-align: left;
}
th.col-num { text-align: right; }

#itemsBody input { border-color: transparent; background: transparent; padding: .35rem .4rem; }
#itemsBody input:focus { border-color: var(--accent); background: var(--surface); }

.item-total-cell {
  min-width: 90px;
  white-space: nowrap;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  padding-top: .7rem;
}

.totals-notes { align-items: stretch; }

.totals {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: 1rem;
  align-self: start;
}
.totals p {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: .4rem 0;
  color: var(--text-muted);
  font-size: .86rem;
}
.totals p strong { color: var(--text); font-weight: 600; }
.totals .grand-total {
  margin-top: .7rem;
  padding-top: .7rem;
  border-top: 1px solid var(--line-strong);
  font-size: 1rem;
}
.totals .grand-total span { color: var(--text); font-weight: 600; }
.totals .grand-total strong { font-size: 1.15rem; color: var(--accent-text); }

.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .7rem; }

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: 1rem -1.15rem -1.15rem;
  padding: .85rem 1.15rem;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.payments-panel { border-top: 1px solid var(--line); padding-top: 1.1rem; margin-top: 1.1rem; }
.payment-balance {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: .8rem;
  color: var(--text-muted);
  font-size: .85rem;
}
.payment-balance strong { color: var(--text); margin-left: .25rem; }

/* ===== Customers / settings ===== */
.customer-list { margin-top: .55rem; }

.detail-list {
  display: grid;
  grid-template-columns: minmax(110px, auto) 1fr;
  gap: .35rem .9rem;
  margin: 0;
  font-size: .85rem;
}
.detail-list dt {
  color: var(--text-muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  align-self: start;
}
.detail-list dd {
  margin: 0;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.customer-code {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .02em;
  color: var(--text-muted);
  background: var(--surface-2, rgba(127, 127, 127, .12));
  border-radius: 4px;
  padding: .05rem .3rem;
  margin-right: .15rem;
}

.contact-form {
  margin-top: .9rem;
  padding-top: .9rem;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.contact-form h4 { margin: 0; font-size: .9rem; }
.contact-primary-label {
  flex-direction: row;
  align-items: center;
  gap: .45rem;
  font-size: .85rem;
}
.contact-primary-label input { width: auto; }

/* ===== Tags (Phase 5b) ===== */
.tag-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: .3rem 0 .8rem;
}
.tag-empty { font-size: .85rem; color: var(--text-muted); }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .25rem .2rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-text);
}
.tag-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px; height: 16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  font-size: .85rem;
  line-height: 1;
  cursor: pointer;
  color: inherit;
  background: rgba(127, 127, 127, .22);
}
.tag-chip-remove:hover { background: rgba(127, 127, 127, .4); }
.tag-add-form {
  display: flex;
  gap: .5rem;
  align-items: center;
}
.tag-add-form input { flex: 1; min-width: 0; }

.status-filter {
  font-size: .78rem;
  padding: .25rem .5rem;
  width: auto;
}

/* ===== Activity / notes timeline (Phase 5c) ===== */
.note-add-form {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin-bottom: 1rem;
}
.note-add-form textarea { width: 100%; resize: vertical; }
.note-form-actions { display: flex; gap: .5rem; align-items: center; }

.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .55rem 0;
  border-bottom: 1px solid var(--line);
}
.activity-item:last-child { border-bottom: 0; }
.activity-marker {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  margin-top: .1rem;
  border-radius: 50%;
  font-size: .8rem;
  line-height: 1;
  color: var(--text-muted);
  background: var(--surface-2, rgba(127, 127, 127, .12));
}
.activity-note .activity-marker { color: var(--accent-text); background: var(--accent-soft); }
.activity-main { flex: 1; min-width: 0; }
.activity-text { font-size: .88rem; white-space: pre-wrap; word-break: break-word; }
.activity-item .doc-actions { flex: 0 0 auto; }

/* ===== Attachments (Phase 5d) ===== */
.attachment-upload-form {
  display: flex;
  gap: .5rem;
  align-items: center;
  margin-bottom: .75rem;
}
.attachment-upload-form input[type="file"] {
  flex: 1;
  min-width: 0;
  font-size: .85rem;
  color: var(--text-muted);
}

.customer-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(270px, .75fr);
  gap: 1.1rem;
  align-items: start;
}

.customer-form, .customer-list-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: var(--surface-2);
}

.file-label input { border: 0; padding: .4rem 0; background: transparent; }

.logo-preview-wrap {
  margin: .7rem 0 0;
  display: flex;
  align-items: center;
  gap: .7rem;
  font-size: .82rem;
  color: var(--text-muted);
}
.logo-preview-wrap img {
  max-height: 54px; max-width: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  background: var(--surface);
}

/* ===== PDF accent colour (Phase 6) ===== */
.accent-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .3rem 0 .85rem;
}
.accent-swatch {
  width: 30px; height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  box-shadow: none;
}
.accent-swatch:hover { border-color: var(--text-faint); }
.accent-swatch.is-selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text);
}
.accent-custom {
  display: flex;
  align-items: flex-end;
  gap: .6rem;
}
.accent-custom label { flex: 0 1 220px; }
.accent-custom input[type="color"] {
  width: 42px; height: 38px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.accent-preview {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--accent);
}

/* ===== Status badges ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .16rem .5rem;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.status-badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.status-draft { background: var(--surface-3); color: var(--text-muted); }
.status-sent { background: var(--accent-soft); color: var(--accent-text); }
.status-accepted { background: var(--success-soft); color: var(--success-text); }
.status-rejected { background: var(--danger-soft); color: var(--danger-text); }
.status-paid { background: var(--success-soft); color: var(--success-text); }
.status-overdue { background: var(--warning-soft); color: var(--warning-text); }
.status-void { background: var(--surface-3); color: var(--text-faint); text-decoration: line-through; }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  border-radius: var(--radius-md);
  background: var(--text);
  color: var(--surface);
  padding: .7rem 1.1rem;
  font-size: .85rem;
  font-weight: 550;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  animation: toastIn .2s ease;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

/* ===== Command palette ===== */
.command-palette {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 1rem 1rem;
}
.command-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  backdrop-filter: blur(2px);
}
.command-box {
  position: relative;
  width: min(100%, 580px);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  animation: toastIn .14s ease;
}
.command-box input {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 1rem 1.1rem;
  font-size: 1rem;
  background: var(--surface);
}
.command-box input:focus { box-shadow: none; border-color: var(--line); }
.command-results {
  list-style: none;
  margin: 0;
  padding: .4rem;
  overflow-y: auto;
}
.command-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .55rem .7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.command-item.active, .command-item:hover { background: var(--surface-2); }
.command-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.command-label { font-weight: 550; color: var(--text); }
.command-hint {
  font-size: .8rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.command-kind {
  flex-shrink: 0;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  padding: .15rem .45rem;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-muted);
}
.command-kind.kind-action, .command-kind.kind-nav {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.command-empty { padding: 1rem .7rem; color: var(--text-muted); font-size: .88rem; text-align: center; }
.command-foot {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .55rem .9rem;
  border-top: 1px solid var(--line);
  font-size: .72rem;
  color: var(--text-faint);
}
.command-foot-tip { margin-left: auto; }
.command-foot kbd {
  font-family: var(--mono);
  font-size: .7rem;
  padding: .05rem .3rem;
  margin-right: .15rem;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--text-muted);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-brand { padding: .25rem .5rem; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
  .nav-item { width: auto; }
  .sidebar-footer {
    margin-top: 0;
    flex-direction: row;
    align-items: center;
    border-top: 0;
    padding-top: 0;
  }
  .layout { padding: 1.25rem; }
}

@media (max-width: 620px) {
  .filter-bar, .customer-layout { grid-template-columns: 1fr; }
  .documents-list li { align-items: flex-start; flex-direction: column; }
  .nav-item span { display: none; }
  .footer-btn .theme-label { display: none; }
  .section-heading { flex-direction: column; align-items: flex-start; }
  .task-list li, .compact-list li { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
