:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1b1b21;
  --line: #2a2a33;
  --text: #f2efe6;
  --muted: #9a978e;
  --brand: #a51d30;
  --brand-soft: rgba(165, 29, 48, 0.14);
  --brand-strong: #ed9ca8;
  --ok: #3ecf8e;
  --warn: #c9d1d9;
  --bad: #ef5d5d;
  --radius: 12px;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 15px; line-height: 1.5; }
[hidden] { display: none !important; }
a { color: var(--brand-strong); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: "SFMono-Regular", Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }

.brand { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.brand strong { color: var(--brand-strong); }
.brand small { font-size: 10px; letter-spacing: 0.18em; color: var(--muted); border: 1px solid var(--line); padding: 2px 6px; border-radius: 4px; }
.mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; font-weight: 800; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); border-radius: 9px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--brand); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(239, 93, 93, .45); color: var(--bad); background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.icon-btn { display: none; background: transparent; border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 38px; height: 38px; font-size: 18px; cursor: pointer; }

.form { display: grid; gap: 14px; }
.form.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, textarea, select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font: inherit; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 96px; resize: vertical; }
.form-message { min-height: 1.4em; margin: 10px 0 0; color: var(--warn); font-size: 14px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.auth-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0%, rgba(165, 29, 48, .12), transparent 45%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; display: grid; gap: 14px; }

.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; padding: 22px 16px; background: var(--surface); border-right: 1px solid var(--line); }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 550; border: 1px solid transparent; }
.sidebar nav a span { width: 18px; text-align: center; color: var(--brand-strong); opacity: .8; }
.sidebar nav a:hover { color: var(--text); background: var(--surface-2); }
.sidebar nav a.active { color: var(--brand-strong); background: var(--brand-soft); border-color: rgba(165, 29, 48, .35); }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; }
.sidebar-business { margin: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 30; }
.main-wrap { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 18px 28px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(13, 17, 23, .92); backdrop-filter: blur(8px); z-index: 10; }
.topbar h1 { font-size: 20px; flex: 1; }
main { padding: 28px; display: grid; gap: 22px; outline: none; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 650; text-transform: capitalize; border: 1px solid var(--line); color: var(--muted); }
.pill.completed, .pill.active { color: var(--ok); border-color: rgba(62, 207, 142, .4); background: rgba(62, 207, 142, .08); }
.pill.paid, .pill.approved { color: var(--ok); }
.pill.rejected { color: var(--bad); }
.policy-content { white-space: pre-wrap; overflow-wrap: anywhere; margin: 16px 0 28px; }
.pill.pending { color: var(--warn); border-color: rgba(201, 209, 217, .4); background: rgba(201, 209, 217, .08); }
.pill.failed, .pill.suspended, .pill.inactive { color: var(--bad); border-color: rgba(239, 93, 93, .4); background: rgba(239, 93, 93, .08); }

.banner { padding: 12px 28px; font-weight: 550; }
.banner.danger { background: rgba(239, 93, 93, .12); color: #ffb3b3; border-bottom: 1px solid rgba(239, 93, 93, .35); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2 { font-size: 16px; }
.grid { display: grid; gap: 18px; }
.grid.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.metric { position: relative; overflow: hidden; }
.metric .label { color: var(--muted); font-size: 13px; font-weight: 550; }
.metric .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }
.metric .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.metric.highlight { border-color: rgba(165, 29, 48, .45); background: linear-gradient(160deg, rgba(165, 29, 48, .16), var(--surface) 60%); }
.metric.highlight .value { color: var(--brand-strong); }

.chart { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 8px; align-items: end; height: 190px; padding-top: 10px; }
.bar-col { display: grid; grid-template-rows: 1fr auto; gap: 6px; height: 100%; min-width: 0; }
.bar-track { display: flex; align-items: flex-end; height: 100%; }
.bar { width: 100%; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, var(--brand-strong), rgba(165, 29, 48, .35)); min-height: 2px; }
.bar.empty { background: var(--line); }
.bar-label { font-size: 10px; color: var(--muted); text-align: center; white-space: nowrap; }
.bar-h0 { height: 0%; } .bar-h5 { height: 5%; } .bar-h10 { height: 10%; } .bar-h15 { height: 15%; } .bar-h20 { height: 20%; }
.bar-h25 { height: 25%; } .bar-h30 { height: 30%; } .bar-h35 { height: 35%; } .bar-h40 { height: 40%; } .bar-h45 { height: 45%; }
.bar-h50 { height: 50%; } .bar-h55 { height: 55%; } .bar-h60 { height: 60%; } .bar-h65 { height: 65%; } .bar-h70 { height: 70%; }
.bar-h75 { height: 75%; } .bar-h80 { height: 80%; } .bar-h85 { height: 85%; } .bar-h90 { height: 90%; } .bar-h95 { height: 95%; } .bar-h100 { height: 100%; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.amount { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 34px 12px; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.tab.active { color: #fff; background: var(--brand); border-color: var(--brand); }
.tab .count { margin-left: 6px; opacity: .75; }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.toolbar input[type="search"] { max-width: 280px; }

.link-url { display: flex; gap: 8px; align-items: center; min-width: 0; }
.link-url a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.key-box { display: grid; gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.key-box.secret { border-color: rgba(165, 29, 48, .55); background: var(--brand-soft); }
.key-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.key-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.callout { border-left: 3px solid var(--brand); background: var(--surface-2); padding: 12px 14px; border-radius: 6px; font-size: 14px; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; overflow-x: auto; font-size: 12.5px; color: #e9e3cf; margin: 0; }

.toast { position: fixed; bottom: 22px; right: 22px; background: var(--surface-2); border: 1px solid var(--brand); color: var(--text); padding: 12px 16px; border-radius: 10px; opacity: 0; transform: translateY(10px); transition: all .2s; pointer-events: none; z-index: 50; max-width: 360px; }
.toast.show { opacity: 1; transform: translateY(0); }
.loading { color: var(--muted); padding: 30px 0; text-align: center; }

@media (max-width: 1100px) {
  .grid.metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.split { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .icon-btn { display: inline-grid; place-items: center; }
  .topbar { padding: 14px 16px; }
  main { padding: 16px; }
  .banner { padding: 12px 16px; }
  .form.two { grid-template-columns: 1fr; }
  .chart { gap: 4px; }
  .bar-label { font-size: 8px; }
}
@media (max-width: 520px) {
  .grid.metrics { grid-template-columns: 1fr; }
}
