:root {
  --ink: #17302d;
  --muted: #667572;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --line: #dce5e1;
  --brand: #0e6655;
  --brand-dark: #08473c;
  --danger: #b43c31;
  --warning: #a46300;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; }
a { color: var(--brand-dark); text-underline-offset: 2px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(1.7rem, 3vw, 2.35rem); letter-spacing: -.03em; }
h2 { margin-bottom: 1rem; font-size: 1.1rem; }
label { display: grid; gap: .38rem; font-weight: 650; font-size: .91rem; }
input, textarea, select {
  width: 100%; border: 1px solid #b9c9c2; border-radius: .55rem; background: #fff;
  padding: .66rem .72rem; color: var(--ink); font: inherit;
}
input:focus, textarea:focus, select:focus { outline: 3px solid #b9ded5; border-color: var(--brand); }
textarea { resize: vertical; }
button { font: inherit; cursor: pointer; }

.topbar {
  min-height: 4.35rem; padding: .75rem max(1.1rem, calc((100% - 1200px) / 2)); display: flex;
  align-items: center; gap: 1.5rem; background: var(--ink); color: white;
}
.brand { color: white; text-decoration: none; font-size: 1.12rem; font-weight: 800; letter-spacing: -.025em; white-space: nowrap; }
.brand span { color: #a7e8d8; }
.topbar nav { display: flex; gap: 1rem; }
.topbar nav a { color: #d8e7e3; text-decoration: none; font-size: .94rem; }
.topbar nav a:hover { color: white; }
.account { margin-left: auto; display: flex; align-items: center; gap: .8rem; color: #d8e7e3; font-size: .83rem; }
.account form { margin: 0; }
.install-button { min-height: 2rem; padding: .35rem .65rem; border-color: #7da99e; background: transparent; color: #fff; font-size: .78rem; }
.install-button:hover { border-color: #a7e8d8; color: #a7e8d8; }
.page { width: min(1200px, calc(100% - 2.2rem)); margin: 0 auto; padding: 2.3rem 0 3.5rem; }
.page-heading { display: flex; gap: 1rem; justify-content: space-between; align-items: flex-start; margin-bottom: 1.5rem; }
.eyebrow { margin-bottom: .42rem; color: var(--brand); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.back { display: inline-block; margin-bottom: 1rem; color: var(--muted); font-size: .9rem; }

.button { display: inline-flex; justify-content: center; align-items: center; min-height: 2.45rem; padding: .55rem .85rem; border: 1px solid #9bb8ae; border-radius: .55rem; background: #fff; color: var(--ink); text-decoration: none; font-size: .9rem; font-weight: 700; }
.button:hover { border-color: var(--brand); color: var(--brand-dark); }
.button.primary { border-color: var(--brand); background: var(--brand); color: white; }
.button.primary:hover { background: var(--brand-dark); color: white; }
.link-button { min-height: auto; padding: .25rem; border: 0; background: transparent; color: #fff; font-weight: 600; }
.danger-button { border-color: #e1aaa2; color: var(--danger); }
.danger-button:hover { border-color: var(--danger); color: #8b271d; }

.card { padding: 1.25rem; border: 1px solid var(--line); border-radius: .85rem; background: var(--surface); box-shadow: 0 8px 18px rgb(17 49 43 / 4%); }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: .85rem; margin-bottom: 1rem; }
.metric { padding: 1.05rem; border: 1px solid var(--line); border-radius: .85rem; background: #fff; }
.metric span { display: block; color: var(--muted); font-size: .82rem; }
.metric strong { display: block; margin-top: .38rem; font-size: 1.7rem; }
.metric.warning strong { color: var(--warning); }
.two-column { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.client-workspace { align-items: start; }
.stack { display: grid; gap: 1rem; }
.clean-list { display: grid; gap: .65rem; padding: 0; margin: 0; list-style: none; }
.clean-list li { line-height: 1.35; }
.badge { display: inline-block; margin-right: .25rem; padding: .16rem .42rem; border-radius: 99px; background: #dcefe9; color: #176152; font-size: .73rem; font-weight: 750; }
.badge.danger { background: #f6e0dc; color: var(--danger); }

.search { display: flex; gap: .6rem; max-width: 710px; margin-bottom: 1rem; }
.search input { flex: 1; }
.table-card { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: .9rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .9rem; }
th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .045em; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f8fbfa; }
.company { font-weight: 750; }
.empty { padding: 1.4rem; margin: 0; color: var(--muted); }

.form-card { max-width: 820px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: .55rem; font-weight: 500; }
.check input { width: auto; }
.actions { display: flex; justify-content: flex-end; gap: .65rem; }
.alert { margin-bottom: 1rem; padding: .8rem .9rem; border-radius: .6rem; font-size: .9rem; }
.alert.error { border: 1px solid #e8bdb6; background: #fff4f1; color: #8b271d; }
.alert.warning { border: 1px solid #e9d39c; background: #fff9e8; color: #745100; }
.alert a { margin-left: .3rem; }

.details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.details div { min-width: 0; }
.details span { display: block; margin-bottom: .25rem; color: var(--muted); font-size: .78rem; }
.details strong { display: block; overflow-wrap: anywhere; font-size: .94rem; }
.inline-form { display: flex; gap: .6rem; }
.inline-form input { min-width: 0; }
.inline-form.compact { margin-top: .55rem; align-items: center; }
.inline-form.compact input { min-width: 12rem; }
.subnav { display: flex; flex-wrap: wrap; gap: .55rem; margin: -0.55rem 0 1rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.access-list li { display: flex; align-items: center; justify-content: space-between; gap: .7rem; }
.client-picker { margin: 0; padding: .95rem; border: 1px solid var(--line); border-radius: .65rem; }
.client-picker legend { padding: 0 .3rem; font-weight: 700; font-size: .91rem; }
.client-picker-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem 1rem; max-height: 17rem; overflow-y: auto; }
.client-picker-list .check { min-width: 0; overflow-wrap: anywhere; }
.quote-items { display: grid; gap: .65rem; margin-bottom: .65rem; }
.quote-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(12rem, .42fr) auto; align-items: end; gap: .6rem; }
.history-filters { display: flex; flex-wrap: wrap; gap: .35rem; margin: -0.25rem 0 1rem; }
.history-filters a { padding: .32rem .48rem; border-radius: .45rem; color: var(--muted); font-size: .78rem; text-decoration: none; }
.history-filters a:hover, .history-filters a.active { background: #dcefe9; color: #176152; font-weight: 750; }
.pager { display: flex; justify-content: space-between; gap: .6rem; margin-top: 1rem; }
.history { min-height: 15rem; }
.timeline { display: grid; gap: 1rem; padding: 0; margin: 0; list-style: none; }
.timeline li { position: relative; padding-left: 1rem; border-left: 2px solid #c9ded7; }
.timeline li::before { content: ""; position: absolute; top: .25rem; left: -.34rem; width: .55rem; height: .55rem; border-radius: 50%; background: var(--brand); }
.timeline p { margin: .5rem 0; white-space: pre-wrap; font-size: .92rem; }
.timeline time, .timeline small { color: var(--muted); font-size: .77rem; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 1.5rem; }
.login-card { width: min(100%, 425px); padding: 2rem; border: 1px solid var(--line); border-radius: 1rem; background: #fff; box-shadow: 0 20px 45px rgb(17 49 43 / 10%); }
.login-card h1 { font-size: 2rem; }
.login-card > p { color: var(--muted); }
.message-card { max-width: 540px; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: .5rem 1rem; }
  .topbar nav { order: 3; width: 100%; }
  .account { margin-left: auto; }
  .metrics, .two-column, .details { grid-template-columns: 1fr; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .page-heading > .button { align-self: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .client-picker-list { grid-template-columns: 1fr; }
  .quote-item { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
}

@media (max-width: 480px) {
  .page { width: min(100% - 1.2rem, 1200px); padding-top: 1.35rem; }
  .account span { display: none; }
  .install-button { max-width: 8.5rem; }
  .search, .inline-form { flex-direction: column; }
  .inline-form.compact { align-items: stretch; }
  th, td { padding: .7rem; }
}
