:root {
  --bg: #f5f6f8; --panel: #fff; --ink: #1d2433; --muted: #6b7385; --line: #e2e5eb;
  --brand: #12355b; --accent: #1f6feb; --ok: #1a7f37; --warn: #9a6700; --bad: #c62828;
  --ok-bg: #e8f5ec; --warn-bg: #fff6e0; --bad-bg: #fdecec; --draft-bg: #eef1f6;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.right, td.num, th.num { text-align: right; }
.nowrap { white-space: nowrap; }
pre, code { font-family: Consolas, monospace; font-size: .85rem; }
pre { background: #0f172a; color: #e2e8f0; padding: .8rem; border-radius: 6px; overflow: auto; white-space: pre-wrap; }

/* Layout */
body.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: #dbe6f3; padding: 1rem .8rem; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { color: #fff; font-weight: 600; font-size: 1.02rem; display: block; margin-bottom: 1rem; line-height: 1.2; }
.sidebar .brand span { display: block; font-size: .7rem; letter-spacing: .15em; color: #9fb7d3; }
.sidebar nav { flex: 1; }
.sidebar nav a { display: flex; justify-content: space-between; align-items: center; color: #dbe6f3; padding: .32rem .55rem; border-radius: 5px; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.16); color: #fff; }
.sidebar h4 { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #8ea9c8; margin: 1rem .55rem .3rem; }
.sidebar .who { border-top: 1px solid rgba(255,255,255,.15); padding-top: .7rem; font-size: .85rem; }
.sidebar .who .muted { color: #8ea9c8; }
.badge { background: #f59e0b; color: #1d2433; border-radius: 10px; padding: 0 .45rem; font-size: .75rem; font-weight: 700; }
.content { padding: 1.4rem 1.8rem 3rem; max-width: 1400px; }
body.simple { display: flex; justify-content: center; }
.narrow { width: min(880px, 100%); padding: 2rem 1rem; }
.maintenance { max-width: 640px; margin: 15vh auto; background: #fff; padding: 2rem; border-radius: 10px; border: 1px solid var(--line); }

/* Panels, cards, alerts */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.2rem; margin-bottom: 1rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; }
.card .label { color: var(--muted); font-size: .8rem; }
.card .value { font-size: 1.35rem; font-weight: 600; margin-top: .2rem; }
.card.attention { border-color: #f59e0b; background: var(--warn-bg); }
.alert { padding: .65rem .9rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; white-space: pre-line; }
.alert.ok { background: var(--ok-bg); border-color: #b7e1c2; color: var(--ok); }
.alert.bad { background: var(--bad-bg); border-color: #f3b9b9; color: var(--bad); }
.alert.warn { background: var(--warn-bg); border-color: #f2d48b; color: var(--warn); }
.alert.validation:not(.validation-summary-errors) { display: none; }
.alert ul { margin: 0; padding-left: 1.2rem; }
.pill { display: inline-block; padding: .05rem .5rem; border-radius: 10px; font-size: .78rem; background: var(--draft-bg); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.draft { background: var(--draft-bg); color: #3b4a63; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--panel); }
.panel table { background: transparent; }
th, td { padding: .42rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.subtotal td { font-weight: 600; background: #fafbfc; }
tbody tr:hover td { background: #fafcff; }
td input, td select { width: 100%; }

/* Forms */
form.inline { display: inline; }
.toolbar { display: flex; gap: .5rem; align-items: end; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar .spacer { flex: 1; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .7rem 1rem; }
.grid .wide { grid-column: 1 / -1; }
label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
label.check { display: flex; gap: .4rem; align-items: center; color: var(--ink); font-size: .9rem; }
input, select, textarea { font: inherit; padding: .38rem .5rem; border: 1px solid #c9ced8; border-radius: 5px; background: #fff; color: var(--ink); width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 4.5rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid #b6d0ff; border-color: var(--accent); }
.field-validation-error { color: var(--bad); font-size: .8rem; }
button, .button { font: inherit; padding: .42rem .9rem; border-radius: 5px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; display: inline-block; white-space: nowrap; }
.button:hover { text-decoration: none; }
button.secondary, .button.secondary { background: #fff; color: var(--accent); }
button.danger, .button.danger { background: #fff; color: var(--bad); border-color: var(--bad); }
button.link { background: none; border: none; color: inherit; padding: 0; text-decoration: underline; cursor: pointer; }
button.small, .button.small { padding: .2rem .55rem; font-size: .82rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem 1rem; margin: 0 0 1rem; background: var(--panel); }
legend { font-weight: 600; padding: 0 .4rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 1000px) { .two { grid-template-columns: 1fr; } body.app { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }
.totals { margin-left: auto; width: 340px; }
.totals td { border: none; padding: .2rem .5rem; }
.question { border-left: 4px solid #f59e0b; }
.question .options { display: flex; flex-direction: column; gap: .25rem; margin: .5rem 0; }
.pdf-frame { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.notes { margin: 0; padding-left: 1.1rem; }
.notes li { margin-bottom: .2rem; }
.drop { border: 2px dashed #b9c3d3; border-radius: 10px; padding: 1.4rem; text-align: center; background: #fbfcfe; }

/* Customer documents (quote/invoice) */
body.print { background: #fff; display: block; }
.doc { max-width: 820px; margin: 2rem auto; background: #fff; padding: 2.2rem; border: 1px solid var(--line); }
.doc header { display: flex; justify-content: space-between; gap: 2rem; margin-bottom: 1.6rem; }
.doc h1 { font-size: 1.8rem; letter-spacing: .08em; color: var(--brand); margin: 0; }
.doc .meta td { border: none; padding: .1rem .4rem; }
.doc .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-bottom: 1.4rem; }
.doc .footer { margin-top: 2rem; font-size: .82rem; color: var(--muted); white-space: pre-line; }
.noprint { text-align: center; margin: 1rem; }
@media print { .noprint { display: none; } .doc { border: none; margin: 0; padding: 0; } body { background: #fff; } }
