:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e4e7ec;
  --line-soft: #eef1f5;
  --text: #101828;
  --muted: #667085;
  --muted-2: #98a2b3;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --green: #039855;
  --green-soft: #ecfdf3;
  --amber: #b54708;
  --amber-soft: #fffaeb;
  --red: #d92d20;
  --red-soft: #fef3f2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; color: var(--text); }

.boot { padding: 40px; color: var(--muted); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 13px; }

label { display: block; font-size: 12.5px; font-weight: 500; color: #344054; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: 1px solid #d0d5dd;
  background: #fff; color: var(--text); font: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px #2563eb1f; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  padding: 9px 14px; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: #1d4ed8; }
.btn.ghost { background: #fff; border-color: #d0d5dd; color: #344054; font-weight: 500; }
.btn.ghost:hover { background: #f9fafb; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.link { background: none; border: 0; color: var(--accent); padding: 0; font-weight: 500; }

.err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.sidebar {
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 16px; font-weight: 700; font-size: 15px; }
.brand .dot { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.nav-group { padding: 12px 10px 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted-2); font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px;
  color: #344054; cursor: pointer; border: 0; background: transparent; font: inherit;
  text-align: left; width: 100%; font-weight: 500;
}
.nav-item:hover { background: #f4f6f8; text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item .ico { width: 18px; text-align: center; opacity: .85; }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--muted); background: #f2f4f7; border-radius: 999px; padding: 1px 7px; }
.nav-item.disabled { color: var(--muted-2); cursor: default; }
.nav-item.disabled:hover { background: transparent; }
.sidebar .spacer { flex: 1; }
.whoami { border-top: 1px solid var(--line-soft); padding: 12px 10px 6px; font-size: 12.5px; color: var(--muted); }
.whoami b { display: block; color: var(--text); font-size: 13px; font-weight: 600; }
.whoami .mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { padding: 24px 28px 44px; min-width: 0; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; letter-spacing: -.2px; }
.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.page-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.crumbs { color: var(--muted); font-size: 13px; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.pad-0 { padding: 0; overflow: hidden; }
.card h3 { font-size: 14px; }
.card h3.small { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; }
.kpi .k { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 28px; font-weight: 700; letter-spacing: -.5px; margin-top: 4px; }
.kpi .s { font-size: 12px; color: var(--muted-2); margin-top: 2px; }
.kpi.hot .v { color: var(--red); }

.cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cols.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1180px) { .cols, .cols.two { grid-template-columns: 1fr; } .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.card-head h3 { font-size: 14px; }
.card-head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card-body { padding: 14px 16px; }
.card-body.tight { padding: 0; }

.mut { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- tables ---------- */
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; vertical-align: middle; }
table.data th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; background: #fcfcfd; }
table.data tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #fafbfc; }
tr.total td { background: #fcfcfd; font-weight: 600; }
.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13.5px; }

.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: #f2f4f7; color: #475467; text-transform: capitalize; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }

.tabs { display: inline-flex; background: #f2f4f7; border-radius: 8px; padding: 3px; gap: 2px; }
.tab { border: 0; background: transparent; padding: 5px 11px; border-radius: 6px; font: inherit; font-size: 13px;
  color: var(--muted); cursor: pointer; font-weight: 500; }
.tab.active { background: #fff; color: var(--text); box-shadow: var(--shadow); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type="search"] { max-width: 340px; }
.toolbar select { max-width: 200px; }

/* ---------- misc ---------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 7px 14px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack { display: grid; gap: 10px; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 130px; padding: 8px 2px 0; }
.bars .bar { flex: 1; background: linear-gradient(180deg, #93b4fd, #2563eb); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .bar span { position: absolute; top: -16px; left: 50%; transform: translateX(-50%); font-size: 9.5px; color: var(--muted-2); white-space: nowrap; }
.bars-x { display: flex; gap: 6px; margin-top: 6px; }
.bars-x div { flex: 1; text-align: center; font-size: 9.5px; color: var(--muted-2); }

.list { display: grid; }
.list .item { display: flex; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line-soft); }
.list .item:last-child { border-bottom: 0; }
.list .item .main { min-width: 0; flex: 1; }
.list .item .t { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .item .s { font-size: 12.5px; color: var(--muted); }
.list .item .amt { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 420px;
  background: #101828; color: #fff; padding: 12px 14px; border-radius: 10px;
  box-shadow: 0 12px 28px #10182833; font-size: 13.5px;
}
.toast.error { background: var(--red); }
[hidden] { display: none !important; }

@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-group, .whoami .mail, .brand span.name { display: none; }
  .nav-item { width: auto; }
  .main { padding: 16px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  table.data { display: block; overflow-x: auto; white-space: nowrap; }
}
