:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1d2330;
  --muted: #64748b;
  --line: #e2e6ec;
  --brand: #2f5bea;
  --brand-ink: #ffffff;
  --good: #1a7f4b;
  --warn: #b4531a;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 980px; margin: 0 auto; padding: 0 20px; }
.page { padding: 28px 0 64px; }

/* Header */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar__inner { display: flex; align-items: center; gap: 24px; padding: 14px 20px; max-width: 980px; margin: 0 auto; }
.topbar__brand { font-weight: 700; font-size: 17px; letter-spacing: -.01em; color: var(--ink); }
.topbar__brand:hover { text-decoration: none; }
.nav { display: flex; gap: 18px; list-style: none; margin: 0; padding: 0; flex: 1; }
.nav-link { color: var(--muted); font-weight: 500; font-size: 14px; }
.nav-link:hover { color: var(--ink); text-decoration: none; }
.nav-link--active { color: var(--brand); }
.topbar__right { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }

/* Impersonation banner */
.impersonation-banner { background: var(--warn); color: #fff; }
.impersonation-banner__inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 20px; max-width: 980px; margin: 0 auto; font-size: 14px; }
.impersonation-banner form { margin: 0; }
.impersonation-banner a, .impersonation-banner button { color: #fff; font-weight: 600; font-size: 14px; }
.impersonation-banner button { background: rgba(255,255,255,.2); border: 1px solid rgba(255,255,255,.4); color: #fff; padding: 4px 12px; border-radius: 6px; cursor: pointer; }
.impersonation-banner button:hover { background: rgba(255,255,255,.3); }

/* Flash */
.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; }
.flash--alert { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c0; }
.flash--notice { background: #e9f6ef; color: var(--good); border: 1px solid #c4e6d2; }

/* Cards & layout */
.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.card__title { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.card__sub { color: var(--muted); font-size: 13px; margin: 0; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 6px; }

/* Typography */
h1, h2, h3 { letter-spacing: -.01em; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 32px 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 24px; font-size: 14px; }
.muted { color: var(--muted); }
.price { font-weight: 700; }
.price--large { font-size: 20px; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat__value { font-size: 24px; font-weight: 700; }
.stat__label { color: var(--muted); font-size: 13px; }

/* Buttons */
.btn { display: inline-block; background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand); border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; line-height: 1.2; }
.btn:hover { background: #244ac0; text-decoration: none; }
.btn--sm { padding: 5px 11px; font-size: 13px; }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { background: #f1f3f7; }
.btn--danger { background: var(--surface); color: var(--danger); border-color: #e9c3bf; }
.btn--danger:hover { background: #fdecea; }
.btn--success { background: var(--good); border-color: var(--good); }
.btn--success:hover { background: #156a3d; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

/* Forms */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  font-size: 14px; color: var(--ink); font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.field { margin-bottom: 16px; }
.field--inline { display: grid; grid-template-columns: 1fr 120px; gap: 12px; align-items: end; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }

.errors { background: #fdecea; border: 1px solid #f5c6c0; color: var(--danger); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.errors ul { margin: 6px 0 0; padding-left: 18px; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fafbfc; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .row-actions { text-align: right; white-space: nowrap; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge--open { background: #fff4e5; color: var(--warn); }
.badge--invoiced { background: #e9f6ef; color: var(--good); }
.badge--customer { background: #eef2ff; color: var(--brand); }
.badge--superadmin { background: #ece9ff; color: #6b46c1; }
.badge--inactive { background: #f1f3f7; color: var(--muted); }

/* Line items (basket) */
.line-item { display: grid; grid-template-columns: 1fr 110px 130px 90px; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line-item--head { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.line-item--head span { padding-top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.line-item__remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 13px; font-weight: 600; padding: 0; }
.line-total { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.order-total { display: flex; justify-content: space-between; align-items: baseline; padding: 16px 0 4px; }
.order-total__label { font-weight: 600; }
.order-total__value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }

.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.divider { height: 1px; background: var(--line); margin: 24px 0; }
.login { max-width: 360px; margin: 8vh auto; }
