/* Lumina ERP — same layout system as the Greig ERP, in Lumina's charcoal & grey (from the logo). */
:root {
  --brand: #2b2c2e; --brand-dark: #161718; --brand-soft: #eeeff0; --brand-line: #d3d4d6; --brand-grey: #6b6c6e;
  --ink: #1d2433; --muted: #667085; --line: #e2e5ea; --slate: #475467;
  --bg: #f4f4f5; --card: #ffffff; --sidebar: #1e1f21; --sidebar-ink: #c9cacc; --sidebar-muted: #85868a;
  --green: #1f7a4d; --green-soft: #e5f4ec; --amber: #b7791f; --amber-soft: #fdf3e1;
  --red: #b42318; --red-soft: #fdecea; --blue: #2a6fb0; --blue-soft: #e6f0fa; --grey-soft: #eef0f3;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.45; }
a { color: #3d5a80; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; font-weight: 650; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.12rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.muted { font-size: .9rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }
code { background: var(--grey-soft); padding: .1em .35em; border-radius: 4px; font-size: .9em; }
svg.i { width: 18px; height: 18px; flex: 0 0 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- layout ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex: 0 0 240px; background: var(--sidebar); color: var(--sidebar-ink); padding: 1rem .75rem 2rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand, .auth .brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem 1rem; color: #fff; font-weight: 700; letter-spacing: .01em; }
.sidebar .brand .logo { width: 38px; height: 38px; border-radius: 9px; background: #fff; display: grid; place-items: center; flex: 0 0 38px; }
.sidebar .brand .logo img { width: 30px; height: auto; }
.auth .auth-logo { display: block; width: 220px; margin: 0 auto 1.25rem; }
.sidebar .brand small, .auth .brand small { display: block; font-weight: 400; color: var(--sidebar-ink); font-size: .72rem; }
.nav-group { margin-top: .9rem; }
.nav-group > span { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); padding: 0 .5rem .3rem; }
.nav-group a { display: flex; align-items: center; gap: .6rem; padding: .42rem .6rem; border-radius: 7px; color: var(--sidebar-ink); font-size: .92rem; }
.nav-group a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav-group a.active { background: var(--brand-grey); color: #fff; }
.nav-group a .count { margin-left: auto; background: rgba(255,255,255,.16); border-radius: 999px; font-size: .7rem; padding: .05rem .45rem; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .7rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .search { flex: 1; max-width: 420px; }
.topbar .user { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
.topbar .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; font-size: .8rem; }
.menu-toggle { display: none; background: none; border: 0; padding: .3rem; cursor: pointer; color: var(--ink); }
.content { padding: 1.5rem; max-width: 1440px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.crumbs { font-size: .82rem; color: var(--muted); margin-bottom: .25rem; }
.crumbs a { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.actions form { margin: 0; }

/* ---- cards & grids ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.15rem 1.25rem; margin-bottom: 1.25rem; }
.card > h2:first-child, .card-head { margin-bottom: .85rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card.flush { padding: 0; overflow: visible; }
.card.flush > .card-head { padding: 1rem 1.25rem 0; }
.grid { display: grid; gap: 1.25rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.kpi .label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi .value { font-size: 1.45rem; font-weight: 700; margin-top: .25rem; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .82rem; color: var(--muted); margin-top: .15rem; }
.kpi.brand { border-top: 3px solid var(--brand); }
.btn.primary:focus-visible, .btn:focus-visible { outline: 2px solid var(--brand-grey); outline-offset: 2px; }
.kpi.warn .value { color: var(--amber); } .kpi.bad .value { color: var(--red); } .kpi.good .value { color: var(--green); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; font-size: .92rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th { text-align: left; font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .6rem .75rem; border-bottom: 1px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.t td { padding: .6rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: #f8f8f9; }
table.t .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tfoot td { font-weight: 700; border-top: 2px solid var(--line); background: #fafbfc; }
table.t tr.sub td { background: #f8f9fb; font-weight: 600; }
table.t td.empty { text-align: center; color: var(--muted); padding: 2rem; }
.card.flush table.t th:first-child, .card.flush table.t td:first-child { padding-left: 1.25rem; }
.card.flush table.t th:last-child, .card.flush table.t td:last-child { padding-right: 1.25rem; }

/* ---- badges ---- */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: .14rem .55rem; border-radius: 999px; white-space: nowrap; background: var(--grey-soft); color: var(--slate); }
.b-green { background: var(--green-soft); color: var(--green); } .b-blue { background: var(--blue-soft); color: var(--blue); }
.b-amber { background: var(--amber-soft); color: var(--amber); } .b-red { background: var(--red-soft); color: var(--red); }
.b-grey { background: var(--grey-soft); color: var(--slate); } .b-brand { background: var(--brand-soft); color: var(--brand-dark); }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: .5rem .9rem; border-radius: 8px; font-size: .9rem; font-weight: 550; cursor: pointer; line-height: 1.2; font-family: inherit; white-space: nowrap; }
.btn:hover { text-decoration: none; background: #f8f9fa; }
.btn svg.i { width: 16px; height: 16px; flex-basis: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--red); border-color: #f1c4bf; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: .3rem .6rem; font-size: .82rem; }
.btn.link { border: 0; background: none; padding: 0; color: var(--brand-dark); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- forms ---- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.25rem; }
.form-grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .section { grid-column: 1 / -1; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-dark); font-weight: 700; border-bottom: 1px solid var(--brand-line); padding-bottom: .3rem; margin-top: .6rem; }
.field label, label.lbl { display: block; font-size: .84rem; font-weight: 600; margin-bottom: .3rem; color: var(--slate); }
.field .help { font-size: .78rem; color: var(--muted); margin-top: .25rem; }
.field .err { font-size: .8rem; color: var(--red); margin-top: .25rem; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=password], input[type=search], input[type=month], input[type=file], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid #cfd5dd; border-radius: 8px; font: inherit; font-size: .92rem; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-line); border-color: var(--brand); }
input[disabled], select[disabled] { background: var(--grey-soft); }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .92rem; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
.form-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.25rem; flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.filters input, .filters select { width: auto; min-width: 160px; }
.inline { display: inline; }

/* ---- line item editor ---- */
table.lines { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.lines th { font-size: .74rem; text-transform: uppercase; color: var(--muted); text-align: left; padding: .4rem .35rem; border-bottom: 1px solid var(--line); }
table.lines td { padding: .35rem; vertical-align: top; border-bottom: 1px dashed var(--line); }
table.lines input, table.lines select { padding: .4rem .45rem; font-size: .86rem; }
table.lines .w-qty { width: 80px; } table.lines .w-price { width: 130px; } table.lines .w-vat { width: 80px; } table.lines .w-amt { width: 130px; }
table.lines .tags { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; margin-top: .35rem; }
.totals { margin-left: auto; width: 320px; font-size: .95rem; }
.totals div { display: flex; justify-content: space-between; padding: .3rem 0; }
.totals .grand { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--line); margin-top: .3rem; padding-top: .5rem; }

/* ---- alerts ---- */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .92rem; border: 1px solid; }
.alert.ok { background: var(--green-soft); color: #14532d; border-color: #bfe3cf; }
.alert.error { background: var(--red-soft); color: #7a1a12; border-color: #f3c6c0; }
.alert.info { background: var(--blue-soft); color: #1d4f80; border-color: #c6dbf1; }
.alert.warn { background: var(--amber-soft); color: #7a4d0f; border-color: #f0d9ad; }
.alert ul { margin: .3rem 0 0 1.1rem; padding: 0; }

/* ---- tabs, modal, misc ---- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .55rem .9rem; font-size: .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--brand-dark); border-color: var(--brand); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
details.pop { position: relative; display: inline-block; }
details.pop > summary { list-style: none; }
details.pop > summary::-webkit-details-marker { display: none; }
details.pop > .pop-body { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(16,24,40,.15); padding: 1rem; width: 360px; }
details.pop > .pop-body .field { margin-bottom: .7rem; }
.progress { height: 8px; background: var(--grey-soft); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand-grey); border-radius: 999px; }
.progress.over > span { background: var(--red); }
.bars { display: flex; align-items: flex-end; gap: .9rem; height: 170px; padding-top: .5rem; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .3rem; height: 100%; justify-content: flex-end; }
.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; width: 100%; justify-content: center; }
.bars .pair span { width: 40%; max-width: 22px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .in { background: var(--brand); } .bars .out { background: #b9c1cd; }
.bars small { font-size: .74rem; }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.list li:last-child { border-bottom: 0; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.pagination { display: flex; gap: .3rem; justify-content: flex-end; padding: .9rem 1.25rem; flex-wrap: wrap; }
.pagination a, .pagination span { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 6px; font-size: .85rem; color: var(--ink); background: #fff; }
.pagination .current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pagination .disabled { color: var(--muted); }
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.unit-tile { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; font-size: .84rem; background: #fff; border-left: 4px solid var(--grey-soft); }
.unit-tile.occupied { border-left-color: var(--green); } .unit-tile.vacant { border-left-color: var(--amber); }
.unit-tile.reserved { border-left-color: var(--blue); } .unit-tile.maintenance { border-left-color: var(--red); } .unit-tile.sold { border-left-color: var(--slate); }
.unit-tile strong { display: block; font-size: .92rem; }

/* ---- auth ---- */
.auth { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 20% 20%, #3a3b3e, var(--sidebar) 60%); padding: 1rem; }
.auth .card { width: 100%; max-width: 400px; padding: 2rem; }
.auth .brand { color: var(--ink); justify-content: center; padding-bottom: 1.5rem; }
.auth .sidebar .brand small, .auth .brand small { color: var(--muted); }

/* ---- responsive ---- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
  body.nav-open .sidebar { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .menu-toggle { display: inline-flex; }
  .g2, .g3, .form-grid, .form-grid.g3 { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
  .topbar { padding: .6rem 1rem; }
  .topbar .user .who { display: none; }
  table.lines .tags { grid-template-columns: 1fr; }
  details.pop > .pop-body { width: 300px; }
}
@media print {
  .sidebar, .topbar, .actions, .filters, .no-print { display: none !important; }
  .content { padding: 0; } .card { box-shadow: none; border: 0; }
  body { background: #fff; }
}
textarea[name=body] { min-height: 560px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; line-height: 1.5; }
