/* WB Quick — Reminders-style layout, Work Balance colours */

:root {
  --bg-sidebar: #f9fafb;
  --bg-main: #ffffff;
  --bg-card: #ffffff;
  --bg-input: #eef1f4;
  --text: #111827;
  --text-dim: #6b7280;
  --separator: rgba(17, 24, 39, 0.09);
  --tile-count: #111827;
  --wb-maroon: #8c2d4a;
  --wb-maroon-soft: #9e5c7b;
  --wb-blue: #40758f;
  --wb-blue-soft: #7db8d1;
  --wb-teal: #38bdd0;
  --red: #dc2626;
  --row-hover: rgba(17, 24, 39, 0.045);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg-sidebar: #16181d;
    --bg-main: #0c0d10;
    --bg-card: #22252c;
    --bg-input: #2a2e36;
    --text: #f3f4f6;
    --text-dim: #9aa1ab;
    --separator: rgba(148, 163, 184, 0.16);
    --tile-count: #f3f4f6;
    --row-hover: rgba(148, 163, 184, 0.08);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-main);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select {
  font: inherit; color: var(--text);
  background: var(--bg-input);
  border: none; border-radius: 10px;
  padding: 10px 12px; width: 100%;
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: var(--bg-sidebar); padding: 20px; z-index: 50;
}
.login-card {
  width: 100%; max-width: 340px; background: var(--bg-card);
  border-radius: 20px; padding: 32px 28px; text-align: center;
  box-shadow: 0 10px 40px rgba(17, 24, 39, 0.10);
  display: flex; flex-direction: column; gap: 12px;
}
.login-logo { height: 52px; object-fit: contain; margin: 0 auto 4px; }
.login-card h1 { font-size: 24px; letter-spacing: -0.4px; }
.login-sub { color: var(--text-dim); font-size: 14px; margin-bottom: 8px; }
.btn-primary {
  background: var(--wb-blue); color: #fff; border-radius: 10px;
  padding: 11px; font-weight: 600;
}
.btn-primary:disabled { opacity: 0.6; }
.login-error { color: var(--red); font-size: 13px; min-height: 16px; }

