/* ============================================================
   Orçamentos - app shell
   Dark navy #181d2a + lime #8ffa04, from the owner's reference
   design (assets/original-*.webp). Operate mode.
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #181d2a;
  --surface: #1f2738;
  --surface-2: #2d3545;
  --surface-3: #343e52;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f9fafa;
  --text-2: #9ba3b5;
  --text-3: #949daf;   /* lightened for WCAG AA (>=4.5:1) on --bg/--surface */
  --accent: #8ffa04;
  --accent-ink: #131a0a;
  --blue: #4e95d9;
  --red: #ff7b7b;
  --amber: #ffc061;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28), 0 2px 8px rgba(0, 0, 0, 0.18);
  font-size: 16px;
}

* { box-sizing: border-box; }

/* ---- Themed scrollbars (site-wide) ----------------------------- */
/* Brand-lime thumbs on the dark theme: visible but elegant, comfortable
   width (12px pill ~6px visible) that never overpowers the content.
   Firefox uses scrollbar-color; Chromium/Safari the -webkit rules. */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(143, 250, 4, 0.5) transparent;
}
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(143, 250, 4, 0.5);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(143, 250, 4, 0.85);
  background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: transparent; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: rgba(143, 250, 4, 0.28); }

.ico { display: inline-flex; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---- App frame ------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---- Sidebar ---------------------------------------------------- */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.brand-name {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
  line-height: 1.2;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.02em;
  margin-top: 1px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.nav-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--text-2);
  font-weight: 600;
  font-size: 13.5px;
  border: 1px solid transparent;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: rgba(143, 250, 4, 0.12);
  color: var(--accent);
  border-color: rgba(143, 250, 4, 0.22);
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.03);
}
.sidebar-foot .who {
  font-weight: 700;
  font-size: 13px;
  color: var(--text);
}
.sidebar-foot .what {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
  line-height: 1.4;
}

/* ---- Main ------------------------------------------------------- */

.main {
  padding: 26px 30px 48px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}
.page-sub {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ============================================================
   Design system - form controls & components
   A universal themed base (zero specificity via :where, so any
   context rule refines on top) plus opt-in component classes.
   ============================================================ */

/* ---- Universal base: every control inherits the theme --------------- */
:where(input:not([type='checkbox']):not([type='radio']):not([type='hidden']),
       select, textarea) {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
:where(input:not([type='checkbox']):not([type='radio']):not([type='hidden']),
       select, textarea)::placeholder { color: var(--text-3); opacity: 1; }
:where(input:not([type='checkbox']):not([type='radio']):not([type='hidden']),
       select, textarea):focus {
  outline: none;
  border-color: rgba(143, 250, 4, 0.55);
  box-shadow: 0 0 0 3px rgba(143, 250, 4, 0.08);
}
input[type='color'] {
  height: 40px;
}
textarea { resize: vertical; min-height: 74px; line-height: 1.5; }

/* Selects get a themed chevron instead of the native arrow */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23949daf' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  cursor: pointer;
}
select option { background: var(--surface); color: var(--text); }

/* ---- Component classes (opt-in, DRY) ---------------------------------- */
.input, .select, .textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: rgba(143, 250, 4, 0.55);
  box-shadow: 0 0 0 3px rgba(143, 250, 4, 0.08);
}
.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23949daf' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  cursor: pointer;
}
.textarea { resize: vertical; min-height: 74px; line-height: 1.5; }

/* Checkboxes / radios - custom, theme-matched */
.checkbox, .radio {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  user-select: none;
}
.checkbox input, .radio input { position: absolute; opacity: 0; width: 0; height: 0; }
.checkbox .box, .radio .dot {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  border: 1.5px solid var(--border-strong);
  background: var(--bg);
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.checkbox .box::after {
  content: '';
  width: 9px;
  height: 5px;
  border-left: 2px solid var(--accent-ink);
  border-bottom: 2px solid var(--accent-ink);
  transform: rotate(-45deg) translate(1px, -1px);
  opacity: 0;
  transition: opacity 0.12s ease;
}
.checkbox input:checked + .box { background: var(--accent); border-color: var(--accent); }
.checkbox input:checked + .box::after { opacity: 1; }
.checkbox input:focus-visible + .box,
.radio input:focus-visible + .dot { box-shadow: 0 0 0 3px rgba(143, 250, 4, 0.15); }
.radio .dot { border-radius: 50%; }
.radio .dot::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.12s ease;
}
.radio input:checked + .dot { border-color: var(--accent); }
.radio input:checked + .dot::after { opacity: 1; }

