:root {
  --brand: #04a4bf;
  --brand-dark: #038ba2;
  --side: #13222b;
  --side-hover: #1c313d;
  --side-text: #c9d3da;
  --bg: #f2f3f8;
  --card: #fff;
  --line: #e3e6ee;
  --text: #1f2a33;
  --muted: #6b7781;
  --green: #2e9e5b;
  --red: #d64545;
  --amber: #d88b10;
  --gray: #8a949c;
  --cost: #f08a3c;
  --radius: 4px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: 'Jost', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-dark); }
.num { font-variant-numeric: tabular-nums; }

/* ---------- khung ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: 56px; background: var(--brand); color: #fff; display: flex; align-items: center; z-index: 30; }
.brand { width: 220px; padding: 0 20px; font-size: 20px; letter-spacing: 0.06em; font-weight: 400; flex-shrink: 0; }
.brand b { font-weight: 600; }
.burger { background: none; border: 0; color: #fff; width: 44px; height: 44px; cursor: pointer; font-size: 22px; border-radius: var(--radius); }
.burger:hover { background: rgba(255,255,255,0.12); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; padding-right: 16px; }
.role-chip { background: #fff; color: #c79a00; font-weight: 600; font-size: 13px; padding: 4px 10px; border-radius: 3px; letter-spacing: 0.04em; }
.role-chip.staff { color: #0b7a8c; }
.role-chip.customer { color: #2e7d4f; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,0.25); display: grid; place-items: center; font-weight: 600; }
.me { display: flex; align-items: center; gap: 10px; cursor: pointer; background: none; border: 0; color: #fff; padding: 4px 6px; border-radius: var(--radius); }
.me:hover { background: rgba(255,255,255,0.12); }

.sidebar { position: fixed; top: 56px; bottom: 0; left: 0; width: 220px; background: var(--side); color: var(--side-text); overflow-y: auto; z-index: 20; display: flex; flex-direction: column; transition: transform 0.2s ease; }
.nav { list-style: none; margin: 12px 0; padding: 0; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 20px; color: var(--side-text); text-decoration: none; }
.nav a:hover { background: var(--side-hover); color: #fff; }
.nav a.active { color: var(--brand); font-weight: 500; background: rgba(4,164,191,0.08); box-shadow: inset 3px 0 0 var(--brand); }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav .badge { margin-left: auto; background: var(--brand); color: #fff; font-size: 12px; border-radius: 10px; padding: 0 7px; }
.side-foot { margin-top: auto; border-top: 1px solid #23394a; padding: 14px 20px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }
.side-foot div { display: flex; justify-content: space-between; padding: 4px 0; }
.side-foot span:last-child { color: #fff; text-transform: none; }

main { margin: 56px 0 0 220px; padding: 24px 32px 48px; min-height: calc(100vh - 56px); transition: margin 0.2s ease; }
body.collapsed .sidebar { transform: translateX(-100%); }
body.collapsed main { margin-left: 0; }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 500; margin: 0; text-wrap: balance; }
.page-head .spacer { flex: 1; }
.crumb { color: var(--muted); text-decoration: none; }
.crumb:hover { color: var(--brand-dark); }

/* ---------- thành phần ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 20px 24px; }
.card h2 { font-size: 18px; font-weight: 400; margin: 0 0 16px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; margin-bottom: 24px; }
.stat { text-align: center; padding: 22px 12px; }
.stat .label { text-transform: uppercase; font-size: 14px; letter-spacing: 0.02em; }
.stat .value { font-size: 18px; font-weight: 600; margin-top: 4px; }
.stat .sub { font-size: 14px; color: var(--muted); }
.stat .value.pos { color: var(--green); }
.stat .value.neg { color: var(--red); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: var(--radius); border: 1px solid var(--line); background: #fff; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text); }
.btn:hover { border-color: #c6ccd6; background: #fafbfc; }
.btn.primary { background: #17c1d9; border-color: #12a9bf; color: #fff; box-shadow: inset 0 -2px 0 rgba(0,0,0,0.12); }
.btn.primary:hover { background: #12b3ca; }
.btn.danger { color: var(--red); }
.btn.danger:hover { border-color: var(--red); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible, .seg button:focus-visible, .nav a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .burger:focus-visible, .me:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; flex-wrap: wrap; }
.seg button { border: 0; border-right: 1px solid var(--line); background: #fff; padding: 0 14px; height: 38px; cursor: pointer; font-size: 14px; }
.seg button:last-child { border-right: 0; }
.seg button:hover { background: #f5f6f9; }
.seg button.on { background: #8e9bb3; color: #fff; }
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar .grow { flex: 1; }

input, select, textarea { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; padding: 0 10px; height: 38px; min-width: 0; font-size: 16px; }
textarea { height: auto; padding: 8px 10px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
label.f > input, label.f > select, label.f > textarea { color: var(--text); width: 100%; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid2 .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.check input { height: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 500; font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: 0.03em; background: #fafbfc; white-space: nowrap; }
td.r, th.r { text-align: right; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover { background: #f7fbfc; }
.table-wrap { overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 10px; border-radius: 12px; white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-online { color: var(--green); background: #e6f5ec; }
.st-offline { color: var(--red); background: #fbeaea; }
.st-maintenance { color: var(--amber); background: #fdf3e1; }
.st-stopped { color: var(--gray); background: #eef0f2; }
.rq-pending { color: var(--amber); background: #fdf3e1; }
.rq-approved { color: var(--brand-dark); background: #e1f5f8; }
.rq-done { color: var(--green); background: #e6f5ec; }
.rq-rejected { color: var(--red); background: #fbeaea; }

.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.status-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.status-box .n { font-size: 24px; font-weight: 600; }
.bar { height: 8px; border-radius: 4px; background: #eef0f2; display: flex; overflow: hidden; margin: 14px 0 4px; }
.bar span { display: block; height: 100%; }

.alert { border: 1px solid #f2a65a; background: #fdeee2; color: #c4620a; text-align: center; border-radius: 10px; padding: 10px 16px; margin: 0 auto 20px; max-width: 620px; font-weight: 500; }

.empty { text-align: center; padding: 40px 16px; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; margin-bottom: 24px; }
.kv { display: grid; grid-template-columns: 128px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* chart */
.chart { width: 100%; height: 300px; display: block; }
.chart text { font-family: inherit; font-size: 11px; fill: var(--muted); }
.legend { display: flex; justify-content: center; gap: 18px; font-size: 14px; margin-bottom: 6px; }
.legend i { display: inline-block; width: 28px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.tip { position: fixed; pointer-events: none; background: #1f2a33; color: #fff; font-size: 13px; padding: 6px 10px; border-radius: 4px; z-index: 50; display: none; white-space: nowrap; }

/* modal */
.backdrop { position: fixed; inset: 0; background: rgba(15, 25, 32, 0.45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: #fff; border-radius: 6px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.2); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); font-size: 18px; font-weight: 500; }
.modal .body { padding: 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.err { color: var(--red); font-size: 14px; min-height: 1em; margin-top: 10px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f2a33; color: #fff; padding: 10px 18px; border-radius: 6px; font-size: 14px; opacity: 0; transition: opacity 0.2s; pointer-events: none; z-index: 60; }
#toast.show { opacity: 1; }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(180deg, var(--brand) 0 38%, var(--bg) 38%); }
.auth .card { width: min(400px, 100%); padding: 28px; }
.auth h1 { font-size: 22px; font-weight: 500; margin: 0 0 4px; }
.auth .logo { color: #fff; font-size: 24px; letter-spacing: 0.06em; text-align: center; margin-bottom: 20px; }
.auth form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }

.scrim { display: none; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .brand { width: auto; padding: 0 8px 0 4px; font-size: 17px; }
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 56px 0 0 0; background: rgba(0,0,0,0.35); z-index: 15; }
  main, body.collapsed main { margin-left: 0; padding: 16px 16px 40px; }
  .me .name, .role-chip { display: none; }
  .status-grid { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
  .stats { gap: 12px; }
  .stat { padding: 16px 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* đề xuất: chọn sàn */
fieldset.platforms { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.platforms legend { font-size: 14px; color: var(--muted); padding: 0; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 19px; background: #fff; cursor: pointer; user-select: none; }
.chip:hover { border-color: #c6ccd6; }
.chip input { margin: 0; accent-color: var(--brand); width: 16px; height: 16px; }
.chip:has(input:checked) { border-color: var(--brand); background: #e8f7fa; color: var(--brand-dark); }
.chip.all { font-weight: 500; }
.chip:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: #e8f7fa; color: var(--brand-dark); white-space: nowrap; margin: 1px 0; }
