/* =========================================================
   THEME TOKENS
   Light (default) is Shopify-admin inspired: white cards on
   a light gray canvas, dashed card dividers, solid accents.
   ========================================================= */
:root {
  --bg: #f6f7f9;
  --bg-soft: #eef0f3;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e1e5ea;
  --border-strong: #c9cfd6;
  --text: #202223;
  --text-dim: #6d7175;
  --text-faint: #8c9196;

  --accent: #008060;
  --accent-hover: #006e52;
  --accent-soft: rgba(0, 128, 96, 0.08);
  --teal: #008060;
  --teal-strong: #006e52;
  --teal-soft: rgba(0, 128, 96, 0.08);
  --blue: #1363d1;
  --blue-soft: rgba(19, 99, 209, 0.08);
  --amber: #b98900;
  --amber-soft: rgba(185, 137, 0, 0.1);
  --violet: #5c6ac4;
  --violet-soft: rgba(92, 106, 196, 0.1);
  --danger: #d72c0d;
  --danger-soft: rgba(215, 44, 13, 0.08);

  --chart-line: #1363d1;
  --chart-line-prev: rgba(19, 99, 209, 0.35);
  --chart-grid: #eef0f3;
  --chart-area-top: rgba(19, 99, 209, 0.22);
  --chart-area-bottom: rgba(19, 99, 209, 0);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(31, 41, 51, 0.06), 0 8px 24px rgba(31, 41, 51, 0.06);
  --shadow-lift: 0 2px 4px rgba(31, 41, 51, 0.08), 0 16px 40px rgba(31, 41, 51, 0.12);
}

:root[data-theme="dark"] {
  --bg: #0a0e14;
  --bg-soft: #0d1219;
  --surface: #121926;
  --surface-2: #0e141d;
  --border: #1f2a3a;
  --border-strong: #2b3a4f;
  --text: #e8eef6;
  --text-dim: #8b98a9;
  --text-faint: #5d6b7d;

  --accent: #34d399;
  --accent-hover: #10b981;
  --accent-soft: rgba(52, 211, 153, 0.1);
  --teal: #34d399;
  --teal-strong: #10b981;
  --teal-soft: rgba(52, 211, 153, 0.1);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.12);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.12);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);

  --chart-line: #60a5fa;
  --chart-line-prev: rgba(96, 165, 250, 0.35);
  --chart-grid: #1f2a3a;
  --chart-area-top: rgba(96, 165, 250, 0.2);
  --chart-area-bottom: rgba(96, 165, 250, 0);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.3), 0 16px 40px rgba(0, 0, 0, 0.4);
}

/* ============ BASE ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  transition: background 0.2s ease, color 0.2s ease;
}

button { font-family: inherit; cursor: pointer; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }

.icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
/* Icons: filled symbols carry fill="currentColor" on the <symbol>; the few
   stroke icons (chevrons, sort arrows, close) carry their own stroke attrs.
   No fill/stroke defaults here so each symbol controls its own look. */

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

::selection { background: var(--accent-soft); }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ============ LAYOUT ============ */
.app { display: flex; min-height: 100vh; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.22s ease;
}
.sidebar__brand { position: relative; display: flex; align-items: center; gap: 12px; padding: 0 8px 24px; }
.sidebar__collapse {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-faint);
  transition: all 0.15s;
}
.sidebar__collapse:hover { color: var(--text); background: var(--bg-soft); border-color: var(--border); }
.sidebar__collapse .icon { width: 15px; height: 15px; }
.sidebar__logo {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #10b981, #0d9488);
  border-radius: 10px;
  color: #fff;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.35);
}
.sidebar__logo .icon { width: 20px; height: 20px; }
.sidebar__name { font-weight: 700; font-size: 1rem; letter-spacing: -0.01em; }
.sidebar__tag { font-size: 0.72rem; color: var(--text-faint); }