/* Toggle switch - used by .mode-option admin toggles */
.mode-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.mode-option input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  width: 34px;
  height: 19px;
  margin: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.mode-option input[type='checkbox']::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  background: var(--text-2);
  border-radius: 50%;
  transition: transform 0.15s ease, background 0.15s ease;
}
.mode-option input[type='checkbox']:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.mode-option input[type='checkbox']:checked::after {
  transform: translateX(15px);
  background: var(--accent-ink);
}
.mode-option input[type='checkbox']:focus-visible {
  outline: 2px solid rgba(143, 250, 4, 0.5);
  outline-offset: 2px;
}

/* Accordion - works with <details>/<summary> natively and with
   .accordion > .accordion-head toggling .open (delegated in app.js) */
.accordion { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.accordion > .accordion-head,
.accordion > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.accordion > summary::-webkit-details-marker { display: none; }
.accordion > .accordion-head::after,
.accordion > summary::after {
  content: '';
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-3);
  border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  flex: 0 0 auto;
}
.accordion.open > .accordion-head::after,
.accordion[open] > summary::after { transform: rotate(-135deg); }
.accordion .accordion-panel { padding: 0 14px 14px; }

/* ---- Search ------------------------------------------------------- */

.search {
  position: relative;
  width: 260px;
}
/* The .ico wrapper is inline-flex and would add a 21px line box, making the
   container taller than the input - the icon then centers against the wrapper
   instead of the input. Pin it to the container so the height matches. */
.search .ico {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-3);
  pointer-events: none;
}
.search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px 8px 34px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus {
  outline: none;
  border-color: rgba(143, 250, 4, 0.55);
}

/* ---- Buttons ------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  min-height: 40px;
  min-width: 40px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.05s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { text-decoration: none; background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 700;
}
.btn-primary:hover { background: #a2ff2e; color: var(--accent-ink); }
.btn-primary:focus-visible { outline-color: var(--accent); }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

.btn-danger:hover { background: rgba(255, 123, 123, 0.12); border-color: rgba(255, 123, 123, 0.4); color: var(--red); }

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  color: var(--text-2);
}
.btn-icon svg { width: 17px; height: 17px; }
.btn-icon:hover { color: var(--text); background: var(--surface-2); }

/* ---- Metrics -------------------------------------------------------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.metrics .metric:nth-child(5) { display: none; }
@media (min-width: 861px) and (max-width: 1360px) {
  .metrics { grid-template-columns: repeat(4, 1fr); }
  .metrics .metric:nth-child(5) { display: block; }
}

/* ---- Dashboard (index) -------------------------------------------------- */

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.recent-list { display: flex; flex-direction: column; gap: 6px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s ease, background .15s ease;
}
.recent-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.recent-num { font-weight: 700; font-size: 13px; min-width: 96px; }
.recent-client { flex: 1; min-width: 0; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-client small { color: var(--text-3); }
.recent-total { font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.quick-actions { display: flex; flex-direction: column; gap: 10px; }
.quick-actions .btn { justify-content: flex-start; }
.quick-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  margin-left: auto;
  border-radius: 999px;
  background: var(--amber, #f5b63f); color: #1a1405;
  font-size: 11.5px; font-weight: 800;
}
@media (max-width: 980px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .recent-item { flex-wrap: wrap; row-gap: 4px; }
  .recent-num { min-width: 0; }
  .recent-client { flex-basis: 100%; order: 3; }
  .recent-item .badge { order: 2; }
}

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.metric-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric-label svg { width: 14px; height: 14px; color: var(--text-3); }
.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 6px;
  line-height: 1.1;
  color: var(--text);
}
.metric-value.accent { color: var(--accent); }
.metric-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 5px;
}
.metric-sub .up { color: var(--accent); }
.metric-sub .down { color: var(--red); }

/* ---- Filters -------------------------------------------------------- */

