:root {
  --g: #1d955e;
  --g-hover: #177a4c;
  --g-soft: #e6f5ee;
  --ink: #141816;
  --muted: #5b6b63;
  --subtle: #7a8a82;
  --bg: #f3f6f4;
  --surface: #fff;
  --line: #d5e0d9;
  --line-strong: #b7c7bd;
  --sidebar: #121614;
  --sidebar-fg: #eef3f0;
  --sidebar-muted: #9aa89f;
  --danger: #b42318;
  --warn: #b54708;
  --radius: 10px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}
[x-cloak] { display: none !important; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--g); text-decoration: none; }
a:hover { color: var(--g-hover); }
img { max-width: 100%; }
code, .mono { font-family: var(--mono); }

.auth-split { display: grid; min-height: 100vh; }
@media (min-width: 880px) { .auth-split { grid-template-columns: 1fr 1fr; } }
.auth-brand { background: var(--sidebar); color: var(--sidebar-fg); display: none; padding: 48px; }
@media (min-width: 880px) { .auth-brand { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-brand img { height: 56px; width: auto; }
.auth-panel { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.auth-card h1 { margin: 0 0 6px; font-size: 1.4rem; }
.auth-card p.lead { margin: 0 0 20px; color: var(--muted); font-size: 0.92rem; }
.guest-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 40px 24px 64px; }
.guest-logo { height: 44px; width: auto; margin: 0 0 20px; }
.guest-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.guest-card.wide { max-width: 980px; overflow-x: auto; }
.guest-card h1 { margin: 0 0 6px; font-size: 1.4rem; }
.guest-card p.lead { margin: 0 0 20px; color: var(--muted); font-size: 0.92rem; }
.guest-page.wide .guest-logo { display: none; }
.guest-page.wide { padding-top: 28px; }
.quote-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 3px solid #1d955e; padding-bottom: 12px; margin-bottom: 18px; }
.quote-head img { height: 48px; width: auto; }
.quote-title { text-align: right; font-size: 1.35rem; font-weight: 600; line-height: 1.2; }
.quote-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 8px; }
.quote-meta p { margin: 0 0 3px; }
.quote-k { color: var(--muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
@media (max-width: 700px) { .quote-meta { grid-template-columns: 1fr; } }
.quote-lines th, .quote-lines td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.quote-lines th { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); background: #eef3f0; }
.quote-lines .num, table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.quote-lines tfoot td { font-weight: 600; border-bottom: 0; }
.quote-terms { font-size: 12px; line-height: 1.45; color: #3d4a44; margin: 18px 0 8px; text-align: justify; }
.quote-terms p { margin: 0 0 8px; }
.logo-plate { display: inline-block; background: var(--sidebar); padding: 8px 10px; border-radius: 8px; margin-bottom: 16px; }
.logo-plate img { height: 36px; }

.shell { display: flex; min-height: 100vh; }
.menubar { display: flex; align-items: center; gap: 12px; background: var(--sidebar); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 30; }
.menubar img { height: 28px; width: auto; }
.menu-btn { background: transparent; color: #fff; border: 1px solid #3a463f; border-radius: 8px; padding: 6px 10px; font: 500 0.9rem var(--font); display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.burger { display: block; width: 16px; height: 2px; background: #fff; position: relative; }
.burger:before, .burger:after { content: ""; position: absolute; left: 0; width: 16px; height: 2px; background: #fff; }
.burger:before { top: -5px; }
.burger:after { top: 5px; }
.nav-backdrop { position: fixed; inset: 0; background: rgb(20 24 22 / 0.45); z-index: 40; }
.sidebar { width: 240px; background: var(--sidebar); color: var(--sidebar-fg); display: none; flex-direction: column; }
@media (max-width: 959px) {
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: min(280px, 86vw); overflow: auto; }
  .sidebar.open { display: flex; }
  .main { padding: 16px 14px 48px; }
  h1.page { font-size: 1.55rem; }
}
@media (min-width: 960px) {
  .menubar, .nav-backdrop { display: none; }
  .sidebar { display: flex; position: sticky; top: 0; height: 100vh; }
}
.sidebar .brand { padding: 18px 16px; }
.sidebar .brand img { height: 32px; }
.sidebar nav { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar a { color: var(--sidebar-muted); padding: 8px 10px; border-radius: 8px; font-size: 0.92rem; }
.sidebar button.nav-parent { color: var(--sidebar-muted); padding: 8px 10px; border-radius: 8px; font-size: 0.92rem; width: 100%; text-align: left; background: none; border: 0; font-family: inherit; cursor: pointer; }
.sidebar a:hover, .sidebar a.active, .sidebar button.nav-parent:hover, .sidebar button.nav-parent.active { background: #1c2420; color: #fff; }
.sidebar a.active, .sidebar button.nav-parent.active { color: #fff; box-shadow: inset 3px 0 0 var(--g); }
.sidebar .nav-sub { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 8px 14px; }
.sidebar .nav-sub a { font-size: 0.86rem; padding: 6px 10px; }
.sales-nav { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 16px; }
.sales-nav a { padding: 6px 12px; border-radius: 999px; background: #eef3f0; color: var(--ink); font-size: 0.9rem; }
.sales-nav a.on { background: var(--g); color: #fff; }
.sales-stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 8px; }
.sales-stats .n { font-size: 1.45rem; }
.main { flex: 1; padding: 28px 28px 64px; }
.topbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 22px; align-items: center; }

h1.page { margin: 0 0 16px; font-size: 2rem; letter-spacing: -0.02em; color: var(--g); }
.desc { color: var(--muted); margin: 0 0 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 8px; padding: 8px 14px; font: 500 0.9rem var(--font); cursor: pointer; background: var(--g); color: #fff; }
.btn:hover { background: var(--g-hover); }
.btn.secondary { background: #eef3f0; color: var(--ink); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #912018; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 0.8rem; }
a.btn, a.btn:hover { color: #fff; }
a.btn.secondary, a.btn.secondary:hover { color: var(--ink); }
a.btn.ghost, a.btn.ghost:hover { color: var(--muted); }
a.btn.danger, a.btn.danger:hover { color: #fff; }

.field { margin-bottom: 12px; }
label { display: block; font-size: 0.8rem; margin-bottom: 4px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font: 0.95rem var(--font); background: var(--surface);
}
textarea { min-height: 90px; }
input.in-range { border-color: var(--g); background: var(--g-soft); }
input.near-floor { border-color: var(--warn); background: #fffaeb; }
input.out-range { border-color: var(--danger); background: #fef3f2; }
.range-note.in-range { color: #145c3a; }
.range-note.near-floor { color: var(--warn); }
.range-note.out-range { color: var(--danger); }
.price.near-floor { color: #7a5b00; background: #ffe58f; font-weight: 600; border-radius: 4px; padding: 0 4px; }
.price.out-range { color: var(--danger); background: #fde8e6; font-weight: 600; border-radius: 4px; padding: 0 4px; }
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 0.9rem; }
.alert.error { background: #fef3f2; color: var(--danger); }
.alert.ok { background: var(--g-soft); color: #145c3a; }
.alert.warn { background: #fffaeb; color: var(--warn); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 800px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr 1fr 1fr; } }
@media (min-width: 880px) { .grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.grid-5 .stat { padding: 12px 10px; }
.grid-5 .stat .n { font-size: 1.5rem; }
.grid-5 .muted { font-size: 12px; line-height: 1.3; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat .n { font-size: 1.8rem; font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); background: #eef3f0; padding: 10px 14px; }
td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: top; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef3f0; text-transform: capitalize; }
.badge.signed, .badge.active, .badge.occupied, .badge.paid, .badge.completed, .badge.live, .badge.approved { background: var(--g-soft); color: #145c3a; }
.badge.awaiting_signature, .badge.open, .badge.overdue, .badge.revoked, .badge.pending, .badge.live.attention { background: #fffaeb; color: var(--warn); }
.badge.in_progress { background: #eff8ff; color: #175cd3; }

.dialog { position: fixed; inset: 0; background: rgb(20 24 22 / 0.45); display: grid; place-items: center; padding: 16px; z-index: 40; }
.dialog .box { background: #fff; border-radius: 14px; padding: 20px; width: min(520px, 100%); max-height: 90vh; overflow: auto; position: relative; }
.dialog .box.wide { width: min(880px, 100%); }
.dialog-x { position: absolute; top: 8px; right: 8px; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.dialog-x:hover { background: #eef3f0; color: var(--ink); }
.dialog .box h3 { padding-right: 28px; }
.dialog .btn + .btn { margin-left: 8px; }

.sig canvas { width: 100%; height: 112px; border: 1px solid var(--line); border-radius: 8px; background: #fff; touch-action: none; }
.userchip { font-size: 0.85rem; color: var(--sidebar-muted); padding: 12px 16px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.muted { color: var(--muted); }
.right { text-align: right; }

.receptacle-tip { display: inline-flex; line-height: 0; cursor: zoom-in; }
.receptacle-zoom { display: none; }
#receptacle-pop {
  position: fixed;
  z-index: 80;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 10px 28px rgb(20 24 22 / 0.18);
  pointer-events: none;
}
#receptacle-pop[hidden] { display: none; }