/* --- collapsed state --- */
.sidebar-collapsed .sidebar { width: 76px; padding: 20px 10px; }
.sidebar-collapsed .sidebar__brand { justify-content: center; padding: 0 0 24px; }
.sidebar-collapsed .sidebar__brand-text,
.sidebar-collapsed .sidebar__label,
.sidebar-collapsed .btn__label,
.sidebar-collapsed .sidebar__tag,
.sidebar-collapsed .sidebar__shortcuts { display: none; }
.sidebar-collapsed .sidebar__collapse {
  position: absolute;
  right: -13px; top: 6px;
  width: 26px; height: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.sidebar-collapsed .sidebar__collapse .icon { width: 14px; height: 14px; }
.sidebar-collapsed .sidebar__nav { align-items: center; }
.sidebar-collapsed .sidebar__link { justify-content: center; padding: 11px 0; width: 100%; }
.sidebar-collapsed .sidebar__footer .btn { padding: 10px 0; }
.sidebar-collapsed .sidebar__footer .btn .icon { width: 17px; height: 17px; }

.sidebar__nav { display: flex; flex-direction: column; gap: 3px; flex-grow: 1; }
.sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem; font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar__link .icon { width: 17px; height: 17px; }
.sidebar__link:hover { background: var(--bg-soft); color: var(--text); }
.sidebar__link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar__footer { display: flex; flex-direction: column; gap: 8px; padding-top: 16px; border-top: 1px solid var(--border); }
.sidebar__shortcuts {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px;
  font-size: 0.72rem; color: var(--text-faint);
  padding: 0 4px;
}
.kbd {
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text-dim);
}

/* ============ MAIN ============ */
.main { flex-grow: 1; padding: 30px 36px 48px; max-width: 1240px; width: 100%; }
.main__header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; gap: 16px; flex-wrap: wrap; }
.main__title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.main__subtitle { color: var(--text-dim); font-size: 0.88rem; margin-top: 3px; }
.main__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.main__footer { margin-top: 40px; color: var(--text-faint); font-size: 0.78rem; text-align: center; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  font-size: 0.88rem; font-weight: 600;
  transition: transform 0.12s, background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn .icon { width: 16px; height: 16px; }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { background: var(--surface); color: var(--text-dim); border-color: var(--border); }
.btn--ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-2); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(1.05); }
.btn--block { width: 100%; }

