:root {
  --bg: #faf7f2;
  --panel: #ffffff;
  --ink: #1d1b18;
  --muted: #6f6a62;
  --line: #ebe5da;
  --line-2: #f3eee6;
  --red: #ee4d2d;
  --red-ink: #c63a1d;
  --red-soft: #fdeee9;
  --green: #1f8a4c;
  --green-soft: #e7f5ec;
  --amber: #a86400;
  --amber-soft: #fff4dd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(40, 30, 10, .04), 0 4px 16px rgba(40, 30, 10, .05);
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 'Plus Jakarta Sans', system-ui, sans-serif; }
a { color: var(--red-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- shell ---------- */
.top { position: sticky; top: 0; z-index: 10; background: rgba(250, 247, 242, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1180px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--red); display: grid; place-items: center; color: #fff; font-weight: 800; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav button { border: 0; background: none; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; cursor: pointer; }
.nav button:hover { background: var(--line-2); color: var(--ink); }
.nav button.on { background: var(--ink); color: #fff; }
.who { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 80px; }
h1 { font-size: 22px; letter-spacing: -.02em; margin: 0; }
h2 { font-size: 15px; margin: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 13px; }

/* ---------- elements ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); padding: 8px 14px; border-radius: 10px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #d9d1c3; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-ink); }
.btn.ghost { border-color: transparent; background: none; }
.btn.danger { color: var(--red-ink); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line-2); gap: 10px; }
.card-b { padding: 16px 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.two { grid-template-columns: 1.3fr 1fr; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, 1fr); } .two { grid-template-columns: 1fr; } .nav button { padding: 8px 8px; } }
.kpi { padding: 16px 18px; }
.kpi .l { color: var(--muted); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(31, 138, 76, .5); animation: pulse 2s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(31, 138, 76, 0); } 100% { box-shadow: 0 0 0 0 rgba(31, 138, 76, 0); } }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 18px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.chain { display: flex; flex-direction: column; gap: 2px; }
.chain .arrow { color: var(--muted); font-size: 12px; }
.trunc { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 36px 18px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.table-wrap { overflow-x: auto; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.red { background: var(--red-soft); color: var(--red-ink); }
.pill.dark { background: var(--ink); color: #fff; }

.seg { display: inline-flex; background: var(--line-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 10px; border-radius: 8px; font-weight: 600; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }

.banner { border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; font-weight: 600; display: flex; gap: 10px; align-items: center; }
.banner.warn { background: var(--amber-soft); color: var(--amber); border: 1px solid #f3dca8; }
.banner.critical { background: var(--red-soft); color: var(--red-ink); border: 1px solid #f6c6b8; }
.meter { height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.meter.warn > i { background: #e0a020; }
.meter.critical > i { background: var(--red); }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 8px; }
.bars .b { flex: 1; background: var(--red); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; position: relative; }
.bars .b.zero { background: var(--line); }
.bars .b:hover { opacity: 1; }
.bars .b:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; font-size: 11px; padding: 3px 7px; border-radius: 6px; white-space: nowrap; z-index: 2; }
.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 6px; }

.bd { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.bd-item h3 { font-size: 12px; color: var(--muted); margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.bd-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; font-size: 13px; padding: 4px 0; position: relative; }
.bd-row .bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--red); opacity: .5; border-radius: 2px; }

/* forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: 13px; }
.field .hint { color: var(--muted); font-size: 12px; }
input[type=text], input[type=email], input[type=password], input[type=url], select, textarea {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 12px; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
textarea { min-height: 70px; resize: vertical; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > * { min-width: 0; }
.host-input { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.host-input input, .host-input select { border: 0; border-radius: 0; box-shadow: none !important; }
.host-input span { background: var(--line-2); color: var(--muted); padding: 9px 8px; display: flex; align-items: center; font-family: var(--mono); font-size: 12.5px; }
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.radio-cards label { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; cursor: pointer; font-weight: 500; display: flex; gap: 8px; align-items: flex-start; }
.radio-cards label:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.radio-cards b { display: block; font-size: 13px; }
.radio-cards small { color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; }
details.more { border-top: 1px solid var(--line-2); padding-top: 12px; margin-top: 4px; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.sub-box { background: var(--line-2); border-radius: 12px; padding: 12px 14px 2px; margin-bottom: 14px; }
.error { color: var(--red-ink); font-weight: 600; font-size: 13px; min-height: 18px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(29, 27, 24, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--panel); border-radius: 18px; width: min(620px, 100%); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal.wide { width: min(920px, 100%); }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line-2); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.modal-b { padding: 18px 22px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line-2); position: sticky; bottom: 0; background: var(--panel); }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth h1 { margin: 16px 0 4px; }

.ns { font-family: var(--mono); background: var(--line-2); padding: 8px 10px; border-radius: 8px; margin: 4px 0; display: flex; justify-content: space-between; align-items: center; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; font-weight: 600; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
