/* =====================================================================
   Ledger — visual language

   The reference is a ruled accounts register, not a web dashboard.
   Figures are the content; everything else gets out of their way.
   Rules are horizontal and thin, columns are ruled only where a reader
   needs to separate money from words, and numerals are tabular so a
   column of amounts lines up digit over digit.
   ===================================================================== */

:root {
  --ink:        #16233a;
  --ink-soft:   #4a5672;
  --ink-faint:  #7b879c;
  --paper:      #ffffff;
  --page:       #edf0f5;
  --rule:       #d3dae5;
  --rule-firm:  #9faec4;

  --dr-text:    #8e1116;
  --dr-bg:      #fcedee;
  --cr-text:    #0d5a2a;
  --cr-bg:      #e9f4ec;

  --warn-bg:    #fff6e0;
  --warn-line:  #d8a418;

  --sidebar:    210px;
  --radius:     3px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
p  { margin: 0 0 10px; }
a  { color: var(--ink); }

.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

/* Every figure in the app uses this: fixed-width digits so columns
   align, and no wrapping mid-number. */
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  text-align: right;
  white-space: nowrap;
}

.dr { color: var(--dr-text); }
.cr { color: var(--cr-text); }

/* ------------------------------------------------------------- SHELL */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--ink);
  color: #c9d2e2;
  padding: 18px 0 30px;
}

.brand {
  padding: 0 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: 12px;
}
.brand strong { display: block; color: #fff; font-size: 15px; font-weight: 600; }
.brand span   { display: block; font-size: 11.5px; color: #8d9bb4; margin-top: 2px; }

.nav a {
  display: block;
  padding: 8px 18px;
  color: #c9d2e2;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.nav a:hover  { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(255,255,255,.10); color: #fff;
                border-left-color: #7f9ac9; font-weight: 600; }
.nav .group {
  padding: 14px 18px 4px;
  font-size: 11px;
  color: #7583a0;
  letter-spacing: .04em;
}

.main { flex: 1; min-width: 0; padding: 22px 26px 60px; }

.topline {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}

/* ------------------------------------------------------------ PANELS */

.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.panel > h2 {
  padding: 10px 14px;
  border-bottom: 1px solid var(--rule);
  margin: 0;
  background: #f7f9fc;
}
.pad { padding: 14px; }

/* -------------------------------------------------------------- GRID */

.cards { display: grid; gap: 14px; margin-bottom: 18px;
         grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }

.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-top: 3px solid var(--rule-firm);
  border-radius: var(--radius);
  padding: 13px 15px 15px;
}
.card .label { font-size: 12.5px; color: var(--ink-soft); }
.card .sub   { font-size: 11.5px; color: var(--ink-faint); margin-top: 3px; }
.card .figure {
  font-size: 23px; font-weight: 600; margin-top: 6px;
  font-variant-numeric: tabular-nums; letter-spacing: -0.015em;
}
.card.total { border-top-color: var(--ink); background: #f7f9fc; }
.card.owed  { border-top-color: var(--cr-text); }

/* ------------------------------------------------------------ LEDGER */

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

table.ledger th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  padding: 8px 10px;
  background: #f7f9fc;
  border-bottom: 2px solid var(--rule-firm);
  white-space: nowrap;
}
table.ledger td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
table.ledger tbody tr:hover td { background: #f9fbfd; }

table.ledger th.money, table.ledger td.money {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  border-left: 1px solid var(--rule);
  width: 1%;
}
td.money.debit  { background: var(--dr-bg); color: var(--dr-text); }
td.money.credit { background: var(--cr-bg); color: var(--cr-text); }
th.money.debit  { color: var(--dr-text); }
th.money.credit { color: var(--cr-text); }
td.money.balance { background: #f6f8fb; font-weight: 600; }

table.ledger tr.empty td {
  padding: 26px 14px; text-align: center; color: var(--ink-soft);
}

.scroll { overflow-x: auto; }

/* ------------------------------------------------------------- FORMS */

label { display: block; font-size: 12.5px; color: var(--ink-soft);
        margin-bottom: 4px; }

input[type=text], input[type=password], input[type=date],
input[type=number], input[type=email], select, textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--rule-firm);
  border-radius: var(--radius);
  font: inherit;
  color: var(--ink);
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #5b7fb9;
  outline-offset: 1px;
  border-color: #5b7fb9;
}
input.num-in { text-align: right; font-variant-numeric: tabular-nums; }

.field { margin-bottom: 12px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); }

.btn {
  display: inline-block;
  padding: 8px 15px;
  background: var(--ink);
  color: #fff;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: #22324f; }
.btn.quiet { background: #fff; color: var(--ink); border-color: var(--rule-firm); font-weight: 500; }
.btn.quiet:hover { background: #f2f5f9; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }

/* ------------------------------------------------------------ NOTICES */

.notice {
  padding: 10px 13px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  border: 1px solid;
}
.notice.ok   { background: var(--cr-bg); border-color: #a9d3b8; color: var(--cr-text); }
.notice.err  { background: var(--dr-bg); border-color: #e0aeb0; color: var(--dr-text); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-line); color: #6b4d00; }

/* ------------------------------------------------------------- LOGIN */

.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--ink);
}
.login-box {
  width: 100%; max-width: 340px;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 26px 24px 24px;
}
.login-box h1 { margin-bottom: 2px; }
.login-box .lead { color: var(--ink-soft); font-size: 13px; margin-bottom: 18px; }
.login-box .btn { width: 100%; text-align: center; margin-top: 4px; }

/* ------------------------------------------------------------ MOBILE */

@media (max-width: 820px) {
  .shell { display: block; }
  .sidebar {
    width: 100%; flex: none; padding: 12px 0;
    display: flex; align-items: center; gap: 6px;
    overflow-x: auto; white-space: nowrap;
  }
  .brand { border: 0; margin: 0; padding: 0 14px; flex: 0 0 auto; }
  .brand span { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav .group { display: none; }
  .nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 6px 12px; }
  .nav a.active { border-left: 0; border-bottom-color: #7f9ac9; }
  .main { padding: 16px 14px 50px; }
}

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

@media print {
  .sidebar, .btn, .noprint { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
  .panel { border: 0; }
}
