/* Acertronix Books — app chrome. The quote/invoice sheet itself is paper.css. */
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1d2433;
  --soft: #626b7d;
  --line: #dde2ea;
  --navy: #13294f;
  --brand: #0a8a9c;   /* logo teal, darkened to read on white */
  --brand-ink: #ffffff;
  --ok: #1e8e4f;
  --warn: #b26a00;
  --bad: #c23b32;
  --radius: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 22px 0 10px; }
.card h2:first-child, .card h2.span2 { margin-top: 4px; }
.muted { color: var(--soft); }
.small { font-size: .85rem; font-weight: normal; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.bad { color: var(--bad); }

/* top bar */
.topbar { display: flex; align-items: center; gap: 18px; padding: 0 20px; background: var(--navy); color: #fff;
  min-height: 54px; flex-wrap: wrap; }
.brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand img { height: 24px; width: auto; }
.brand span { color: #2de0e6; font-weight: 600; letter-spacing: .5px; }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: #c9d5ec; padding: 16px 10px; border-bottom: 3px solid transparent; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar nav a.on { color: #fff; border-bottom-color: #2de0e6; }
.topbar .logout button { color: #c9d5ec; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 40px; }
main.center { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.foot { text-align: center; color: var(--soft); font-size: .8rem; padding: 10px 0 24px; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px;
  flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; }

/* buttons + inputs */
button, .button { font: inherit; padding: 8px 14px; border-radius: 6px; border: 1px solid var(--line); background: #fff;
  color: var(--ink); cursor: pointer; display: inline-block; line-height: 1.2; }
button:hover, .button:hover { border-color: #b9c2d2; text-decoration: none; }
.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.primary:hover { background: #087383; }
.danger { color: var(--bad); border-color: #efc5c1; }
button.link { background: none; border: none; padding: 4px; color: var(--brand); }
button:disabled { opacity: .5; cursor: not-allowed; }
.button.small { padding: 6px 10px; font-size: .9rem; }
.wide { width: 100%; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink); width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #a9e3ea; border-color: var(--brand); }
textarea { resize: vertical; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--soft); }
label > input, label > select, label > textarea, label .row { color: var(--ink); }
.row { display: flex; gap: 8px; align-items: center; }
.row select { flex: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  margin-bottom: 16px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.grid-form .span2 { grid-column: span 2; }
form.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
form.inline label { flex-direction: row; align-items: center; gap: 6px; }
form.inline input, form.inline select { width: auto; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; background: #eaf1ff; border: 1px solid #c9d8f7; }
.flash.ok { background: #e8f6ee; border-color: #bfe3cd; }
.flash.error { background: #fdecea; border-color: #f2c4bf; color: #7d221b; }
.flash.warn { background: #fff5e5; border-color: #f3d6a6; }

/* login */
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.login h1 { justify-content: center; font-size: 1.25rem; }
.login label { text-align: left; }
.login-band { background: var(--navy); border-radius: 6px; padding: 18px 16px; margin: -4px -4px 0; }
.login-band img { width: 100%; max-width: 280px; display: block; margin: 0 auto; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 2px; color: var(--ink); }
a.tile:hover { border-color: var(--brand); text-decoration: none; }
.tile-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: var(--soft); }
.tile-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: .8rem; color: var(--soft); }
.tile.warn .tile-value { color: var(--warn); }

/* tables */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: var(--soft);
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
table.list th.num { text-align: right; }
table.list td { padding: 9px 12px; border-bottom: 1px solid #edf0f5; vertical-align: top; }
table.list tbody tr:last-child td { border-bottom: none; }
table.list tfoot th { border-top: 2px solid var(--line); border-bottom: none; color: var(--ink); font-size: .9rem; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td, table.list tbody tr:hover td { background: #f6f9ff; }
tr.dim td { opacity: .55; }
.products .desc { max-width: 520px; white-space: pre-line; color: var(--soft); font-size: .9rem; }
.todo { color: var(--warn); font-style: italic; font-size: .85rem; }
.pencil { font-size: 1.1rem; }
.editrow td { background: #f6f9ff; }
.sum { text-align: right; color: var(--soft); }

.filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.filters select, .filters input[type=date] { width: auto; }
.filters label { flex-direction: row; align-items: center; gap: 6px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px; background: #eef1f6; color: var(--soft); vertical-align: middle; }
.s-sent { background: #e2f5f7; color: #08707f; }
.s-paid, .s-accepted { background: #e3f5ea; color: var(--ok); }
.s-draft { background: #f0f1f4; color: #6b7280; }
.s-cancelled, .s-declined { background: #fbe9e7; color: var(--bad); }
.s-invoiced { background: #efe8fb; color: #6a3fb5; }

/* invoices | drafts tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs a { padding: 9px 16px; color: var(--soft); border-bottom: 3px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.on { color: var(--ink); border-bottom-color: var(--brand); }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #fff1dc;
  color: var(--warn); font-size: .75rem; text-align: center; }
.draftbar { background: #fffaf0; border-color: #f3d6a6; }

/* expenses */
.dropzone { border: 2px dashed #b9c6d8; background: #fbfcfe; display: flex; flex-direction: column; gap: 10px; }
.dropzone.over { border-color: var(--brand); background: #eef8f9; }
.dz-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.dz-actions label.small { flex-direction: row; align-items: center; gap: 6px; }
.dz-actions input[type=date] { width: auto; }
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.review-head p { margin: 0 0 10px; }
table.review .catsel { min-width: 180px; font-size: .85rem; padding: 5px 6px; }
tr.flagged td { background: #fffaf0; }
.flags { display: flex; flex-direction: column; gap: 3px; margin-top: 4px; }
.flag { font-size: .78rem; color: var(--soft); }
.warnflag { color: var(--warn); }
.personalflag { color: #8a3fb5; }
.dupflag { color: #08707f; }
.small-btn { padding: 4px 9px; font-size: .82rem; }
.danger-link { color: var(--bad) !important; }
.money-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
label.check input { width: auto; }
.gst-return { max-width: 560px; }
.gst-return > div { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.gst-return .grand { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 8px; font-size: 1.1rem; }

/* document view */
.actionbar { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; padding: 12px 16px; }
.meta-row { margin: -4px 0 16px; }

/* product inline form */
.product-form { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px 14px; }
.product-form .pf-desc { grid-column: span 3; }
.product-form .pf-active { grid-column: span 2; }
.product-form .pf-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: end; }

/* quote/invoice editor */
.lines-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.lines-head h2 { margin: 0; }
.lines-head label { flex-direction: row; align-items: center; }
.lines-head select { width: auto; }
table.lines { width: 100%; border-collapse: collapse; margin: 10px 0; }
table.lines th { text-align: left; font-size: .78rem; text-transform: uppercase; color: var(--soft); padding: 6px; }
table.lines th.num { text-align: right; }
table.lines td { padding: 6px; vertical-align: top; border-top: 1px solid #edf0f5; }
table.lines .c-item { width: 46%; }
table.lines .c-item textarea { margin-top: 4px; font-size: .9rem; overflow: hidden; }
table.lines .c-qty { width: 8%; } table.lines .c-price { width: 12%; } table.lines .c-tax { width: 18%; }
table.lines .c-amt { width: 12%; padding-top: 14px; font-weight: 600; }
table.lines .remove { color: var(--bad); padding-top: 10px; }
.table-wrap table.lines { margin: 0; }
.card .table-wrap { border: none; }
.totals { margin-left: auto; max-width: 320px; margin-top: 12px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 7px; font-weight: 700; font-size: 1.1rem; }

@media (max-width: 760px) {
  .topbar { padding: 0 12px; gap: 6px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .topbar nav a { padding: 10px 8px; white-space: nowrap; }
  .topbar .logout { margin-left: auto; }
  main { padding: 16px 16px 30px; }
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .span2 { grid-column: span 1; }
  .product-form { grid-template-columns: 1fr; }
  .money-grid { grid-template-columns: 1fr 1fr; }
  .product-form .pf-desc, .product-form .pf-active { grid-column: span 1; }
  /* editor lines become stacked cards */
  table.lines thead { display: none; }
  table.lines, table.lines tbody, table.lines tr, table.lines td { display: block; width: 100% !important; }
  table.lines tr.line { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 0;
    border-top: 1px solid var(--line); }
  table.lines td { border: none; padding: 0; }
  table.lines .c-item, table.lines .c-tax { grid-column: span 2; }
  table.lines .c-amt { text-align: left; padding-top: 4px; }
}
