/* Daybook app — the working tool. Dense on purpose; it's open all day. */

:root {
  --paper: #f4f4f2;
  --panel: #ffffff;
  --ink: #26241f;
  --muted: #6f6a61;
  --line: #ddd9d2;
  --side: #23211f;
  --side-dim: #a49d92;
  --accent: #bc3f2a;
  --accent-dark: #9c3220;
  --paid: #3e6b34;
  --sent: #8a6d1f;
}

* { box-sizing: border-box; }

body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.5;
}
.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }
a { color: var(--accent); }
button { font-family: inherit; }

/* ------------------------------------------------------------- shell */

.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--side); color: #ece9e2;
  padding: 20px 0; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .wordmark {
  font-size: 19px; font-weight: 600; padding: 0 20px 18px;
  border-bottom: 1px solid #3a372f; margin-bottom: 14px;
}
.sidebar .wordmark .tick { color: var(--accent); }
.sidebar nav a {
  display: block; color: #ece9e2; text-decoration: none;
  padding: 8px 20px; font-size: 14px;
}
.sidebar nav a:hover { background: #2e2b26; }
.sidebar nav a.active { background: #2e2b26; border-left: 3px solid var(--accent); padding-left: 17px; }
.sidebar .who {
  margin-top: auto; padding: 14px 20px 0; border-top: 1px solid #3a372f;
  font-size: 13px; color: var(--side-dim);
}
.sidebar .who .name { color: #ece9e2; font-size: 14px; }
.sidebar .who button {
  background: none; border: none; color: var(--side-dim); cursor: pointer;
  padding: 4px 0 0; font-size: 13px; text-decoration: underline;
}

.main { padding: 28px 36px 64px; max-width: 1060px; }
.main h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.main .sub { color: var(--muted); margin: 0 0 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.page-head .btn { margin-top: 4px; }

/* ------------------------------------------------------------- controls */

.btn {
  display: inline-block; background: var(--accent); color: #fff;
  border: 1px solid var(--accent-dark); padding: 7px 14px; border-radius: 3px;
  font-size: 14px; font-weight: 500; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent-dark); }
.btn.plain { background: var(--panel); color: var(--ink); border-color: #c9c4ba; }
.btn.plain:hover { border-color: var(--ink); background: var(--panel); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.danger { background: var(--panel); color: var(--accent); border-color: #e3b3a6; }
.btn.danger:hover { background: #f9e9e5; }
.btn[disabled] { opacity: 0.5; cursor: default; }

input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--ink);
  border: 1px solid #c9c4ba; border-radius: 3px; padding: 8px 10px;
  background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); border-color: var(--accent);
}
label.flabel { display: block; font-size: 12px; font-weight: 500; margin-bottom: 5px; color: #3d3a34; }
.field { margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-error {
  background: #f9e9e5; border: 1px solid #e3b3a6; color: #7e2413;
  padding: 10px 12px; font-size: 13px; margin-bottom: 16px; border-radius: 3px; display: none;
}

/* ------------------------------------------------------------- panels + tables */

.panel {
  background: var(--panel); border: 1px solid var(--line);
  padding: 18px 20px; margin-bottom: 20px;
}
.panel h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
.panel h2 .more { float: right; font-size: 13px; font-weight: 400; }

table.list { border-collapse: collapse; width: 100%; }
table.list th, table.list td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.list th { font-size: 12px; color: var(--muted); font-weight: 500; }
table.list tr:last-child td { border-bottom: none; }
table.list td.num, table.list th.num { text-align: right; font-family: "IBM Plex Mono", monospace; }
table.list a { color: var(--ink); text-decoration: none; font-weight: 500; }
table.list a:hover { color: var(--accent); text-decoration: underline; }

.status {
  font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.status.sent { color: var(--sent); border-color: #ddd0a0; background: #fbf6e0; }
.status.overdue { color: var(--accent); border-color: #e3b3a6; background: #f9e9e5; }
.status.paid { color: var(--paid); border-color: #b9cfb0; background: #eef4ea; }

/* dashboard stat strip — numbers first, labels under, like a ledger summary */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); padding: 16px 20px; }
.stat .figure { font-family: "IBM Plex Mono", monospace; font-size: 28px; font-weight: 500; }
.stat .figure.red { color: var(--accent); }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 2px; }

.empty { color: var(--muted); padding: 12px 0; }
.row-actions { white-space: nowrap; }
.row-actions .btn { margin-left: 6px; }
.linklike {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: 13px; padding: 0; text-decoration: underline;
}

/* ------------------------------------------------------------- invoice editor */

.items-table { border-collapse: collapse; width: 100%; margin-bottom: 8px; }
.items-table th { font-size: 12px; color: var(--muted); font-weight: 500; text-align: left; padding: 0 6px 6px 0; }
.items-table td { padding: 0 6px 8px 0; }
.items-table td.num input { text-align: right; font-family: "IBM Plex Mono", monospace; }
.items-table .del {
  background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px;
}
.items-table .del:hover { color: var(--accent); }
.totals-box { margin-left: auto; width: 280px; }
.totals-box table { border-collapse: collapse; width: 100%; }
.totals-box td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.totals-box td.num { text-align: right; font-family: "IBM Plex Mono", monospace; }
.totals-box tr.grand td { font-weight: 600; font-size: 16px; border-bottom: none; padding-top: 9px; }
.tax-row { display: flex; gap: 8px; align-items: center; }
.tax-row input[type="checkbox"] { width: auto; }

/* ------------------------------------------------------------- invoice document */

.invoice-doc {
  background: #fff; border: 1px solid var(--line);
  padding: 44px 48px; max-width: 780px;
}
.invoice-doc .doc-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 2px solid var(--ink); padding-bottom: 16px; margin-bottom: 20px;
}
.invoice-doc .biz { font-size: 20px; font-weight: 600; }
.invoice-doc .biz small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; white-space: pre-line; margin-top: 4px; }
.invoice-doc .doc-title { text-align: right; }
.invoice-doc .doc-title .t { font-size: 13px; letter-spacing: 0.12em; color: var(--muted); }
.invoice-doc .doc-title .n { font-family: "IBM Plex Mono", monospace; font-size: 22px; }
.invoice-doc .doc-meta { display: flex; gap: 48px; margin-bottom: 24px; font-size: 13px; }
.invoice-doc .doc-meta .k { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.invoice-doc .billto { white-space: pre-line; }
/* ruled lines, like ledger paper */
.invoice-doc table.doc-items { border-collapse: collapse; width: 100%; margin-bottom: 6px; }
.invoice-doc table.doc-items th {
  text-align: left; font-size: 11px; color: var(--muted); font-weight: 500;
  border-bottom: 1px solid var(--ink); padding: 6px 8px 6px 0;
}
.invoice-doc table.doc-items td {
  padding: 9px 8px 9px 0; border-bottom: 1px solid var(--line); vertical-align: top;
}
.invoice-doc table.doc-items td.num, .invoice-doc table.doc-items th.num {
  text-align: right; font-family: "IBM Plex Mono", monospace; padding-right: 0;
}
.invoice-doc .doc-notes { margin-top: 26px; font-size: 13px; color: #3d3a34; white-space: pre-line; }
.invoice-doc .doc-status {
  display: inline-block; margin-top: 14px; font-size: 12px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}

.activity { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.activity li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.activity li:last-child { border-bottom: none; }
.activity .when { color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: 12px; margin-right: 10px; }
.activity pre {
  white-space: pre-wrap; font-family: "IBM Plex Sans", sans-serif; font-size: 13px;
  background: var(--paper); border: 1px solid var(--line); padding: 10px 12px; margin: 8px 0 2px;
}

.reminder-box textarea { min-height: 190px; line-height: 1.55; }
.tone-row { display: flex; gap: 8px; margin-bottom: 10px; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar .spacer { flex: 1; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .main { padding: 20px 16px 48px; }
  .stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .invoice-doc { padding: 28px 20px; }
}

/* ------------------------------------------------------------- print: just the invoice */

@media print {
  body { background: #fff; }
  .sidebar, .toolbar, .no-print { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .invoice-doc { border: none; padding: 0; max-width: none; }
  .panel { border: none; padding: 0; }
}
