:root {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --ink: #17212b;
  --muted: #66727d;
  --border: #dfe5ea;
  --primary: #203246;
  --primary-hover: #162636;
  --green: #18794e;
  --green-bg: #e8f6ee;
  --amber: #936300;
  --amber-bg: #fff4d8;
  --red: #b42318;
  --red-bg: #fff0ee;
  --radius: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
button, a { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid #8bb9df; outline-offset: 2px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.55rem, 3vw, 2rem); line-height: 1.15; letter-spacing: -.02em; }
h2 { font-size: 1rem; line-height: 1.3; }

.topbar { position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--border); background: rgba(255,255,255,.94); backdrop-filter: blur(10px); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; max-width: 1480px; min-height: 62px; margin: 0 auto; padding: 0 24px; }
.brand { font-weight: 800; letter-spacing: -.02em; }
.brand span { color: var(--muted); font-weight: 500; }
.topbar-actions, .row-inline, .row-between, .button-row, .plan-footer, .panel-heading, .page-heading, .row-meta { display: flex; align-items: center; gap: 10px; }
.topbar-actions { justify-content: flex-end; }
.user-pill, .count-badge { border: 1px solid var(--border); border-radius: 999px; padding: 5px 10px; color: var(--muted); font-size: .78rem; white-space: nowrap; }

.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 24px; max-width: 1480px; margin: 0 auto; padding: 24px; }
.sidebar { align-self: start; position: sticky; top: 86px; display: flex; flex-direction: column; justify-content: space-between; min-height: 260px; }
.nav-list { display: grid; gap: 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; min-height: 42px; border-radius: 8px; padding: 0 12px; color: #52606c; transition: background .18s ease, color .18s ease; }
.nav-link:hover, .nav-link.is-active { background: #e9eef3; color: var(--primary); }
.nav-link.is-active { font-weight: 700; }
.nav-mark { display: grid; place-items: center; width: 20px; color: #778693; font-size: .72rem; }
.sidebar-note { display: flex; align-items: center; gap: 8px; margin: 28px 12px; color: var(--muted); font-size: .75rem; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; }
.status-dot-green { background: #28a968; box-shadow: 0 0 0 3px #d9f1e3; }
.content { min-width: 0; display: grid; gap: 18px; }
.page-heading { justify-content: space-between; align-items: flex-end; gap: 18px; margin-bottom: 4px; }
.page-heading > div { min-width: 0; }
.page-heading p { margin-top: 7px; }
.eyebrow { margin-bottom: 7px; color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .14em; }
.muted { color: var(--muted); font-size: .86rem; line-height: 1.5; }
.text-link { color: #1f5d8a; font-weight: 650; }
.back-link { display: inline-block; margin-bottom: 10px; color: #1f5d8a; font-size: .86rem; }

.metric-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.metric-card { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 16px; }
.metric-card span { display: block; overflow: hidden; color: var(--muted); font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }
.metric-card strong { display: block; margin-top: 8px; font-size: 1.65rem; letter-spacing: -.04em; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.panel { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 18px; box-shadow: 0 1px 1px rgba(20,35,50,.02); }
.panel-heading { justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.panel-heading h2 { min-width: 0; }
.key-values { display: grid; gap: 8px; }
.key-values > div, .list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-radius: 7px; background: #f6f8fa; padding: 10px 12px; font-size: .86rem; }
.key-values span { color: var(--muted); }
.compact-list, .error-list, .stack-list { display: grid; gap: 10px; }
.list-row > * { min-width: 0; }
.list-row p { margin-top: 3px; }
.row-meta { flex-wrap: wrap; justify-content: flex-end; color: var(--muted); font-size: .75rem; }
.error-list { gap: 8px; }
.error-item { border-left: 3px solid #e26b61; border-radius: 6px; background: #fff8f7; padding: 11px 12px; }
.row-between { justify-content: space-between; }
.error-text { color: var(--red); line-height: 1.45; }
.empty { padding: 18px 0; color: var(--muted); font-size: .86rem; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: .7rem; font-weight: 750; line-height: 1; white-space: nowrap; }
.badge-success { color: var(--green); background: var(--green-bg); }
.badge-warning { color: var(--amber); background: var(--amber-bg); }
.badge-danger { color: var(--red); background: var(--red-bg); }
.badge-neutral { color: #52606c; background: #edf1f4; }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; border: 1px solid var(--border); border-radius: 7px; padding: 0 13px; background: white; color: var(--ink); font-size: .83rem; font-weight: 700; transition: background .18s ease, border-color .18s ease, transform .18s ease; }
.button:hover { background: #f1f4f6; border-color: #c7d1d9; }
.button:active { transform: translateY(1px); }
.button-primary { border-color: var(--primary); background: var(--primary); color: white; }
.button-primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.button-secondary { background: #eef2f5; }
.button-success { border-color: var(--green); background: var(--green); color: white; }
.button-success:hover { background: #11633f; }
.button-danger { border-color: var(--red); background: var(--red); color: white; }
.button-danger:hover { background: #941b13; }
.button-ghost { background: transparent; }
.button-small { min-height: 32px; padding: 0 9px; font-size: .72rem; }
.button-block { width: 100%; }

.table-wrap { overflow-x: auto; padding: 0; }
.table-wrap-inner { border: 0; }
table { width: 100%; min-width: 760px; border-collapse: collapse; text-align: left; font-size: .82rem; }
th { border-bottom: 1px solid var(--border); background: #f8fafb; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; white-space: nowrap; }
th, td { padding: 12px 14px; vertical-align: middle; }
tbody tr + tr { border-top: 1px solid #edf0f2; }
tbody tr:hover { background: #fbfcfd; }
.top-align td { vertical-align: top; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.break-text { overflow-wrap: anywhere; }
.url-cell { max-width: 340px; margin: 5px 0 8px; }
.error-url { max-width: 640px; margin-top: 4px; }

.payment-top { display: flex; justify-content: space-between; gap: 20px; }
.payment-top > div { min-width: 0; }
.payment-top p { margin-top: 7px; }
.receipt-thumb { display: block; width: 150px; height: 150px; flex: 0 0 150px; overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: #eef1f3; }
.receipt-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; transition: opacity .18s ease; }
.receipt-thumb:hover img { opacity: .78; }
.quote, .note { margin-top: 14px; border-radius: 7px; background: #f7f9fa; padding: 11px 12px; font-size: .84rem; line-height: 1.55; white-space: pre-wrap; }
.note { color: var(--muted); }
.review-form { display: grid; gap: 10px; margin-top: 16px; border-top: 1px solid var(--border); padding-top: 16px; }

label { display: grid; gap: 6px; color: #34424e; font-size: .78rem; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid #cdd6dd; border-radius: 7px; background: white; color: var(--ink); padding: 10px 11px; }
textarea { resize: vertical; min-height: 76px; }
input:focus, textarea:focus, select:focus { border-color: #5590bd; }
.stack-form { display: grid; gap: 14px; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 12px; margin: 16px 0; }
.form-grid { display: grid; gap: 12px; }
.form-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.check-label, .check-card { display: flex; align-items: center; gap: 8px; }
.check-label input, .check-card input { width: 16px; height: 16px; }
.check-card { align-self: end; min-height: 42px; border: 1px solid var(--border); border-radius: 7px; padding: 0 11px; }
.plan-footer { justify-content: space-between; margin-top: 16px; }
.narrow-panel { max-width: 620px; }
.flash { border: 1px solid #b8e1c8; border-radius: 8px; background: var(--green-bg); color: #14643f; padding: 11px 13px; font-size: .84rem; }
.flash-error { border-color: #f1c2bd; background: var(--red-bg); color: var(--red); }

.login-wrap { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-card { width: min(100%, 420px); border: 1px solid var(--border); border-radius: 14px; background: var(--surface); padding: 32px; box-shadow: 0 16px 50px rgba(25,45,65,.08); }
.login-card h1 { margin-bottom: 8px; }
.login-card .flash { margin: 20px 0 0; }
.login-card .stack-form { margin-top: 22px; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .form-grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; gap: 14px; padding: 16px; }
  .sidebar { position: static; min-height: 0; }
  .nav-list { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .nav-link { flex: 0 0 auto; }
  .sidebar-note { display: none; }
  .two-column { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr 1fr; }
  .inline-form .button { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .topbar-inner { min-height: 56px; padding: 0 16px; }
  .user-pill { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card { padding: 13px; }
  .metric-card strong { font-size: 1.4rem; }
  .panel { padding: 14px; }
  .payment-top { align-items: flex-start; flex-direction: column; }
  .receipt-thumb { width: 100%; height: 220px; flex-basis: 220px; }
  .form-grid-5, .inline-form { grid-template-columns: 1fr; }
  .inline-form .button { grid-column: auto; }
  .plan-footer { align-items: flex-start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
