@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --ink: #041B33;
  --ink2: #0B2A52;
  --surface: #F4F6F9;
  --card: #FFFFFF;
  --line: #DDE4EC;
  --teal: #0B2A52;       /* brand navy — primary actions, links, focus */
  --teal-dark: #041B33;
  --teal-soft: #E7ECF4;
  --amber: #E2231A;       /* brand red — tags, accents */
  --amber-soft: #FDEAEA;
  --text: #16202C;
  --mut: #5C6B7A;
  --red: #D81E1E;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Montserrat', system-ui, sans-serif; color: var(--text); background: var(--surface); }
.h-display, h1, h2, h3 { font-family: 'Montserrat', sans-serif; font-weight: 700; color: var(--ink); }
.mono { font-family: 'JetBrains Mono', monospace; }
.muted { color: var(--mut); }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- shared form bits ---------- */
.stack { display: grid; gap: 14px; }
label { display: grid; gap: 5px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); }
input, select, textarea {
  font: 14px 'Montserrat', sans-serif; color: var(--text);
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #FBFCFB; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--teal); color: #fff; border: 1px solid var(--teal);
  font: 600 14px 'Montserrat', sans-serif; padding: 10px 18px; border-radius: 10px; cursor: pointer;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn-wide { width: 100%; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--red); border-color: #EBC6BE; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.err { background: #F8E7E3; border: 1px solid #EBC6BE; color: var(--red); font-size: 13px; padding: 9px 12px; border-radius: 9px; }
.flash { background: var(--teal-soft); border: 1px solid #BFDCD4; color: var(--teal-dark); font-size: 13px; padding: 9px 12px; border-radius: 9px; margin-bottom: 14px; }
.warn-box { background: var(--amber-soft); border: 1px solid #EDD3A6; color: #8A5A13; font-size: 13px; padding: 10px 12px; border-radius: 9px; }

/* ---------- brand ---------- */
.brand-lockup { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; background: var(--teal); color: #fff; font-size: 21px; flex: none;
}
.brand-name { font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 19px; color: var(--ink); display: block; line-height: 1.1; }
.brand-name em { font-style: normal; color: var(--amber); }
.brand-sub { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .22em; color: var(--mut); }
.logo-img { display: block; height: auto; }
.login-logo { width: 300px; max-width: 100%; }
.install-logo { width: 260px; max-width: 100%; }
.sidebar-logo-wrap { padding: 18px 16px 10px; }
.sidebar-logo { width: 100%; height: auto; }

/* ============================================================
   LOGIN — form left, benefits image right
   ============================================================ */
.login-body { background: var(--ink); }
.login-split { display: grid; grid-template-columns: minmax(380px, 480px) 1fr; min-height: 100vh; }

.login-left { background: var(--card); display: flex; align-items: center; justify-content: center; padding: 40px 32px; }
.login-form-wrap { width: 100%; max-width: 360px; }
.login-title { font-size: 30px; font-weight: 800; margin: 34px 0 6px; }
.login-form { margin-top: 20px; }
.login-foot { font-size: 12px; margin-top: 22px; }

.login-right {
  position: relative;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(11,42,82,.6), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(226,35,26,.22), transparent 55%),
    var(--ink);
  background-size: cover; background-position: center;
  display: flex; align-items: center;
}
.login-right.has-image::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(15,27,23,.92) 15%, rgba(15,27,23,.62) 60%, rgba(15,27,23,.85));
}
.login-right-overlay { position: relative; padding: 56px clamp(32px, 6vw, 88px); max-width: 720px; }
.eyebrow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .24em; color: var(--amber); margin: 0 0 12px; }
.benefits-title { color: #fff; font-size: clamp(26px, 3.2vw, 38px); font-weight: 800; line-height: 1.15; margin: 0 0 30px; }
.benefits { list-style: none; margin: 0; padding: 0; display: grid; gap: 20px; }
.benefits li { display: flex; gap: 14px; color: #C9D6D1; font-size: 14px; line-height: 1.55; }
.benefits strong { color: #fff; font-weight: 600; }
.benefit-ic {
  flex: none; width: 40px; height: 40px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 18px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14);
}
.benefits-note { margin-top: 32px; font-size: 13px; color: #8BA39B; border-top: 1px solid rgba(255,255,255,.12); padding-top: 18px; }

@media (max-width: 860px) {
  .login-split { grid-template-columns: 1fr; }
  .login-right { min-height: 420px; }
}

/* ---------- installer ---------- */
.auth-body { background: var(--ink); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.install-wrap { width: 100%; max-width: 460px; }
.install-wrap .brand-lockup { justify-content: center; margin-bottom: 26px; }
.install-wrap .brand-name { color: #fff; }
.install-wrap .brand-sub { color: #8BA39B; }
.install-card { display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }

/* ============================================================
   APP SHELL
   ============================================================ */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex: none; background: var(--ink); display: flex; flex-direction: column; }
.sidebar .brand { padding: 18px 16px; display: flex; align-items: center; gap: 10px; }
.sidebar .brand .brand-mark { width: 36px; height: 36px; font-size: 18px; }
.sidebar .brand-name { color: #fff; font-size: 15px; }
.side-nav { flex: 1; padding: 8px 10px; display: grid; gap: 4px; align-content: start; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 9px;
  color: #93A69F; font-size: 14px; font-weight: 500; border-left: 3px solid transparent;
}
.side-nav a:hover { text-decoration: none; background: rgba(255,255,255,.05); }
.side-nav a.active { background: var(--ink2); color: #fff; border-left-color: var(--amber); }
.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  background: var(--amber); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700;
}
.side-foot { border-top: 1px solid #22332C; padding: 12px 14px; }
.side-foot .who { color: #fff; font-size: 13px; font-weight: 600; margin: 0; }
.side-foot .role { color: #8BA39B; font-size: 11px; margin: 2px 0 10px; }
.side-foot a { color: #93A69F; font-size: 13px; }

.main { flex: 1; min-width: 0; padding: 28px clamp(18px, 4vw, 44px); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; font-weight: 800; margin: 0; }
.head-tools { display: flex; align-items: center; gap: 8px; }
.head-tools input[type=search] { width: 210px; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.update-banner {
  display: block; text-decoration: none; margin-bottom: 16px; padding: 12px 16px; border-radius: 12px;
  background: var(--amber-soft); border: 1px solid #F3C6C4; color: var(--teal-dark); font-size: 14px;
}
.update-banner:hover { text-decoration: none; opacity: .92; }
.update-banner strong { color: var(--amber); }
.stat { display: flex; align-items: center; gap: 12px; }
.stat .n { font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 26px; color: var(--ink); line-height: 1; }
.stat .l { font-size: 12px; color: var(--mut); margin-top: 3px; }
.stat-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--teal-soft); color: var(--teal-dark); display: inline-flex; align-items: center; justify-content: center; font-size: 17px; flex: none; }
.stat-ic.c1 { background: #E7ECF4; color: #0B2A52; }  /* navy */
.stat-ic.c2 { background: #FDEAEA; color: #E2231A; }  /* red */
.stat-ic.c3 { background: #EAF2F0; color: #1E7A5F; }  /* teal-green, complements navy+red */
.stat-ic.c4 { background: #FCF1E3; color: #B4741A; }  /* warm gold */

.tag { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 6px; background: var(--amber-soft); color: #8A5A13; border: 1px solid #EDD3A6; }
.pill { font-size: 11px; font-weight: 500; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); background: #EEF1EF; color: var(--mut); }
.pill.on { background: var(--teal-soft); color: var(--teal-dark); border-color: #BFDCD4; }
.pill.off { background: #F8E7E3; color: var(--red); border-color: #EBC6BE; }

.item { margin-bottom: 12px; }
.item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.item h3 { margin: 0; font-size: 16px; }
.item .meta { font-size: 12px; color: var(--mut); margin: 5px 0 0; }
.item .row-actions { margin-left: auto; display: flex; gap: 6px; }

.cred {
  margin-top: 10px; background: #FAFBFA; border: 1px solid var(--line); border-radius: 9px;
  padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; font-size: 12px;
}
.cred .lbl { font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); font-size: 11px; }
.cred .mono { font-size: 12px; }
.cred button { background: none; border: none; cursor: pointer; color: var(--mut); font-size: 13px; padding: 2px 4px; }
.cred button:hover { color: var(--teal-dark); }

.empty { border: 1.5px dashed var(--line); background: #FAFBFA; border-radius: 12px; padding: 44px 20px; text-align: center; }
.empty p { margin: 4px 0; }
.empty .t { font-weight: 600; }
.empty .h { font-size: 12px; color: var(--mut); }

table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 10px 12px; font-size: 13px; border-top: 1px solid var(--line); }
table.list th { background: #FAFBFA; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); border-top: none; }

/* ---------- modal ---------- */
dialog {
  border: none; border-radius: 16px; padding: 0; width: min(560px, 94vw);
  max-height: 90vh;
}
dialog::backdrop { background: rgba(15,27,23,.55); }
.modal-inner { padding: 22px; }
.modal-inner h2 { margin: 0 0 16px; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.fieldset-cred { background: var(--teal-soft); border: 1px solid #BFDCD4; border-radius: 12px; padding: 12px; display: grid; gap: 12px; }
.fieldset-cred .fs-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--teal-dark); }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .cols2 { grid-template-columns: 1fr; } }

/* ---------- generic view dialog ---------- */
.view-list { display: grid; gap: 10px; margin-top: 4px; }
.view-row { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: start; font-size: 13px; }
.view-lbl { font-weight: 600; text-transform: uppercase; letter-spacing: .05em; font-size: 11px; color: var(--mut); padding-top: 2px; }
.view-val { color: var(--text); }

/* ---------- line item editor (invoices/quotes/receipts) ---------- */
table.items { width: 100%; border-collapse: collapse; margin-top: 6px; }
table.items th, table.items td { padding: 7px 8px; font-size: 13px; border-bottom: 1px solid var(--line); }
table.items th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); text-align: left; }
table.items input { padding: 6px 8px; }
table.items td.num { width: 90px; }
table.items td.money { width: 120px; }
table.items td.act { width: 36px; text-align: center; }
.items-actions { margin-top: 10px; }
.totals-box { margin-top: 14px; display: grid; gap: 6px; justify-items: end; }
.totals-box .row { display: flex; gap: 18px; font-size: 14px; }
.totals-box .row .k { color: var(--mut); min-width: 90px; text-align: right; }
.totals-box .row.grand { font-weight: 800; font-size: 17px; color: var(--ink); border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; }

/* ---------- printable billing document ---------- */
.doc-page { max-width: 760px; margin: 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 40px; }
.doc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 2px solid var(--ink); padding-bottom: 20px; margin-bottom: 24px; }
.doc-biz strong { font-family: 'Montserrat', sans-serif; font-size: 18px; }
.doc-biz p { margin: 3px 0 0; font-size: 12px; color: var(--mut); }
.doc-meta { text-align: right; }
.doc-meta h1 { font-size: 24px; margin: 0; letter-spacing: .04em; }
.doc-meta p { margin: 4px 0 0; font-size: 13px; color: var(--mut); }
.doc-meta .num { font-family: 'JetBrains Mono', monospace; font-weight: 600; color: var(--text); }
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 26px; }
.doc-parties h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); }
.doc-parties p { margin: 0; font-size: 14px; line-height: 1.5; }
table.doc-items { width: 100%; border-collapse: collapse; }
table.doc-items th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); border-bottom: 2px solid var(--line); padding: 8px 6px; }
table.doc-items td { padding: 10px 6px; font-size: 14px; border-bottom: 1px solid var(--line); }
table.doc-items td.r, table.doc-items th.r { text-align: right; }
.doc-footer-note { margin-top: 28px; font-size: 12px; color: var(--mut); border-top: 1px solid var(--line); padding-top: 14px; }
.doc-actions { max-width: 760px; margin: 0 auto 16px; display: flex; justify-content: space-between; }
@media print {
  .doc-actions, .no-print { display: none !important; }
  body { background: #fff; }
  .doc-page { border: none; padding: 0; }
}

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; }
  .side-nav { display: flex; padding: 8px; }
  .side-nav a { white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .side-nav a.active { border-bottom-color: var(--amber); }
  .side-foot { border-top: none; margin-left: auto; display: flex; align-items: center; gap: 10px; }
  .side-foot .role { display: none; }
}