.filters {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
}
.tab {
  border: none;
  background: transparent;
  color: var(--text-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 15px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab:hover { color: var(--text); }
.tab.active {
  background: var(--surface-3);
  color: var(--text);
}

.filter-count {
  font-size: 12.5px;
  color: var(--text-3);
}
.filter-count b { color: var(--text-2); font-weight: 700; }

.clear-filters {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--accent);
  background: rgba(143, 250, 4, 0.1);
  border: 1px solid rgba(143, 250, 4, 0.25);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
}
.clear-filters:hover { background: rgba(143, 250, 4, 0.18); }
.clear-filters svg { width: 13px; height: 13px; }
.clear-filters[hidden] { display: none; }

/* ---- Table ---------------------------------------------------------- */

.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-wrap { overflow-x: auto; }
/* Thin brand scrollbar in scrollable tables (reports, transactions),
   matching the drawer/cookie-modal treatment - 6px on the horizontal axis. */
.table-wrap {
  scrollbar-width: thin;
  scrollbar-color: rgba(143, 250, 4, 0.45) transparent;
}
.table-wrap::-webkit-scrollbar { width: 6px; height: 6px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(143, 250, 4, 0.45);
  border-radius: 99px;
  border: none;
}
.table-wrap::-webkit-scrollbar-thumb:hover { background: rgba(143, 250, 4, 0.8); }

table.list {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}
table.list th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.list th.right { text-align: right; }
table.list td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: middle;
}
table.list tr:last-child td { border-bottom: none; }
table.list tbody tr {
  transition: background 0.12s ease;
}
table.list tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
table.list tbody tr.clickable { cursor: pointer; }

.cell-number { font-weight: 700; color: var(--text); white-space: nowrap; }
.cell-client { color: var(--text); font-weight: 600; }
.cell-client .sub { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; }
.cell-num { text-align: right; font-weight: 700; color: var(--text); white-space: nowrap; }
.cell-muted { color: var(--text-2); white-space: nowrap; }

.row-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  opacity: 0.35;
  transition: opacity 0.15s ease;
}
tbody tr:hover .row-actions,
.row-actions:focus-within { opacity: 1; }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-rascunho { color: var(--text-2); background: rgba(255, 255, 255, 0.06); }
.badge-enviado { color: #7db8e8; background: rgba(78, 149, 217, 0.16); }
.badge-aprovado { color: #b2e96b; background: rgba(143, 250, 4, 0.13); }
.badge-expirado { color: #ff9d9d; background: rgba(255, 123, 123, 0.14); }

/* ---- Admin scope + pagination --------------------------------------- */

.scope-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
}
.scope-row select {
  flex: 1;
  min-width: 0;
  max-width: 420px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 11px;
}
.scope-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-2);
  white-space: nowrap;
}
.scope-label svg { width: 15px; height: 15px; color: var(--accent); }