/* ---------- Layout ---------- */
.app { display: flex; height: 100dvh; }
.sidebar {
  width: 320px; flex-shrink: 0; background: var(--bg-sidebar);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--separator);
}
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 18px 16px 8px; }
.sidebar-logo { height: 34px; object-fit: contain; align-self: flex-start; display: block; margin: 2px 2px 16px; }
@media (prefers-color-scheme: dark) {
  .sidebar-logo, .login-logo { filter: brightness(1.15); }
}
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  background: var(--bg-card); border-radius: 14px; padding: 10px 12px 8px;
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  border: 1px solid var(--separator);
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
  transition: transform 0.08s ease;
}
.tile:active { transform: scale(0.97); }
.tile.active { border-color: var(--tile); outline: 1px solid var(--tile); }
.tile-wide { grid-column: span 2; }
.tile-top { display: flex; align-items: center; justify-content: space-between; }
.tile-icon, .list-dot {
  width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
  background: var(--tile-bg);
  display: flex; align-items: center; justify-content: center;
}
@media (prefers-color-scheme: dark) {
  .tile-icon, .list-dot { background: color-mix(in srgb, var(--tile) 26%, transparent); }
}
.tile-icon svg, .list-dot svg {
  width: 17px; height: 17px;
  fill: none; stroke: var(--tile); stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
@media (prefers-color-scheme: dark) {
  .tile-icon svg, .list-dot svg { stroke: color-mix(in srgb, var(--tile) 60%, #ffffff); }
}
.tile-count { font-size: 24px; font-weight: 700; color: var(--tile-count); }
.tile-label { font-size: 13.5px; font-weight: 600; color: var(--text-dim); margin-top: 2px; }

/* ---------- Sidebar lists ---------- */
.lists-heading {
  font-size: 13px; font-weight: 700; color: var(--text-dim);
  margin: 22px 6px 6px;
}
.lists {
  display: flex; flex-direction: column; background: var(--bg-card);
  border-radius: 12px; overflow: hidden; border: 1px solid var(--separator);
}
.list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; font-size: 15px; text-align: left;
  border-bottom: 1px solid var(--separator);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--row-hover); }
.list-row.active { background: var(--row-hover); }
.list-dot { width: 28px; height: 28px; }
.list-count { margin-left: auto; color: var(--text-dim); font-size: 15px; }

.sidebar-footer {
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--separator); gap: 8px;
}
.user-email { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout { color: var(--wb-blue); font-size: 13px; flex-shrink: 0; }

/* ---------- Main view ---------- */
.main-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px 8px;
}
.back-btn { display: none; color: var(--wb-blue); font-size: 17px; padding: 4px 0; }
.view-title {
  font-size: 32px; font-weight: 800; letter-spacing: -0.5px;
  color: var(--accent, var(--wb-blue)); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header-actions { display: flex; gap: 6px; }
.add-btn, .refresh-btn {
  width: 34px; height: 34px; border-radius: 50%; font-size: 20px;
  color: var(--accent, var(--wb-blue));
  display: flex; align-items: center; justify-content: center;
}
.add-btn:hover, .refresh-btn:hover { background: var(--row-hover); }
.view-body { flex: 1; overflow-y: auto; padding: 4px 22px calc(30px + env(safe-area-inset-bottom)); }

/* ---------- Sections & rows ---------- */
.section-title {
  font-size: 17px; font-weight: 700; margin: 18px 2px 6px;
}
.section-title.red { color: var(--red); }
.section-title.dim { color: var(--text-dim); }
.client-group {
  font-size: 13px; font-weight: 700; margin: 12px 2px 2px;
  color: var(--accent, var(--wb-blue));
  text-transform: uppercase; letter-spacing: 0.4px;
}
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 2px; border-bottom: 1px solid var(--separator);
}
.row:last-child { border-bottom: none; }
.circle {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
  border: 1.8px solid var(--accent, var(--wb-blue));
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
}
.circle:hover { background: color-mix(in srgb, var(--accent, var(--wb-blue)) 12%, transparent); }
.circle.done { background: var(--accent, var(--wb-blue)); }
.circle.done::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.circle.static { border-color: var(--separator); border-style: dashed; cursor: default; }
.row-main { flex: 1; min-width: 0; }
.row-main.linked { cursor: pointer; }
.row-main.linked:hover .row-title { text-decoration: underline; }
.row-main.linked:hover .row-title::after {
  content: " \2197"; font-size: 13px; color: var(--accent, var(--wb-blue));
}
.row-title { font-size: 16px; line-height: 1.35; }
.row.completed .row-title { color: var(--text-dim); text-decoration: line-through; }
.row-sub { font-size: 13.5px; color: var(--text-dim); margin-top: 1px; line-height: 1.35; }
.row-side { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.row-amount { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.row-date { font-size: 13px; color: var(--text-dim); }
.row-date.overdue { color: var(--red); font-weight: 600; }

.chip {
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 20px;
  background: var(--bg-input); color: var(--text-dim);
  text-transform: capitalize;
}
.chip.draft { background: rgba(107, 114, 128, 0.14); color: var(--text-dim); }
.chip.sent { background: rgba(64, 117, 143, 0.14); color: var(--wb-blue); }
.chip.accepted, .chip.paid { background: rgba(22, 163, 74, 0.14); color: #16a34a; }
.chip.rejected, .chip.overdue-chip { background: rgba(220, 38, 38, 0.12); color: var(--red); }
.chip.clickable { cursor: pointer; }

.flag-btn { color: var(--separator); font-size: 17px; padding: 2px 6px; flex-shrink: 0; }
.flag-btn.flagged, .flag-btn:hover { color: var(--wb-maroon); }

.empty { color: var(--text-dim); text-align: center; padding: 40px 10px; font-size: 15px; }

/* ---------- Add forms ---------- */
.add-form {
  background: var(--bg-sidebar); border: 1px solid var(--separator);
  border-top: 3px solid var(--accent, var(--wb-blue));
  border-radius: 14px; padding: 14px;
  margin: 10px 0 6px; display: flex; flex-direction: column; gap: 10px;
}
@media (prefers-color-scheme: dark) { .add-form { background: var(--bg-card); } }
.add-form .form-row { display: flex; gap: 8px; }
.add-form .form-row > * { flex: 1; }
.add-form textarea { resize: vertical; min-height: 64px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.btn-secondary { color: var(--text-dim); padding: 9px 14px; font-weight: 600; }
.btn-save {
  background: var(--accent, var(--wb-blue)); color: #fff;
  border-radius: 10px; padding: 9px 18px; font-weight: 600;
}
.btn-save:disabled { opacity: 0.5; }
.seg {
  display: flex; background: var(--bg-input); border-radius: 10px; padding: 3px; gap: 2px;
}
.seg button {
  flex: 1; padding: 7px 4px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  color: var(--text-dim);
}
.seg button.on { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 3px rgba(17,24,39,0.14); }
.line-items { display: flex; flex-direction: column; gap: 6px; }
.line-item { display: flex; gap: 6px; }
.line-item input:first-child { flex: 2.5; }
.line-item input:last-child { flex: 1; }
.line-add { align-self: flex-start; color: var(--accent, var(--wb-blue)); font-size: 14px; font-weight: 600; padding: 2px 4px; }
.totals { font-size: 14px; color: var(--text-dim); text-align: right; }
.totals b { color: var(--text); }
/* Section totals in list views get faint rules above and below. */
.view-body > .totals {
  border-top: 1px solid var(--separator);
  border-bottom: 1px solid var(--separator);
  padding: 7px 2px;
  margin-top: 2px;
}
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-dim); margin-bottom: -4px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg-main);
  padding: 10px 18px; border-radius: 22px; font-size: 14px; font-weight: 600;
  box-shadow: 0 6px 24px rgba(17,24,39,0.25); z-index: 60;
  transition: opacity 0.25s ease;
}

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .app { position: relative; }
  .sidebar { width: 100%; border-right: none; }
  .main {
    position: absolute; inset: 0; background: var(--bg-main);
    transform: translateX(100%); transition: transform 0.22s ease;
    visibility: hidden;
  }
  .app.detail .main { transform: translateX(0); visibility: visible; }
  .back-btn { display: block; }
  .view-title { font-size: 27px; }
  .main-header { padding: 14px 16px 6px; }
  .view-body { padding: 4px 16px calc(30px + env(safe-area-inset-bottom)); }
}
