/* Inter, self-hosted: no request to a third-party font server. */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap; src: url("../fonts/inter-latin-var.woff2") format("woff2"); }

:root {
  --primary: #007bbb;
  --primary-press: #00679d;
  --primary-soft: #e6f2f8;
  --bg: #f4f7f9;
  --surface: #ffffff;
  --border: #e3e8ec;
  --text: #0e1a23;
  --muted: #5e6b75;
  --ok: #1a9e5c;
  --ok-soft: #e4f5ec;
  --warn: #b07800;
  --warn-soft: #fdf3dc;
  --bad: #d93f3f;
  --bad-soft: #fde8e8;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* Shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 800; font-size: 19px; letter-spacing: -0.4px; color: var(--primary); }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; display: block; flex: none; }
.brand-lg { font-size: 22px; gap: 12px; }
.brand-lg .brand-logo { width: 44px; height: 44px; border-radius: 12px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border-radius: 12px; color: var(--muted); font-weight: 600; text-decoration: none;
}
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.badge { background: var(--bad); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--border); font-size: 13px; }
.sidebar-foot strong { display: block; }
.main { padding: 28px 32px 56px; max-width: 1240px; width: 100%; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 0 8px 0 4px; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1 1 100%; order: 3; padding-bottom: 4px; }
  .nav a { white-space: nowrap; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; text-align: right; }
  .main { padding: 20px 16px 48px; }
}

/* Page */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.6px; }
.page-head p { color: var(--muted); margin-top: 4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px 0; gap: 12px; }
.card-head h2 { font-size: 16px; font-weight: 700; }
.card-body { padding: 16px 20px 20px; }
.card-body.flush { padding: 8px 0 0; }

.grid { display: grid; gap: 16px; }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c2 { grid-template-columns: 1.4fr 1fr; }
.grid.even { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .grid.c4 { grid-template-columns: repeat(2, 1fr); } .grid.c2, .grid.even, .grid.c3 { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .grid.c4 { grid-template-columns: 1fr; } }

.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-value { font-size: 26px; font-weight: 800; letter-spacing: -0.6px; font-variant-numeric: tabular-nums; }
.stat-hint { color: var(--muted); font-size: 12.5px; }
.stat.warn { border-color: #f0d9a0; background: var(--warn-soft); }
.stat.bad { border-color: #f3bcbc; background: var(--bad-soft); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 700; padding: 10px 20px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 13px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: #fafcfd; }
td.r, th.r { text-align: right; }

.pill { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.muted { background: var(--bg); color: var(--muted); }
.pill.blue { background: var(--primary-soft); color: var(--primary); }

/* Forms */
.btn { border: 1px solid transparent; border-radius: 99px; padding: 10px 18px; font-weight: 700; cursor: pointer; background: var(--bg); transition: background .15s; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--primary-press); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover:not(:disabled) { background: var(--bg); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { padding: 6px 14px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; background: var(--bg);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; background: #fff; }
.form-error { color: var(--bad); font-size: 13.5px; margin-top: 10px; font-weight: 600; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; padding: 0 20px 14px; align-items: center; }
.toolbar input[type="text"] { max-width: 280px; }
.toolbar select { width: auto; }

.empty { color: var(--muted); text-align: center; padding: 36px 16px; }

.switch { width: 44px; height: 26px; border-radius: 99px; border: 0; background: #cfd7dd; padding: 3px; cursor: pointer; transition: background .15s; }
.switch span { display: block; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--primary); }
.switch.on span { transform: translateX(18px); }
.switch:disabled { opacity: .45; cursor: not-allowed; }

/* Modal + toasts */
.overlay { position: fixed; inset: 0; background: rgba(14, 26, 35, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 20px; padding: 24px; width: min(480px, 100%); box-shadow: 0 24px 60px rgba(0,0,0,.25); }
.modal h3 { font-size: 20px; font-weight: 800; letter-spacing: -.3px; }
.modal-desc { color: var(--muted); margin-top: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.error { background: var(--bad); }

/* Bits */
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; }
.kv dt { color: var(--muted); font-weight: 600; font-size: 13.5px; }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 10px; } }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; font-weight: 600; font-size: 14px; }
.alert + .alert { margin-top: 8px; }
.alert.critical { background: var(--bad-soft); color: #a02a2a; }
.alert.warning { background: var(--warn-soft); color: #7a5600; }
.alert-ok { color: var(--ok); font-weight: 600; }

.meter { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; border-radius: 99px; background: var(--primary); }
.meter.low > i { background: var(--bad); }
.rate-row { display: grid; grid-template-columns: 150px 1fr 56px; gap: 12px; align-items: center; padding: 6px 0; font-size: 14px; }
.rate-row .meter { margin: 0; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 120px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; justify-content: flex-end; height: 100%; font-size: 11.5px; color: var(--muted); }
.bars i { display: block; width: 100%; border-radius: 8px 8px 4px 4px; background: var(--primary); min-height: 3px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.tab { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 7px 16px; font-weight: 700; font-size: 13.5px; cursor: pointer; color: var(--muted); }
.tab.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.back { display: inline-block; margin-bottom: 14px; font-weight: 600; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--primary-soft), #fff 60%); }
.login-card { background: #fff; border: 1px solid var(--border); border-radius: 24px; padding: 32px; width: min(420px, 100%); box-shadow: 0 20px 50px rgba(0,123,187,.12); }
.login-card h1 { font-size: 24px; font-weight: 800; letter-spacing: -.5px; margin: 18px 0 6px; }
.demo { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border); font-size: 13px; color: var(--muted); }
.demo button { display: block; width: 100%; text-align: left; background: var(--bg); border: 0; border-radius: 10px; padding: 8px 12px; margin-top: 6px; cursor: pointer; }
.demo button:hover { background: var(--primary-soft); }

/* Laravel specifics */
dialog.modal-dialog { border: 0; padding: 0; background: transparent; max-width: calc(100vw - 32px); }
dialog.modal-dialog::backdrop { background: rgba(14, 26, 35, .45); }
dialog.modal-dialog .modal { margin: 0; }
.flash { position: fixed; right: 20px; bottom: 20px; z-index: 70; background: var(--text); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.banner-error { background: var(--bad-soft); color: #a02a2a; border: 1px solid #f3bcbc; padding: 12px 16px; border-radius: 12px; font-weight: 600; margin-bottom: 16px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px; color: var(--muted); }
.pager a, .pager span.btn { text-decoration: none; }
form.inline { display: inline; }
.sidebar-foot form { margin: 0; }
.rate-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Team and roles */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--primary-soft, #e6f2f8); color: var(--primary); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip.none { background: #eef1f4; color: #67727e; font-weight: 500; }
.perm-group { margin: 12px 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #67727e; }
.perm-row { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; font-size: 14px; }
.perm-row input { margin-top: 3px; }
.qr { display: grid; place-items: center; margin: 14px 0 6px; }
.qr svg { width: 200px; height: 200px; border: 1px solid #e3e8ee; border-radius: 12px; padding: 8px; background: #fff; }
.setup-key { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; background: #f3f6f9; border-radius: 10px; padding: 10px 12px; word-break: break-all; text-align: center; font-size: 14px; }
.cred { background: #f3f6f9; border-radius: 12px; padding: 14px; margin: 12px 0; }
.cred div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }
.cred code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 15px; font-weight: 700; word-break: break-all; }
.stack { display: grid; gap: 10px; }