.check-line {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.check-line input { accent-color: var(--accent); width: 15px; height: 15px; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}
.pagination .pg-info {
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 600;
  min-width: 110px;
  text-align: center;
}

.cell-owner { color: var(--text-2); white-space: nowrap; }

/* ---- Empty state ----------------------------------------------------- */

.empty {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-2);
}
.empty-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: rgba(143, 250, 4, 0.1);
  border: 1px solid rgba(143, 250, 4, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.empty-mark svg { width: 26px; height: 26px; }
.empty-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-text { font-size: 13.5px; max-width: 420px; margin: 0 auto 18px; }

/* ---- Toast ----------------------------------------------------------- */

.toast-wrap {
  position: fixed;
  right: 22px;
  bottom: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toast-in 0.22s ease-out;
  max-width: 360px;
}
.toast.ok svg { color: var(--accent); }
.toast.err svg { color: var(--red); }
.toast svg { width: 18px; height: 18px; flex: 0 0 auto; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Confirm dialog ---------------------------------------------------- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.66);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.dialog {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.dialog-title { font-size: 16px; font-weight: 700; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.dialog-icon { display: inline-flex; }
.dialog-icon svg { width: 18px; height: 18px; }
.dialog-info .dialog-icon svg { color: var(--accent); }
.dialog-success .dialog-icon svg { color: var(--accent); }
.dialog-warning .dialog-icon svg { color: var(--amber); }
.dialog-error .dialog-icon svg,
.dialog-danger .dialog-icon svg { color: var(--red); }
.dialog-text { color: var(--text-2); font-size: 13.5px; margin: 0 0 18px; }
.dialog-type-label { display: block; font-size: 12.5px; color: var(--text-2); margin: 0 0 6px; }
.dialog-type {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 18px;
}
.dialog-type.dialog-prompt {
  min-height: 64px;
  resize: vertical;
  background: var(--bg, #11131c);
  border: 1px solid var(--border-strong, #262b3a);
  border-radius: var(--radius-sm, 10px);
  color: var(--text, #f4f6fb);
  font-family: inherit;
  font-size: 13.5px;
  padding: 10px 12px;
  line-height: 1.5;
}
.dialog-type.dialog-prompt:focus { outline: none; border-color: rgba(143, 250, 4, 0.55); }
.dialog .btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---- Forms (settings / editor) ------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-grid .span-2 { grid-column: span 2; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.field label .req { color: var(--accent); }
.field input[type='text'],
.field input[type='number'],
.field input[type='date'],
.field input[type='tel'],
.field input[type='email'],
.field textarea {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  width: 100%;
  transition: border-color 0.15s ease;
}
.field select {
  background-color: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 34px 9px 12px; /* right room for the themed chevron */
  width: 100%;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23949daf' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  transition: border-color 0.15s ease;
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: rgba(143, 250, 4, 0.55);
}
.field textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
.field .hint { font-size: 11.5px; color: var(--text-3); }

.section-card, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.section-card > h2, .card > h2 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.section-card > .sec-sub, .card > .sec-sub {
  font-size: 12.5px;
  color: var(--text-3);
  margin: 0 0 16px;
}

/* Logo picker */
.logo-picker {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.logo-preview {
  width: 150px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-preview img { max-width: 100%; height: auto; display: block; }
.logo-preview .placeholder {
  color: #999;
  font-size: 12px;
  text-align: center;
  padding: 18px 8px;
}

/* Item editor rows */
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 92px 120px 72px 40px 40px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.item-row input {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 11px;
  width: 100%;
}
.item-row input:focus { outline: none; border-color: rgba(143, 250, 4, 0.55); }
.item-row .row-total {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Observations rows */
.obs-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px 96px auto 40px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.obs-row[data-type="free"] { grid-template-columns: minmax(0, 1fr) 128px 40px; }
.obs-row[data-type="free"] .obs-pct,
.obs-row[data-type="free"] .obs-fixed,
.obs-row[data-type="free"] .obs-amount,
.obs-row[data-type="percent"] .obs-fixed,
.obs-row[data-type="fixed"] .obs-pct { display: none; }
.obs-row input, .obs-row select {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 8px 11px;
  width: 100%;
}
.obs-row select {
  padding: 8px 30px 8px 11px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23949daf' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
}
.obs-row input:focus, .obs-row select:focus { outline: none; border-color: rgba(143, 250, 4, 0.55); }
.obs-row .obs-amount {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  text-align: right;
  white-space: nowrap;
}
.obs-row .obs-amount:empty { display: none; }

.add-row-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px dashed var(--border-strong);
  color: var(--text-2);
  border-radius: 10px;
  padding: 9px 14px;
  min-height: 38px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.add-row-btn:hover { border-color: rgba(143, 250, 4, 0.5); color: var(--accent); }
.add-row-btn svg { width: 15px; height: 15px; }

.remove-row {
  width: 40px;
  height: 40px;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  justify-self: end;
}
.remove-row svg { width: 16px; height: 16px; }
.remove-row:hover { background: rgba(255, 123, 123, 0.12); color: var(--red); }

/* ---- Attachments (quote page + editor) ------------------------------ */

.doc-attachments {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.doc-attachments .att-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  margin-right: 4px;
}
.doc-attachments .att-title svg { width: 14px; height: 14px; color: var(--accent); }
.att-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s ease, background 0.15s ease;
  max-width: 260px;
}
.att-chip svg { width: 13px; height: 13px; color: var(--text-3); flex: 0 0 auto; }
.att-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip:hover { border-color: rgba(143, 250, 4, 0.5); background: rgba(143, 250, 4, 0.06); color: var(--accent); }
.att-chip:hover svg { color: var(--accent); }

.att-zone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
}
.att-zone[data-locked] { opacity: 0.55; pointer-events: none; }
.att-hint { font-size: 12px; color: var(--text-3); }
.att-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.att-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
}
.att-row .att-ico { display: inline-flex; color: var(--text-3); flex: 0 0 auto; }
.att-row .att-ico svg { width: 16px; height: 16px; }
.att-row .att-name {
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.att-row .att-name:hover { color: var(--accent); text-decoration: underline; }
.att-row .att-size { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.att-row .remove-row { margin-left: auto; width: 34px; height: 34px; }
.remove-row.save-service:hover { background: rgba(143, 250, 4, 0.1); color: var(--accent); }

/* ---- Mobile bar + drawer sidebar ---------------------------------------- */

.mobile-bar { display: none; }

.sidebar-head { display: flex; align-items: center; gap: 10px; }
.sidebar-head .brand { flex: 1; min-width: 0; }

.drawer-close {
  display: none;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-2);
  cursor: pointer;
}
.drawer-close svg { width: 17px; height: 17px; }
.drawer-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.1); }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 8, 14, 0.62);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.scrim.show { opacity: 1; pointer-events: auto; }

/* ---- Filter tabs: swipeable slider -------------------------------------- */

.tabs-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.tabs-wrap::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 0;
  bottom: 3px;
  width: 30px;
  background: linear-gradient(to left, var(--surface) 22%, rgba(31, 39, 56, 0));
  border-radius: 0 14px 14px 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.tabs-wrap.scrollable::after { opacity: 1; }
.tabs-wrap .tabs { width: 100%; }

/* ---- Quota chip (dashboard) ------------------------------------------------ */

.quota-chips {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.quota-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px;
  white-space: nowrap;
}
.quota-chip svg { width: 15px; height: 15px; color: var(--accent); flex: 0 0 auto; }
.quota-chip b { color: var(--text); font-weight: 700; }
.quota-chip small {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(143, 250, 4, 0.12);
  border-radius: 99px;
  padding: 2px 8px;
  letter-spacing: 0.2px;
}
/* Compact badge is mobile-only; the two detail badges hide under 860px. */
.quota-chip.compact { display: none; }
/* Paid, free and compact badges are all highlights: neon border, never subtle. */
.quota-chip.free,
.quota-chip.paid,
.quota-chip.compact {
  border-color: rgba(143, 250, 4, 0.5);
  box-shadow: 0 0 0 1px rgba(143, 250, 4, 0.22), 0 0 14px rgba(143, 250, 4, 0.14);
}
.quota-chip.free svg,
.quota-chip.paid svg,
.quota-chip.compact svg { color: var(--accent); }
/* This week's free credit already spent. */
.quota-chip.free.locked {
  border-color: rgba(255, 192, 97, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 192, 97, 0.25);
  color: var(--amber);
}
.quota-chip.free.locked svg { color: var(--amber); }
.quota-chip.free.locked small { background: rgba(255, 192, 97, 0.14); color: var(--amber); }
.quota-chip.zero { border-color: rgba(255, 192, 97, 0.35); color: var(--amber); box-shadow: none; }
.quota-chip.zero svg { color: var(--amber); }
/* Topbar: badges and the action button share one height. */
.topbar-actions .quota-chip,
.topbar-actions .btn { height: 40px; }

/* ---- Quota alert (editor) ---------------------------------------------------- */

.quota-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
  background: rgba(255, 192, 97, 0.09);
  border: 1px solid rgba(255, 192, 97, 0.3);
  color: #ffd9a3;
}
.quota-alert svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.quota-alert b { color: #ffe1b8; }

/* ---- Payment methods picker (editor) ------------------------------------------ */

.pay-methods { display: flex; flex-wrap: wrap; gap: 8px; }
.pay-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
  user-select: none;
}
.pay-chip:hover { border-color: rgba(143, 250, 4, 0.4); }
.pay-chip.checked {
  background: rgba(143, 250, 4, 0.1);
  border-color: rgba(143, 250, 4, 0.4);
  color: var(--text);
}
.pay-chip .pm-name { font-weight: 700; }
.pay-chip .pm-desc { font-size: 12px; color: var(--text-3); font-weight: 400; }
.pay-chip input { accent-color: var(--accent); margin: 0; }

/* ---- Payment methods editor (settings) ----------------------------------------- */

.pay-method {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.02);
}
.pay-method.disabled { opacity: 0.55; }
.pay-method-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.pay-method-head .pm-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.pay-method-head .pm-toggle input { accent-color: var(--accent); margin: 0; }
.pay-method-head .pm-name { flex: 1 1 160px; min-width: 0; }
.pay-method-head .pm-provider { flex: 0 0 220px; }
.pay-method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.pay-method-grid .field { gap: 5px; }
.pay-method-grid label { font-size: 12px; }

/* ---- Plan card (settings) ------------------------------------------------------ */

.plan-row { display: flex; flex-direction: column; gap: 10px; }
.plan-name {
  font-weight: 700;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.plan-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(143, 250, 4, 0.12);
  border: 1px solid rgba(143, 250, 4, 0.3);
  border-radius: 999px;
  padding: 2px 9px;
}
.plan-detail { font-size: 13px; color: var(--text-2); }
.plan-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.plan-bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.plan-note { font-size: 12px; color: var(--text-3); line-height: 1.5; }

/* ---- Subscription (customer, settings) -------------------------------------- */

.sub-box { display: flex; flex-direction: column; gap: 14px; margin-top: 12px; }
.sub-current {
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 12px;
}
.sub-current .lbl { font-size: 12px; color: var(--text-3); }
.sub-current .val { font-size: 13px; font-weight: 700; }
.sub-credits {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch;
  width: 100%; margin-top: 2px;
}
.sub-badge {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 10px; padding: 8px 12px; font-size: 12.5px;
}
.sub-badge b { color: var(--text); font-weight: 700; font-size: 13.5px; }
.sub-badge small {
  font-size: 10.5px; font-weight: 700; color: var(--accent);
  background: rgba(143, 250, 4, 0.12); border-radius: 99px; padding: 2px 8px;
}
.sub-badge.zero { opacity: 0.7; }
/* The free badge is the highlight - the 1/week rule must be unmissable. */
.sub-badge.free {
  border-color: rgba(143, 250, 4, 0.5);
  box-shadow: 0 0 0 1px rgba(143, 250, 4, 0.22), 0 0 14px rgba(143, 250, 4, 0.14);
}
.sub-badge.free.locked {
  border-color: rgba(255, 192, 97, 0.55);
  box-shadow: 0 0 0 1px rgba(255, 192, 97, 0.25);
  color: var(--amber);
}
.sub-badge.free.locked small { background: rgba(255, 192, 97, 0.14); color: var(--amber); }
.sub-ref {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
  font-size: 14px; font-weight: 700; letter-spacing: .04em;
  color: var(--accent);
  background: rgba(143, 250, 4, 0.08);
  border: 1px dashed rgba(143, 250, 4, 0.45);
  border-radius: 10px; padding: 8px 12px;
}
.sub-packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.sub-pack {
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); padding: 14px;
  cursor: pointer; transition: border-color .15s ease, transform .15s ease;
  text-align: left; color: inherit; font: inherit;
}
.sub-pack:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.sub-pack.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.sub-pack.current { cursor: default; opacity: .9; }
.sub-pack .p-name { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.sub-pack .p-price { font-size: 18px; font-weight: 800; margin: 6px 0 2px; }
.sub-pack .p-price small { font-size: 11px; color: var(--text-3); font-weight: 600; }
.sub-pack .p-quota { font-size: 12px; color: var(--text-3); }
.sub-pack ul { margin: 8px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; }
.sub-pack li { font-size: 12px; color: var(--text-2); display: flex; gap: 6px; align-items: baseline; }
.sub-pack li svg { width: 12px; height: 12px; color: var(--accent); flex: 0 0 auto; transform: translateY(1px); }
.sub-form { display: flex; flex-direction: column; gap: 10px; }
.sub-form .field { margin: 0; }
.sub-actions { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.sub-result {
  border: 1px solid rgba(143, 250, 4, 0.35);
  background: rgba(143, 250, 4, 0.06);
  border-radius: 14px; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.sub-result h4 { margin: 0; font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.sub-result h4 svg { width: 16px; height: 16px; color: var(--accent); }
.sub-result .steps { font-size: 12.5px; color: var(--text-2); line-height: 1.55; }
.sub-hist { display: flex; flex-direction: column; gap: 8px; }
.sub-hist-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 12px; font-size: 12.5px;
}
.sub-hist-row .grow { flex: 1 1 auto; min-width: 140px; }
.sub-sec-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-3);
}
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 1px solid var(--border-strong);
  color: var(--text-2); border-radius: 8px;
  padding: 5px 9px; font-size: 12px; font-weight: 600; cursor: pointer;
  min-height: 30px;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.copy-btn svg { width: 13px; height: 13px; }
@media (max-width: 560px) {
  .sub-packs { grid-template-columns: 1fr; }
}

/* ---- Section cards with icon headers -------------------------------------- */

.section-card > h2 { display: flex; align-items: center; gap: 8px; }
.section-card > h2 svg { width: 17px; height: 17px; color: var(--accent); flex: 0 0 auto; }

/* ---- Logout ------------------------------------------------------------ */

.logout-form { margin: 0; }
.logout-form .nav-item {
  justify-content: flex-start;
  padding: 7px 10px;
  font-size: 12.5px;
}
.logout-form .nav-item:hover { color: var(--red); background: rgba(255, 123, 123, 0.1); }

/* ---- Responsive ------------------------------------------------------ */

@media (max-width: 1080px) and (min-width: 721px) {
  .app { grid-template-columns: 76px minmax(0, 1fr); }
  /* Icon rail (tablet only): hide only the label spans - never the .ico
     icon wrapper (span:not(.ico) keeps the icons visible). Below 721px the
     mobile drawer restores the labels. */
  .brand-name, .brand-sub, .nav-label, .nav-item > span:not(.ico) { display: none; }
  .sidebar { padding: 14px 10px; }
  .nav-item { justify-content: center; padding: 10px; }
  .brand { justify-content: center; padding: 4px 0; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .main { padding: 20px 18px 40px; }
  .sidebar-foot { border: none; background: none; padding: 0; display: flex; flex-direction: column; align-items: center; }
  .sidebar-foot .who, .sidebar-foot .what { display: none; }
  .logout-form { margin: 0; }
  .logout-form .nav-item { justify-content: center; padding: 10px; }
}

@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; }
  /* Tablet/desktop-narrow: both credit badges stay side by side (no collision). */
  .topbar-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; width: 100%; }
  .quota-chips { min-width: 0; }
  .search { width: auto; min-width: 0; flex: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .editor-main { grid-template-columns: 1fr; }
  .editor-preview { position: static; }
}

@media (max-width: 720px) {
  /* --- Mobile top bar + sliding drawer sidebar --- */
  .app { grid-template-columns: minmax(0, 1fr); }
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 45;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 9px 12px;
  }
  .menu-btn {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.06s ease;
  }
  .menu-btn svg { width: 20px; height: 20px; }
  .menu-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
  .menu-btn:active { transform: scale(0.94); }
  .menu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  /* Free-credits badge in the main bar, pushed to the right edge. */
  .mobile-bar-quota { margin-left: auto; display: flex; align-items: center; flex: 0 0 auto; }
  .mobile-bar-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
  .mobile-bar-brand .brand-mark { width: 30px; height: 30px; border-radius: 9px; font-size: 13px; }
  .mobile-bar-title {
    font-weight: 700;
    font-size: 14.5px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0; /* allow the title to shrink so the badge never overflows */
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 85vw);
    z-index: 55;
    height: 100vh;
    height: 100dvh;
    padding: 18px 14px;
    gap: 22px;
    border-right: 1px solid var(--border);
    box-shadow: 18px 0 44px rgba(0, 0, 0, 0.4);
    /* Fade + slide, same pattern as the public drawer: visibility flips
       immediately on open and lags behind on close (inert when hidden). */
    transform: translateX(-104%);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.34s cubic-bezier(0.22, 0.8, 0.3, 1), opacity 0.24s ease, visibility 0s linear 0.34s;
    will-change: transform;
  }
  .sidebar.open {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    transition: transform 0.34s cubic-bezier(0.22, 0.8, 0.3, 1), opacity 0.24s ease, visibility 0s;
  }
  .sidebar-head { display: flex; }
  .drawer-close { display: inline-flex; }
  body.menu-open { overflow: hidden; }

  /* restore labels the rail hid */
  .brand-name, .brand-sub, .nav-label, .sidebar-foot { display: block; }
  .nav-item span { display: inline; }
  .nav { flex-direction: column; margin-left: 0; gap: 3px; }
  .nav-item { justify-content: flex-start; padding: 9px 10px; }
  .sidebar-foot { margin-top: auto; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: rgba(255, 255, 255, 0.03); }
  .sidebar-foot .who { display: block; }
  .sidebar-foot .what { display: block; }
  .logout-form { margin-top: 10px; }
  .logout-form .nav-item { justify-content: flex-start; padding: 7px 10px; }

  /* Dashboard: table becomes stacked cards */
  .topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  /* Compact credits badge beside the action button, right-aligned. */
  .topbar-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; width: 100%; }
  .quota-chips { min-width: 0; justify-content: flex-end; }
  .quota-chip.compact { display: inline-flex; }
  .topbar-actions .quota-chip.paid, .topbar-actions .quota-chip.free { display: none; }
  .search { width: auto; min-width: 0; flex: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .metric { padding: 13px 14px; }
  .metric-value { font-size: 22px; }

  /* Filter tabs: finger-swipeable slider with snap */
  .filters { flex-wrap: wrap; align-items: flex-start; }
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-behavior: smooth;
    border-radius: 14px;
    max-width: 100%;
    cursor: grab;
  }
  .tabs:active { cursor: grabbing; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: 0 0 auto; scroll-snap-align: center; white-space: nowrap; }

  table.list, table.list tbody, table.list tr, table.list td { display: block; }
  table.list { min-width: 0; }
  table.list thead { display: none; }
  table.list tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 14px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  table.list tr:last-child { border-bottom: none; }
  table.list td {
    border: none;
    padding: 3px 0;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  table.list td::before {
    content: attr(data-label);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-3);
    flex: 0 0 auto;
  }
  .cell-number { order: 1; }
  .cell-num { order: 2; text-align: right; font-size: 14.5px; }
  .cell-client { order: 3; grid-column: span 2; flex-direction: column; align-items: flex-start; gap: 0; padding-top: 4px; }
  .cell-client::before { display: none; }
  .cell-date { order: 4; }
  .cell-valid { order: 5; }
  .cell-status { order: 6; }
  .cell-actions { order: 7; grid-column: span 2; justify-content: flex-end; border-top: 1px dashed var(--border); margin-top: 6px; padding-top: 8px; }
  .cell-actions::before { display: none; }
  .row-actions { opacity: 1; gap: 4px; }

  /* Editor rows restructure */
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .item-row { grid-template-columns: repeat(3, 1fr) 40px 40px; }
  .item-row input:nth-child(1) { grid-column: 1 / -1; }
  .item-row .row-total { grid-column: 1 / 3; text-align: left; padding-top: 6px; }
  .pay-method-grid { grid-template-columns: 1fr; }
  .pay-method-head .pm-provider { flex: 1 1 100%; }
  .obs-row, .obs-row[data-type="percent"], .obs-row[data-type="fixed"] { grid-template-columns: repeat(2, 1fr) 40px; }
  .obs-row .obs-text { grid-column: 1 / -1; }
  .obs-row .obs-type { grid-column: 1; }
  .obs-row .obs-pct { grid-column: 2; }
  .obs-row .obs-fixed { grid-column: 2; }
  .obs-row .obs-amount { grid-column: 1 / 3; text-align: left; padding-top: 6px; }
  .obs-row .remove-row { grid-column: 3; }

  .main { padding: 16px 12px 36px; }
  .section-card { padding: 16px 14px; }
  .editor-actions, .settings-actions { flex-wrap: wrap; border-radius: 16px; }
  .editor-actions .save-hint { width: 100%; text-align: center; }
}

@media (max-width: 480px) {
  .metrics { grid-template-columns: 1fr; }
  .metric-value { font-size: 24px; }
  .topbar-actions .btn { flex: 1; }
  .page-title { font-size: 21px; }
  .tabs { display: flex; }
  .tab { padding: 10px 12px; font-size: 12.5px; }
  .editor-actions { gap: 8px; }
  .editor-actions .btn { flex: 1; }
  .settings-actions { justify-content: center; }
}