/* ============ PERIOD BAR ============ */
.stats__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.stats__bar-title {
  font-size: 0.74rem;
  color: var(--text-faint);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* ============ SEGMENTED CONTROL ============ */
.seg { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.seg--wrap { flex-wrap: wrap; }
.seg__btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.seg__btn:hover { color: var(--text); }
.seg__btn.is-active { background: var(--surface); color: var(--accent); box-shadow: 0 1px 2px rgba(31, 41, 51, 0.12); }

/* ============ STAT CARDS ============ */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.stat-card__body { min-width: 0; }
.stat-card__label { font-size: 0.72rem; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-card__value-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 5px 0 3px;
  flex-wrap: wrap;
}
.stat-card__value {
  font-size: 1.5rem; font-weight: 700; margin: 0;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-card__hint { font-size: 0.78rem; color: var(--text-faint); }

/* small trend badge inside stat cards */
.trend--sm { font-size: 0.7rem; padding: 3px 9px; gap: 4px; font-weight: 700; }
.trend--sm .icon { width: 12px; height: 12px; }
.trend--amber { color: var(--amber); background: var(--amber-soft); }

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px dashed var(--border-strong);
  flex-wrap: wrap;
}
.card__header--stack { flex-direction: column; border-bottom: 1px dashed var(--border-strong); }
.card__header-actions { display: flex; align-items: center; gap: 10px; }
.card__title { font-size: 1.02rem; font-weight: 700; letter-spacing: -0.01em; }
.card__subtitle { font-size: 0.82rem; color: var(--text-faint); margin-top: 2px; }

/* ============ ANALYTICS (Shopify-style) ============ */
.analytics { padding: 4px 2px 0; }
.analytics__metric-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.analytics__metric {
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 4px 10px;
  border-radius: 999px;
}
.trend .icon { width: 13px; height: 13px; }
.trend--up { color: #007f5f; background: rgba(0, 143, 104, 0.12); }
.trend--down { color: var(--danger); background: var(--danger-soft); }

/* ============ WIDGETS ROW ============ */
.widgets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}
.widget { margin-bottom: 0; display: flex; flex-direction: column; }
.widget .card__header { padding-bottom: 12px; margin-bottom: 14px; }
.widget .analytics { flex-grow: 1; }
.widget .chart svg { height: 190px; }
@media (max-width: 1100px) {
  .widgets { grid-template-columns: 1fr 1fr; }
  .widget--line { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .widgets { grid-template-columns: 1fr; }
}

/* ============ BAR CHART ============ */
.bars { flex-grow: 1; display: flex; align-items: center; }
.bars svg { display: block; width: 100%; height: 190px; }
.bars .bar { fill: var(--blue); transition: opacity 0.15s; }
.bars .bar:hover { opacity: 0.75; }
.bars .bar-label { fill: var(--text-dim); font-size: 10px; font-weight: 600; }
.bars .grid-line { stroke: var(--chart-grid); stroke-width: 1; }

/* ============ DONUT ============ */
.donut-wrap { display: flex; justify-content: center; padding: 10px 0 2px; }
.donut { position: relative; width: 120px; height: 120px; }
.donut svg { display: block; }
.donut .track,
.donut .seg { fill: none; stroke-width: 22; }
.donut .track { stroke: var(--border); }
.donut .seg { transition: opacity 0.18s, stroke-width 0.18s; }
.donut .seg--local { stroke: var(--blue); }
.donut .seg--foreign { stroke: var(--violet); }
.donut .seg.is-dim { opacity: 0.22; }
.donut__center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut__center-value { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.donut__center-label { font-size: 0.64rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; margin-top: 2px; }
.donut-legend { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.donut-legend__item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.82rem;
  padding: 7px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}
.donut-legend__item:hover { background: var(--bg-soft); }
.donut-legend__dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-legend__dot--local { background: var(--blue); }
.donut-legend__dot--foreign { background: var(--violet); }
.donut-legend__name { font-weight: 600; }
.donut-legend__pct { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.donut-legend__amt { color: var(--text-faint); font-size: 0.74rem; font-variant-numeric: tabular-nums; min-width: 68px; text-align: right; }

/* ============ LINE CHART ============ */
.chart svg { display: block; width: 100%; height: 220px; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .grid-label { fill: var(--text-faint); font-size: 10px; font-weight: 500; }
.chart .axis-label { fill: var(--text-faint); font-size: 10px; font-weight: 500; }
.chart .line-cur { stroke: var(--chart-line); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-prev { stroke: var(--chart-line-prev); stroke-width: 1.5; fill: none; stroke-dasharray: 4 4; stroke-linejoin: round; stroke-linecap: round; }
.chart .area-cur { fill: url(#areaGrad); }
.chart .dot { fill: var(--chart-line); stroke: var(--surface); stroke-width: 1.5; }

.legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--text-dim);
  flex-wrap: wrap;
}
.legend__item { display: inline-flex; align-items: center; gap: 7px; }
.legend__swatch { display: inline-block; width: 18px; height: 3px; border-radius: 2px; }
.legend__swatch--cur { background: var(--chart-line); }
.legend__swatch--prev { background: repeating-linear-gradient(90deg, var(--chart-line-prev) 0 4px, transparent 4px 8px); }
.legend__range { color: var(--text-faint); }

/* ============ OUTSTANDING LIST ============ */
.outstanding { margin-top: 22px; border-top: 1px dashed var(--border-strong); padding-top: 16px; }
.outstanding__title {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.85rem; font-weight: 700; margin-bottom: 4px;
}
.outstanding__title .icon { width: 15px; height: 15px; color: var(--amber); }
.outstanding__total { margin-left: auto; color: var(--amber); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.8rem; }
.outstanding__item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.outstanding__item:last-child { border-bottom: none; }
.outstanding__name { font-weight: 600; }
.outstanding__meta { color: var(--text-faint); font-size: 0.76rem; }
.outstanding__amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.outstanding__empty { color: var(--text-faint); font-size: 0.84rem; padding: 10px 2px; }

/* ============ CLIENTS TOOLS ============ */
.clients__tools { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.clients__filters { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.search-wrap { position: relative; max-width: 380px; }
.search-wrap--full { width: 100%; max-width: none; }
.search-wrap .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 0.78rem; font-weight: 600;
  transition: all 0.15s;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.is-active { background: var(--accent-soft); border-color: rgba(0, 128, 96, 0.35); color: var(--accent); }

/* ============ INPUTS ============ */
.input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 9px 12px;
  font-size: 0.88rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-faint); }
select.input {
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238c9196' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
textarea.input { resize: vertical; }
.input--search { padding-left: 36px; }

/* ============ TABLE ============ */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th {
  text-align: left;
  color: var(--text-faint);
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  padding: 11px 14px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background 0.12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }

.th-sort { cursor: pointer; user-select: none; transition: color 0.15s; }
.th-sort:hover { color: var(--text); }
.th-sort .icon--sort { width: 12px; height: 12px; margin-left: 2px; vertical-align: -2px; opacity: 0.5; }
.th-sort.is-sorted { color: var(--accent); }
.th-sort.is-sorted .icon--sort { opacity: 1; }

.table__client-name { font-weight: 600; display: flex; align-items: center; gap: 7px; }
.table__client-niche { font-size: 0.76rem; color: var(--text-faint); margin-top: 1px; }
.table__market {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 6px; flex-shrink: 0;
}
.table__market .icon { width: 12px; height: 12px; }
.table__market--foreign { background: var(--blue-soft); color: var(--blue); }
.table__market--local { background: var(--teal-soft); color: var(--teal); }
.table__url { color: var(--accent); text-decoration: none; font-size: 0.8rem; word-break: break-all; }
.table__url:hover { text-decoration: underline; }
.table__money { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table__money--dim { color: var(--text-faint); font-weight: 500; }
.table__balance--due { color: var(--amber); font-weight: 700; }
.table__date { color: var(--text-dim); white-space: nowrap; }
.table__actions-col { width: 92px; }
.table__actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ============ ICON BUTTONS ============ */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px;
  color: var(--text-faint);
  transition: all 0.15s;
}
.icon-btn .icon { width: 15px; height: 15px; }
.icon-btn:hover { border-color: var(--border); color: var(--text); background: var(--bg-soft); }
.icon-btn--danger:hover { color: var(--danger); border-color: rgba(215, 44, 13, 0.35); background: var(--danger-soft); }

/* ============ STATUS PILLS ============ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill--Completed { color: var(--teal); background: var(--teal-soft); border-color: rgba(0, 128, 96, 0.25); }
.pill--InProgress { color: var(--amber); background: var(--amber-soft); border-color: rgba(185, 137, 0, 0.25); }
.pill--DepositPaid { color: var(--blue); background: var(--blue-soft); border-color: rgba(19, 99, 209, 0.25); }
.pill--Pending { color: var(--text-dim); background: var(--bg-soft); border-color: var(--border); }

/* ============ EMPTY STATE ============ */
.empty-state { text-align: center; padding: 56px 20px; }
.empty-state__icon {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-faint);
}
.empty-state__icon .icon { width: 24px; height: 24px; }
.empty-state__title { font-weight: 700; margin-bottom: 4px; }
.empty-state__text { color: var(--text-faint); font-size: 0.85rem; }

/* ============ MODAL ============ */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(20, 26, 32, 0.5); backdrop-filter: blur(3px); }
.modal__card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
  box-shadow: var(--shadow-lift);
  animation: modalIn 0.18s ease;
}
.modal__card--small { width: min(430px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal__header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; }
.modal__title { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.modal__text { color: var(--text-dim); font-size: 0.92rem; margin-bottom: 24px; }
.modal__footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ============ FORM ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field--full { grid-column: 1 / -1; }
.field > span { font-size: 0.78rem; font-weight: 600; color: var(--text-dim); }
.field__money { display: flex; gap: 8px; }
.input--cur { width: 62px; flex-shrink: 0; text-align: center; font-weight: 700; }

/* ============ LOGIN ============ */
.login {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.login__card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: var(--shadow-lift);
  text-align: center;
}
.login__logo {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #10b981, #0d9488);
  border-radius: 14px;
  color: #fff;
}
.login__logo .icon { width: 26px; height: 26px; }
.login__title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.01em; }
.login__subtitle { color: var(--text-faint); font-size: 0.85rem; margin: 4px 0 22px; }
.login__form { text-align: left; display: flex; flex-direction: column; gap: 14px; }
.login__error { color: var(--danger); font-size: 0.82rem; font-weight: 500; text-align: center; }
.login__footer { margin-top: 18px; font-size: 0.74rem; color: var(--text-faint); }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.88rem; font-weight: 500;
  z-index: 200;
  box-shadow: var(--shadow-lift);
  animation: toastIn 0.2s ease;
}
.toast .toast__icon { width: 17px; height: 17px; color: var(--teal); }
.toast--error { border-color: rgba(215, 44, 13, 0.45); }
.toast--error .toast__icon { color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ============ RESPONSIVE ============ */
#overview, #earnings, #clients { scroll-margin-top: 16px; }

/* ============ MOBILE BOTTOM NAV ============ */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 90;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(31, 41, 51, 0.06);
}
.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 10px;
  color: var(--text-faint);
  text-decoration: none;
  font-size: 0.66rem;
  font-weight: 600;
  transition: color 0.15s, background 0.15s;
}
.bottom-nav__item .icon { width: 20px; height: 20px; }
.bottom-nav__item.is-active { color: var(--accent); background: var(--accent-soft); }

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto;
    position: sticky; top: 0; z-index: 80;
    flex-direction: row; align-items: center;
    padding: 10px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar__brand { padding: 0; }
  .sidebar__collapse, .sidebar__nav, .sidebar__footer { display: none; }
  .sidebar, .main { min-width: 0; } /* let flex children shrink below content width (fixes mobile overflow) */
  .main { padding: 18px 16px 96px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .bottom-nav { display: flex; }
  #overview, #earnings, #clients { scroll-margin-top: 74px; }
  .toast { bottom: 86px; }
  .card { padding: 18px; }
  .table-wrap { overflow-x: auto; }
  .table { min-width: 620px; }
}
@media (max-width: 640px) {
  /* earnings period — single scrollable row instead of wrapping clutter */
  .stats__bar { flex-direction: column; align-items: stretch; gap: 8px; }
  .seg--wrap { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; width: 100%; min-width: 0; }
  .seg--wrap::-webkit-scrollbar { display: none; }
  .seg__btn { white-space: nowrap; flex-shrink: 0; }

  /* clients table → compact stacked cards (2-col money grid) */
  .table-wrap { overflow: visible; border: none; }
  .table { min-width: 0; }
  .table thead { display: none; }
  .table tbody { display: flex; flex-direction: column; gap: 10px; }
  .table tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    position: relative;
  }
  .table td {
    border: none;
    padding: 3px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .table td::before {
    content: attr(data-label);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
  }
  .table td:first-child {
    grid-column: 1 / -1;
    display: block;
    padding: 0 56px 8px 0;
    border-bottom: 1px dashed var(--border);
    margin-bottom: 6px;
  }
  .table td:first-child::before { display: none; }
  .table td:nth-child(2) { grid-column: 1 / -1; }
  .table td:last-child {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0;
  }
  .table td:last-child::before { display: none; }
  .table tbody tr:hover { background: var(--surface); }
}
@media (max-width: 560px) {
  .main { padding: 14px 12px 92px; }
  .main__title { font-size: 1.28rem; }
  .main__subtitle { font-size: 0.8rem; }
  .main__actions { gap: 8px; }
  .main__actions .btn--ghost { display: none; }
  #themeToggle { display: inline-flex !important; }
  .stat-card { padding: 14px 16px; }
  .stat-card__value { font-size: 1.3rem; }
  .form-grid { grid-template-columns: 1fr; }
  /* bottom-sheet modals */
  .modal { align-items: flex-end; padding: 0; }
  .modal__card { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; padding: 22px 18px; }
  .modal__footer { padding-bottom: env(safe-area-inset-bottom); }
}
