@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600&family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500&display=swap');

:root {
  --bg: #F3F5F1;
  --surface: #FFFFFF;
  --surface-sunken: #EAF0EA;
  --border: #DCE4DC;
  --ink: #172B20;
  --ink-soft: #55645A;
  --brand: #1C5C3A;
  --brand-dark: #123D27;
  --gold: #A9812F;
  --gold-soft: #F4ECD8;
  --paid: #1C5C3A;
  --paid-bg: #E4F1E8;
  --pending-bg: #FBF3E2;
  --pending-ink: #8A6414;
  --danger: #B3261E;
  --danger-bg: #FBEAE9;
  --shadow: 0 1px 2px rgba(23, 43, 32, 0.06), 0 8px 24px -12px rgba(23, 43, 32, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10160F; --surface: #172115; --surface-sunken: #1D291B; --border: #2B3728;
    --ink: #EAF0E5; --ink-soft: #9AAA94; --brand: #5CAE81; --brand-dark: #7FC49E;
    --gold: #D8B458; --gold-soft: #2A2517; --paid: #5CAE81; --paid-bg: #1B2E22;
    --pending-bg: #2E2611; --pending-ink: #E3BB55; --danger: #E5847D; --danger-bg: #2E1917;
    --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 32px -14px rgba(0,0,0,0.55);
  }
}
:root[data-theme="dark"] {
  --bg: #10160F; --surface: #172115; --surface-sunken: #1D291B; --border: #2B3728;
  --ink: #EAF0E5; --ink-soft: #9AAA94; --brand: #5CAE81; --brand-dark: #7FC49E;
  --gold: #D8B458; --gold-soft: #2A2517; --paid: #5CAE81; --paid-bg: #1B2E22;
  --pending-bg: #2E2611; --pending-ink: #E3BB55; --danger: #E5847D; --danger-bg: #2E1917;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 12px 32px -14px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 'IBM Plex Sans', system-ui, sans-serif; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; text-wrap: balance; margin: 0; }

.shell { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }

.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; }
.login-card form { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.login-card input { margin-bottom: 4px; }

header.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 24px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-badge { background: var(--brand); border-radius: 9px; padding: 6px 10px; display: flex; align-items: center; flex-shrink: 0; }
.brand-logo { height: 15px; width: auto; display: block; }
.brand-tag { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.08em; }

.admin-pill { font-size: 11px; font-weight: 600; color: var(--ink-soft); background: var(--surface-sunken); border: 1px solid var(--border); padding: 6px 12px; border-radius: 100px; display: flex; align-items: center; gap: 6px; }
.admin-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
@media (max-width: 920px) { .layout { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); }
.panel-head { padding: 22px 26px 0; }
.panel-head .eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); margin-bottom: 6px; display: block; }
.panel-head h2 { font-size: 22px; font-weight: 600; color: var(--ink); }
.panel-head p { font-size: 13px; color: var(--ink-soft); margin: 6px 0 0; max-width: 46ch; }

form { padding: 22px 26px 26px; display: flex; flex-direction: column; gap: 18px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin-bottom: 6px; }
input, textarea, select {
  width: 100%; background: var(--surface-sunken); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; font-size: 14px; font-family: inherit; color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: var(--ink-soft); opacity: 0.6; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
textarea { resize: vertical; min-height: 68px; }

.amount-field { display: grid; grid-template-columns: 84px 1fr; gap: 8px; }
.amount-field label { grid-column: 1 / -1; }
.amount-field input { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; font-weight: 500; }

.hint { font-size: 11.5px; color: var(--ink-soft); margin-top: 6px; }
.error { font-size: 12.5px; color: var(--danger); background: var(--danger-bg); border-radius: 8px; padding: 8px 12px; }

.btn-primary {
  background: var(--brand); color: #fff; border: none; border-radius: 12px; padding: 13px 20px;
  font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-primary svg { width: 15px; height: 15px; }

.divider { height: 1px; background: var(--border); margin: 2px 0; }

.preview-card { padding: 22px; position: sticky; top: 24px; }
.preview-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.preview-label svg { width: 13px; height: 13px; }

.invoice-mini { background: var(--surface-sunken); border: 1px solid var(--border); border-radius: 14px; padding: 18px; }
.invoice-mini .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 12.5px; padding: 7px 0; border-bottom: 1px dashed var(--border); }
.invoice-mini .row:last-child { border-bottom: none; }
.invoice-mini .row .k { color: var(--ink-soft); }
.invoice-mini .row .v { font-weight: 600; text-align: right; }
.invoice-mini .total { margin-top: 6px; padding-top: 12px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: baseline; }
.invoice-mini .total .k { font-family: 'Fraunces', serif; font-size: 15px; font-weight: 600; color: var(--ink); }
.invoice-mini .total .v { font-family: 'IBM Plex Mono', monospace; font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--brand-dark); }

.link-box {
  margin-top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; color: var(--brand); overflow-x: auto; white-space: nowrap;
}
.copy-btn {
  flex-shrink: 0; font-family: 'IBM Plex Sans', sans-serif; font-size: 11px; font-weight: 600;
  background: var(--surface-sunken); border: 1px solid var(--border); color: var(--ink);
  border-radius: 6px; padding: 4px 9px; cursor: pointer;
}
.copy-btn:hover { background: var(--border); }

.table-wrap { margin-top: 28px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); font-weight: 600; padding: 0 10px 10px; }
tbody tr { background: var(--surface); }
tbody td { padding: 14px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:first-child td { border-top: none; }
.cell-client { font-weight: 600; }
.cell-sub { color: var(--ink-soft); font-size: 12px; margin-top: 2px; }
.cell-amt { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; font-weight: 500; }
.cell-link a { color: var(--brand); font-size: 12px; font-weight: 600; text-decoration: none; }
.cell-link a:hover { text-decoration: underline; }

.status { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 100px; }
.status.paid { background: var(--paid-bg); color: var(--paid); }
.status.pending { background: var(--pending-bg); color: var(--pending-ink); }
.status .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 4px 16px 16px; overflow-x: auto; }
.table-title { display: flex; align-items: baseline; justify-content: space-between; padding: 18px 10px 4px; }
.table-title h3 { font-size: 16px; font-weight: 600; }
.table-title span { font-size: 12px; color: var(--ink-soft); }

.empty-row td { text-align: center; color: var(--ink-soft); padding: 28px 10px; }
