/* Metin2 hosting panel - dark/light, no external assets. */
:root {
  color-scheme: dark;
  --bg: #0d1014;
  --bg-2: #12161c;
  --panel: #161b22;
  --panel-2: #1c222b;
  --line: #29313c;
  --ink: #e7ecf2;
  --muted: #98a3b1;
  --faint: #6b7684;
  --accent: #e0a43a;
  --accent-ink: #1b1306;
  --accent-soft: rgba(224, 164, 58, 0.14);
  --ok: #38b27a;
  --ok-soft: rgba(56, 178, 122, 0.14);
  --warn: #e6b23c;
  --warn-soft: rgba(230, 178, 60, 0.14);
  --bad: #ec5f55;
  --bad-soft: rgba(236, 95, 85, 0.14);
  --info: #5aa2f0;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Mono", "DejaVu Sans Mono", monospace;
  --sans: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --bg-2: #eceef2;
  --panel: #ffffff;
  --panel-2: #f7f8fa;
  --line: #dfe3e8;
  --ink: #1b2129;
  --muted: #5d6875;
  --faint: #8a94a1;
  --accent: #b97813;
  --accent-ink: #ffffff;
  --accent-soft: rgba(185, 120, 19, 0.1);
  --ok: #1f8a59;
  --ok-soft: rgba(31, 138, 89, 0.1);
  --warn: #9a6b00;
  --warn-soft: rgba(154, 107, 0, 0.1);
  --bad: #c6372d;
  --bad-soft: rgba(198, 55, 45, 0.1);
  --info: #2468b8;
  --shadow: 0 6px 20px rgba(20, 30, 40, 0.08);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f5f7; --bg-2: #eceef2; --panel: #ffffff; --panel-2: #f7f8fa; --line: #dfe3e8;
    --ink: #1b2129; --muted: #5d6875; --faint: #8a94a1; --accent: #b97813; --accent-ink: #ffffff;
    --accent-soft: rgba(185, 120, 19, 0.1); --ok: #1f8a59; --ok-soft: rgba(31, 138, 89, 0.1);
    --warn: #9a6b00; --warn-soft: rgba(154, 107, 0, 0.1); --bad: #c6372d; --bad-soft: rgba(198, 55, 45, 0.1);
    --info: #2468b8; --shadow: 0 6px 20px rgba(20, 30, 40, 0.08);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 0.6em; }
h1 { font-size: 1.55rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
code, pre, .mono { font-family: var(--mono); font-size: 0.86em; }
p { margin: 0 0 0.8em; }

/* ---------------------------------------------------------- sidebar */
.side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; margin: 0 6px 14px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #c0501f); color: #fff; font-size: 15px;
}
.brand small { display: block; color: var(--muted); font-weight: 500; font-size: 0.75rem; }
.nav-group { margin: 10px 6px 4px; color: var(--faint); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px;
  color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--panel); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav .ico { width: 18px; text-align: center; opacity: 0.9; }
.side .grow { flex: 1; }
.side .me { border-top: 1px solid var(--line); padding: 12px 6px 0; font-size: 0.85rem; color: var(--muted); }
.side .me b { color: var(--ink); display: block; }
.side .me form { display: inline; }

/* ---------------------------------------------------------- main */
main { padding: 26px 32px 60px; max-width: 1280px; width: 100%; min-width: 0; }
input, select, textarea { max-width: 100%; }
.top { display: flex; align-items: center; gap: 12px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 18px; }
.top h1 { margin: 0; }
.crumbs { color: var(--muted); font-size: 0.85rem; margin-bottom: 4px; }
.crumbs a { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card.danger { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.card.danger h2 { color: var(--bad); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
.stat .k { color: var(--muted); font-size: 0.82rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
.spacer { flex: 1; }

/* ---------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 600; background: var(--panel-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
  white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.badge.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.badge.bad { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.badge.accent { color: var(--accent); background: var(--accent-soft); border-color: transparent; }

/* ---------------------------------------------------------- forms */
form.stack { display: grid; gap: 12px; max-width: 560px; }
form.inline { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
label { display: grid; gap: 5px; font-weight: 500; font-size: 0.9rem; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.hint { color: var(--muted); font-size: 0.82rem; font-weight: 400; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 11px; min-width: 0;
}
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 1px;
}
textarea { min-height: 90px; }
.btn, button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
}
.btn:hover, button:hover { border-color: var(--faint); text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger, button.danger { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: var(--bad); }
.btn.ok, button.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.btn.small, button.small { padding: 4px 10px; font-size: 0.82rem; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; }
button[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------------------------------------------------------- alerts */
.alert { border-radius: var(--radius); padding: 11px 14px; margin-bottom: 16px; border: 1px solid transparent; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: color-mix(in srgb, var(--info) 12%, transparent); color: var(--info); }
.alert b { color: inherit; }
.secret-once {
  font-family: var(--mono); font-size: 1.15rem; padding: 12px 14px; background: var(--bg);
  border: 1px dashed var(--accent); border-radius: 8px; user-select: all; word-break: break-all;
}

/* ---------------------------------------------------------- logs / jobs */
pre.log {
  background: #090b0e; color: #cdd6df; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; max-height: 70vh; overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0;
  font-size: 0.8rem; line-height: 1.45;
}
:root[data-theme="light"] pre.log { background: #1d232b; }
pre.log .err { color: #ff8a80; }
.meter { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.meter > span { display: block; height: 100%; background: var(--accent); }

/* ---------------------------------------------------------- login */
body.bare { display: grid; grid-template-columns: 1fr; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 70% -10%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: min(400px, 100%); }
.login-card .brand { justify-content: center; margin-bottom: 18px; }

.theme-toggle { margin-top: 8px; width: 100%; justify-content: center; font-weight: 500; font-size: 0.85rem; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
details summary { cursor: pointer; color: var(--muted); }
.slot { font-family: var(--mono); color: var(--faint); }

@media (max-width: 860px) {
  body { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 10px 12px; gap: 8px; }
  .side .nav-group, .side .grow { display: none; }
  .nav { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 2px; padding-bottom: 4px; }
  .nav a { white-space: nowrap; }
  .brand { margin: 0; }
  .side .me { border-top: 1px solid var(--line); padding: 8px 0 0; }
  .theme-toggle { width: auto; margin: 0 0 0 8px; }
  .top form.inline, .top form.inline input { width: 100%; }
  main { padding: 18px 14px 50px; }
  .grid.two { grid-template-columns: 1fr; }
}
.mt { margin-top: 14px; }

/* widths (no inline styles: CSP) */
.w-xs { width: 80px; } .w-s { width: 130px; } .w-m { width: 180px; }
.bar-col { width: 40%; }
.num.neg { color: var(--bad); } .num.pos { color: var(--ok); }
form.stack.wide { max-width: none; }
.meter > span.w-0 { width: 0%; }
.meter > span.w-5 { width: 5%; }
.meter > span.w-10 { width: 10%; }
.meter > span.w-15 { width: 15%; }
.meter > span.w-20 { width: 20%; }
.meter > span.w-25 { width: 25%; }
.meter > span.w-30 { width: 30%; }
.meter > span.w-35 { width: 35%; }
.meter > span.w-40 { width: 40%; }
.meter > span.w-45 { width: 45%; }
.meter > span.w-50 { width: 50%; }
.meter > span.w-55 { width: 55%; }
.meter > span.w-60 { width: 60%; }
.meter > span.w-65 { width: 65%; }
.meter > span.w-70 { width: 70%; }
.meter > span.w-75 { width: 75%; }
.meter > span.w-80 { width: 80%; }
.meter > span.w-85 { width: 85%; }
.meter > span.w-90 { width: 90%; }
.meter > span.w-95 { width: 95%; }
.meter > span.w-100 { width: 100%; }

/* ---------------------------------------------------------- GM command reference */
[hidden] { display: none !important; }
.offscreen { position: fixed; left: -9999px; top: 0; }
ul.tight { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.filters { position: sticky; top: 0; z-index: 2; padding: 12px 16px; }
.filters .row { align-items: end; }
.filters .grow-1 { flex: 1; min-width: 220px; }
.filters .hint { margin: 6px 0 0; }
.cmd-group { margin-top: 22px; }
.cmd-group > h2 .hint, .cmd-internal summary .hint { font-weight: 400; }
.cmd-internal summary { list-style-position: outside; }
.cmd-internal summary .inline-h { display: inline; margin: 0 6px 0 0; color: var(--ink); }
.cmd-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); margin-top: 10px; }
.cmd {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; min-width: 0;
}
.cmd.danger { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.cmd header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.cmd .cmd-name { font-size: 1rem; font-weight: 700; color: var(--accent); }
.cmd p { margin: 0 0 6px; overflow-wrap: anywhere; }
.cmd .syntax code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; display: inline-block; }
.cmd code.example { user-select: all; }
.cmd ul.notes { margin: 4px 0 6px; padding-left: 1.2em; color: var(--muted); }
.cmd ul.notes li { margin: 2px 0; }
.cmd .meta { margin: 0; color: var(--faint); }
@media (max-width: 860px) {
  .cmd-list { grid-template-columns: 1fr; }
  .filters { position: static; }
}

/* ---------------------------------------------------------- billing */
.billing-banner a { margin-left: 6px; font-weight: 600; }
.plan-name { font-size: 1.1rem; font-weight: 600; margin: 4px 0 2px; }
.lang-switch button { min-width: 40px; justify-content: center; }
.invoice { max-width: 860px; width: 100%; margin: 0 auto; padding: 32px 36px; }
.invoice .invoice-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 20px; }
.invoice .invoice-head h1 { font-size: 1.3rem; margin-bottom: 4px; }
.invoice .invoice-head .brand { margin: 0; }
.invoice-parties { margin-bottom: 18px; }
.invoice-parties p { margin: 0; line-height: 1.6; }
.invoice-lines tfoot td { border-top: 1px solid var(--line); background: var(--panel-2); }
.invoice-lines tr.total td { font-size: 1.05rem; }
body.bare .invoice { place-self: start center; margin-top: 20px; }
@media print {
  body, body.bare { display: block; background: #fff; color: #000; padding: 0; }
  .side, .no-print, .alert, .theme-toggle { display: none !important; }
  main { padding: 0; max-width: none; }
  .invoice, .card, .table-wrap { box-shadow: none; border-color: #999; background: #fff; color: #000; }
  .invoice { margin: 0; padding: 0; border: 0; }
  .badge { border: 1px solid #999; background: #fff; color: #000; }
  .badge::before { display: none; }
  th { background: #eee; color: #000; }
  .invoice-lines tfoot td { background: #f3f3f3; }
  a { color: inherit; text-decoration: none; }
  .brand .logo { background: #333; color: #fff; }
  .muted, .hint { color: #444; }
}
