:root {
  --nav-bg: #1f3b57;
  --nav-bg-2: #16293d;
  --nav-fg: #c8d8e8;
  --nav-active: #2f6fb0;
  --head-bg: #23425f;
  --head-fg: #eaf2fa;
  --bg: #eef2f6;
  --panel: #ffffff;
  --border: #cfdae6;
  --text: #22303d;
  --muted: #6b7c8d;
  --accent: #2f6fb0;
  --accent-2: #4a90d9;
  --ok: #2e8b57;
  --warn: #d98324;
  --err: #c0392b;
  --radius: 4px;
  --shadow: 0 1px 3px rgba(20, 40, 60, .16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 "Segoe UI", "Helvetica Neue", Arial, "Liberation Sans", sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.boot {
  height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--muted);
}
.boot-spinner {
  width: 28px; height: 28px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------- login ------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #1f3b57 0%, #2f6fb0 100%);
  padding: 20px;
}
.login-card {
  width: 380px; background: var(--panel); border-radius: 6px;
  box-shadow: 0 12px 40px rgba(10, 25, 40, .35); overflow: hidden;
}
.login-head { background: var(--head-bg); color: var(--head-fg); padding: 22px 24px; }
.login-head h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: .5px; }
.login-head p { margin: 0; font-size: 12px; opacity: .8; }
.login-body { padding: 22px 24px 26px; }
.login-body label { display: block; font-size: 12px; font-weight: 600; margin: 14px 0 5px; }
.login-body input {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 13px; background: #fbfcfe;
}
.login-body input:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
.btn {
  display: inline-block; border: 1px solid var(--accent); background: var(--accent);
  color: #fff; padding: 8px 14px; border-radius: var(--radius); cursor: pointer;
  font-size: 13px; font-weight: 600;
}
.btn:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-block { width: 100%; margin-top: 20px; padding: 10px; }
.btn-ghost { background: #fff; color: var(--accent); }
.btn-ghost:hover { background: #eef5fc; }
.btn-danger { background: var(--err); border-color: var(--err); }
.btn-danger:hover { background: #a5301f; border-color: #a5301f; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.login-hint {
  margin-top: 16px; font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--border); padding-top: 12px; line-height: 1.6;
}
.err-box {
  background: #fdecea; border: 1px solid #f5c6c0; color: #8a2a1c;
  padding: 9px 11px; border-radius: var(--radius); font-size: 12px; margin-bottom: 6px;
}

/* ---------------------------------------------------------- shell ------- */
.shell { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  background: var(--head-bg); color: var(--head-fg); display: flex;
  align-items: center; gap: 16px; padding: 0 16px; height: 46px; flex: 0 0 46px;
  box-shadow: 0 1px 4px rgba(0,0,0,.25); z-index: 5;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .5px; color: #fff; }
.brand span { color: #7fc4ff; }
.topbar .spacer { flex: 1; }
.level-switch {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  color: #fff; border-radius: var(--radius); padding: 4px 8px; font-size: 12px;
  /* The global rule makes every select full width; this one is in the bar. */
  width: auto; flex: 0 0 auto;
}
.badge {
  display: inline-block; min-width: 17px; text-align: center;
  background: var(--err); color: #fff; border-radius: 9px;
  font-size: 11px; padding: 1px 6px; font-weight: 700;
}
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; }

/* The page body is the only flex row: the panel bodies are blocks, so a
   chart inside one fills the panel instead of collapsing to nothing. */
.shell > .body { display: flex; flex: 1; min-height: 0; }
.sidenav {
  width: 232px; flex: 0 0 232px; background: var(--nav-bg-2); color: var(--nav-fg);
  overflow-y: auto; padding: 8px 0 24px;
}
.sidenav h4 {
  margin: 0; padding: 11px 14px 6px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .9px; color: #7f9cb8; font-weight: 700;
}
.sidenav a {
  display: flex; align-items: center; gap: 9px; padding: 7px 14px;
  color: var(--nav-fg); font-size: 12.5px; border-left: 3px solid transparent;
}
.sidenav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidenav a.active {
  background: var(--nav-active); color: #fff; border-left-color: #9ed0ff; font-weight: 600;
}
.sidenav .ico { width: 15px; text-align: center; opacity: .9; }

.content { flex: 1; overflow: auto; padding: 16px 20px 40px; min-width: 0; }
.page-head { margin-bottom: 14px; }
.crumbs { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.page-head h2 { margin: 0 0 3px; font-size: 19px; font-weight: 600; }
.page-head .desc { color: var(--muted); font-size: 12.5px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

/* --------------------------------------------------------- widgets ------ */
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.panel > header {
  padding: 9px 13px; border-bottom: 1px solid var(--border); font-weight: 600;
  font-size: 12.5px; background: #f4f8fc; border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center; gap: 10px;
}
.panel > header .spacer { flex: 1; }
.panel .body { display: block; padding: 13px; }

table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  text-align: left; padding: 8px 10px; background: #eef3f8; border-bottom: 1px solid var(--border);
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: #4a5a6a; cursor: pointer;
  white-space: nowrap;
}
table.data th.no-sort { cursor: default; }
table.data td { padding: 7px 10px; border-bottom: 1px solid #e6ecf2; vertical-align: top; }
table.data tr:hover td { background: #f6fafe; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 5px; justify-content: flex-end; }
.pill {
  display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px;
  font-weight: 600; background: #e6ecf2; color: #45566a;
}
.pill.ok { background: #dcf1e4; color: #1f6b40; }
.pill.warn { background: #fdf0dc; color: #9a5b12; }
.pill.err { background: #fbe1de; color: #9c2d1c; }
.pill.info { background: #dceafb; color: #1d4f88; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 15px; box-shadow: var(--shadow);
}
.card .label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.card .value { font-size: 22px; font-weight: 700; margin-top: 5px; }
.card .sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

.meter { height: 7px; background: #e4eaf1; border-radius: 4px; overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%; background: var(--accent-2); }
.meter > i.high { background: var(--warn); }
.meter > i.over { background: var(--err); }

form.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
form.grid .full { grid-column: 1 / -1; }
label.fld { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; }
label.fld .req { color: var(--err); }
input[type=text], input[type=password], input[type=number], input[type=email],
select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius);
  font: inherit; background: #fbfcfe; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: var(--accent); }
textarea { min-height: 90px; font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.checkline { display: flex; align-items: center; gap: 7px; font-size: 12.5px; }
.checkline input { width: auto; }

.empty { padding: 34px; text-align: center; color: var(--muted); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 7px 14px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

pre.code {
  background: #1d2b38; color: #d6e6f5; padding: 12px; border-radius: var(--radius);
  overflow: auto; font-size: 12px; max-height: 420px;
}

.chart { display: flex; align-items: flex-end; gap: 3px; width: 100%; height: 150px; padding-top: 10px; }
.chart .bar { flex: 1; max-width: 64px; background: var(--accent-2); border-radius: 2px 2px 0 0; min-height: 2px; position: relative; }
.chart .bar:hover { background: var(--accent); }
.chart-labels { display: flex; gap: 3px; margin-top: 5px; }
.chart-labels span { flex: 1; text-align: center; font-size: 9.5px; color: var(--muted); }

.filebar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filebar code { background: #eef3f8; padding: 3px 7px; border-radius: 3px; font-size: 12px; }

/* --------------------------------------------------------- toasts ------- */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #22333f; color: #fff; padding: 10px 14px; border-radius: var(--radius);
  font-size: 12.5px; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 380px;
  animation: slidein .18s ease-out;
}
.toast.ok { background: #1f6b40; }
.toast.err { background: #9c2d1c; }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

/* --------------------------------------------------------- modal -------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(16, 30, 44, .55);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  z-index: 90; overflow: auto;
}
.modal {
  background: var(--panel); border-radius: 5px; width: 100%; max-width: 620px;
  box-shadow: 0 16px 50px rgba(10, 20, 30, .35);
}
.modal > header {
  padding: 11px 15px; border-bottom: 1px solid var(--border); font-weight: 600;
  display: flex; align-items: center; background: #f4f8fc;
}
.modal > header .spacer { flex: 1; }
.modal .body { padding: 16px; max-height: 65vh; overflow: auto; }
.modal > footer { padding: 11px 15px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.x-btn { cursor: pointer; color: var(--muted); font-size: 17px; line-height: 1; background: none; border: 0; }

.login-twofa { margin-top: 12px; }
.ticket-msg { border-left: 3px solid var(--border); padding: 8px 12px; margin-bottom: 9px; background: #f8fafc; }
.ticket-msg.staff { border-left-color: var(--accent); background: #eef5fc; }
.ticket-msg .meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .sidenav { width: 180px; flex-basis: 180px; }
}


/* ------------------------------------------------- pricing plan locks --- */
.sidenav a.locked { opacity: .45; }
.sidenav a.locked:hover { opacity: .8; }
.sidenav a.locked .lock { margin-left: auto; display: inline-flex; }
.sidenav a.locked .lock svg { width: 13px; height: 13px; }
.sidenav a.locked::after { content: ''; }
.plan-feature { display: flex; align-items: center; gap: 8px; }
.checkline { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.checkline input { width: 16px; height: 16px; cursor: pointer; }
.pill.ok { background: #dcfce7; color: #166534; }
.pill.warn { background: #fef3c7; color: #92400e; }
@media (prefers-color-scheme: dark) {
  .pill.ok { background: rgba(34, 197, 94, .18); color: #86efac; }
  .pill.warn { background: rgba(245, 158, 11, .18); color: #fcd34d; }
}
