:root {
  color-scheme: dark;
  --bg: #080909;
  --sidebar: #0d0f0f;
  --panel: #111313;
  --panel-hover: #171919;
  --line: #242727;
  --text: #f3f4f1;
  --muted: #858a87;
  --accent: #e8ebe6;
  --success: #55c989;
  --danger: #f27483;
  --warning: #e9c575;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5f3;
  --sidebar: #ffffff;
  --panel: #ffffff;
  --panel-hover: #f0f2f0;
  --line: #dfe3df;
  --text: #171a18;
  --muted: #6f7771;
  --accent: #171a18;
  --success: #218653;
  --danger: #c64b58;
  --warning: #a97816;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: -.01em;
}
button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.shell { min-height: 100vh; }
.dashboard { min-height: 100vh; display: grid; grid-template-columns: 244px 1fr; }

.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 20px 12px 14px;
  background: var(--sidebar);
  border-right: 1px solid #171a19;
}
.brand-lockup { display: flex; align-items: center; color: #f1f2ed; }
.brand-logo { display: block; width: 94px; height: 40px; object-fit: contain; }
.side-title { margin: 42px 9px 17px; color: #f0f1ec; font-size: 19px; font-weight: 700; }
.side-nav { display: grid; gap: 3px; }
.side-nav .tab {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 11px;
  border: 0; border-radius: 9px; background: transparent; color: #a2a6a3;
  text-align: left; cursor: pointer; font-weight: 600; transition: background .18s ease, color .18s ease, transform .18s ease;
}
.side-nav .tab:hover { background: #171919; color: #e7eae5; transform: translateX(2px); }
.side-nav .tab.active { background: #1a1c1c; color: #f5f6f2; }
.nav-icon { display: inline-grid; place-items: center; width: 18px; color: #929793; }
.nav-icon svg, .utility-icon svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.sidebar-spacer { flex: 1; }
.account-area { position: relative; margin-top: 12px; }
.account-menu {
  position: absolute; z-index: 10; right: 0; bottom: calc(100% + 8px); width: 232px;
  padding: 9px 8px 8px; border: 1px solid #303234; border-radius: 14px;
  background: #191a1d; box-shadow: 0 14px 34px rgba(0, 0, 0, .42);
}
.account-menu-title { margin: 1px 8px 6px; color: #85888e; font-size: 12px; }
.account-menu-item {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 38px; padding: 8px;
  border: 0; border-radius: 7px; background: transparent; color: #f1f2f3;
  font-size: 13px; font-weight: 600; text-decoration: none; text-align: left; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.account-menu-item:hover { background: #2a2b2f; color: #fff; }
.account-menu-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.account-menu-item.danger { color: #f47d87; }
.account-menu-item.danger:hover { background: #3a2227; color: #ff9aa2; }
.account-menu-divider { height: 1px; margin: 6px 8px; background: #2c2d30; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 12px 10px; background: #191b1b; border-radius: 11px; transition: background .18s ease; }
.user-card:hover { background: #222525; }
.user-card strong, .user-card small { display: block; overflow: hidden; max-width: 120px; text-overflow: ellipsis; white-space: nowrap; }
.user-card strong { color: #eff1ed; font-size: 13px; }
.user-card small { margin-top: 3px; color: #7f8581; font-size: 11px; }
.user-avatar { display: block; width: 34px; height: 34px; border-radius: 50%; background: #e7e9e5; color: #222; object-fit: cover; }
.more-button { display: grid; place-items: center; width: 34px; height: 34px; margin-left: auto; padding: 0; border: 0; border-radius: 8px; background: #292b2b; color: #e5e8e4; cursor: pointer; transition: background .15s ease, color .15s ease; }
.more-button svg { display: block; width: 17px; height: 17px; fill: currentColor; }
.more-button:hover, .more-button[aria-expanded="true"] { background: #292b2b; color: #e7eae5; }

.content { min-width: 0; padding: 0 35px 60px; }
.utilitybar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; height: 63px; border-bottom: 1px solid #151817; }
.utility-icons { display: flex; align-items: center; gap: 27px; height: 100%; }
.utility-actions { display: flex; justify-content: flex-end; align-items: center; }
.theme-toggle {
  position: relative; display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: #858b87;
  cursor: pointer; transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.theme-toggle:hover { border-color: #303432; background: #1b1e1d; color: #f0f2ed; }
.theme-toggle svg { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.6; }
.utility-icon { position: relative; width: 23px; height: 100%; padding: 0; border: 0; background: transparent; color: #747a76; cursor: pointer; font-size: 21px; }
.utility-icon:hover, .utility-icon.active { color: #eef0eb; }
.utility-icon.active::after { position: absolute; bottom: 0; left: 50%; width: 19px; height: 2px; background: #eff1ec; content: ""; transform: translateX(-50%); }
.utility-icon[data-tooltip]::before, .theme-toggle[data-tooltip]::before {
  position: absolute; z-index: 20; top: calc(100% + 7px); left: 50%; padding: 5px 8px;
  border: 1px solid #303432; border-radius: 5px; background: #1b1d1c; color: #e6e9e4;
  content: attr(data-tooltip); font-size: 11px; font-weight: 600; white-space: nowrap;
  opacity: 0; pointer-events: none; transform: translate(-50%, -3px);
  transition: opacity .15s ease, transform .15s ease;
}
.utility-icon[data-tooltip]:hover::before, .theme-toggle[data-tooltip]:hover::before { opacity: 1; transform: translate(-50%, 0); }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 34px 0 25px; }
.page-heading h1 { margin: 0; font-size: clamp(2rem, 4vw, 2.7rem); font-weight: 700; letter-spacing: -.06em; }
.eyebrow { margin: 0 0 8px; color: #7f8581; font-size: 10px; font-weight: 700; letter-spacing: .2em; }
.page-subtitle { margin-top: 9px; color: var(--muted); }
.live-dot { color: var(--success); font-size: 11px; font-weight: 700; letter-spacing: .13em; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat, .card, .item { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.stat { min-height: 128px; padding: 18px; }
.stat span { display: block; color: #858b87; font-size: 10px; font-weight: 700; letter-spacing: .1em; }
.stat strong { display: block; margin-top: 22px; font-size: 22px; font-weight: 600; letter-spacing: -.04em; }
.stat small { display: block; margin-top: 7px; color: #626865; font-size: 11px; }
.overview-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
.card { padding: 20px; }
.card-heading, .section-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.card-heading h2, .section-head h2 { margin: 0; font-size: 15px; }
.details { color: #878c88; font-size: 12px; }
.server-name { margin-top: 28px; color: #dfe3de; font-size: 16px; }
.rule { height: 1px; margin: 24px 0 18px; background: var(--line); }
.server-meta, .status-row { display: flex; justify-content: space-between; gap: 20px; padding: 8px 0; color: #7e8581; }
.server-meta strong, .status-row b { color: #dce0db; font-weight: 500; text-align: right; }
.green { color: var(--success) !important; font-size: 11px; letter-spacing: .08em; }
.status-mark { color: var(--success); font-size: 11px; }
.status-row { padding: 12px 0; border-bottom: 1px solid #1d201f; }
.status-row:last-child { border-bottom: 0; }

.tab-panel { display: none; max-width: 1120px; margin: 0 auto; }
.tab-panel.active { display: block; }
.stack { display: grid; gap: 10px; margin-top: 17px; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 15px 17px; }
.item:hover { background: var(--panel-hover); }
.item-main { min-width: 0; }
.item-main strong { display: block; margin-bottom: 6px; color: #e8ebe6; }
.item-main p { margin: 0; color: #858b87; font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.item-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 8px 13px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; text-decoration: none; transition: .18s ease; }
.button:hover { filter: brightness(1.15); transform: translateY(-1px); }
.button.primary { background: #e8ebe6; color: #151716; }
.button.ghost { background: #1c1f1e; border-color: #303432; color: #d8dcd7; }
.button.danger { background: #4a252d; color: #ffcbd2; }
.button.success { background: #1e4838; color: #c6f6de; }
input, select { width: 100%; padding: 10px 12px; border: 1px solid #292d2b; border-radius: 6px; outline: none; background: #101211; color: var(--text); }
input:focus, select:focus { border-color: #68706b; }
select { cursor: pointer; }
.inline-form { display: flex; gap: 8px; width: min(430px, 100%); }
.form-grid { display: grid; grid-template-columns: 1fr 1.5fr 1.25fr auto auto auto; gap: 10px; align-items: center; margin-top: 20px; }
.check { color: var(--muted); font-size: 12px; white-space: nowrap; }
.check input { width: auto; }
.media-upload { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.media-upload span { white-space: nowrap; }
.media-upload input { flex: 1; min-width: 0; width: auto; padding: 7px 9px; border-style: dashed; color: var(--muted); font-size: 12px; }
.badge { display: inline-block; padding: 4px 8px; border-radius: 999px; background: #242827; color: #aeb4af; font-size: 10px; font-weight: 600; }
.badge.pending { color: var(--warning); }
.badge.approved { color: var(--success); }
.badge.rejected { color: var(--danger); }
.login-card { width: min(420px, calc(100% - 32px)); margin: 14vh auto; padding: 48px 34px; border: 1px solid var(--line); border-radius: 12px; background: #111313; text-align: center; }
.login-card .brand-lockup { justify-content: center; margin-bottom: 30px; }
.login-card .brand-logo { width: 180px; height: 78px; }
.login-card h1 { margin: 0 0 10px; font-size: 27px; letter-spacing: -.05em; }
.login-card p:not(.eyebrow) { margin-bottom: 27px; color: var(--muted); }
.toast { position: fixed; right: 22px; bottom: 22px; padding: 12px 16px; border: 1px solid #343836; border-radius: 7px; background: #202422; color: #f0f3ee; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.dialog-modal { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 20px; }
.dialog-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .68); }
.dialog-card { position: relative; width: min(430px, 100%); padding: 24px; border: 1px solid #343836; border-radius: 12px; background: #171a19; box-shadow: 0 18px 60px rgba(0, 0, 0, .5); }
.dialog-card h2 { margin: 0; color: #f1f3ef; font-size: 18px; }
.dialog-message { margin: 10px 0 0; color: #aeb5af; line-height: 1.6; }
.dialog-label { display: block; margin: 19px 0 7px; color: #dce1dc; font-size: 13px; }
.dialog-input { display: block; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.dialog-actions .button { min-width: 70px; }
.dialog-card.confirm-only .dialog-actions { margin-top: 22px; }

:root[data-theme="light"] .brand-logo { filter: invert(1); }
:root[data-theme="light"] .sidebar { border-color: #e3e6e3; }
:root[data-theme="light"] .brand-lockup,
:root[data-theme="light"] .side-title { color: #171a18; }
:root[data-theme="light"] .side-nav .tab { color: #68716b; }
:root[data-theme="light"] .side-nav .tab:hover,
:root[data-theme="light"] .side-nav .tab.active { background: #edf0ed; color: #171a18; }
:root[data-theme="light"] .nav-icon { color: #707972; }
:root[data-theme="light"] .user-card { background: #f0f2f0; }
:root[data-theme="light"] .user-card:hover { background: #e8ebe8; }
:root[data-theme="light"] .user-card strong { color: #171a18; }
:root[data-theme="light"] .user-card small { color: #7c857e; }
:root[data-theme="light"] .more-button { background: #dfe4df; color: #3d4740; }
:root[data-theme="light"] .more-button:hover,
:root[data-theme="light"] .more-button[aria-expanded="true"] { background: #dfe4df; color: #171a18; }
:root[data-theme="light"] .utilitybar { border-color: #e0e4e0; }
:root[data-theme="light"] .utility-icon { color: #7a837c; }
:root[data-theme="light"] .utility-icon:hover,
:root[data-theme="light"] .utility-icon.active { color: #171a18; }
:root[data-theme="light"] .utility-icon.active::after { background: #171a18; }
:root[data-theme="light"] .theme-toggle { color: #7a837c; }
:root[data-theme="light"] .theme-toggle:hover { border-color: #d6dbd6; background: #e9ece9; color: #171a18; }
:root[data-theme="light"] .page-heading h1,
:root[data-theme="light"] .card-heading h2 { color: #171a18; }
:root[data-theme="light"] .eyebrow,
:root[data-theme="light"] .stat span,
:root[data-theme="light"] .stat small,
:root[data-theme="light"] .details,
:root[data-theme="light"] .server-meta,
:root[data-theme="light"] .status-row,
:root[data-theme="light"] .item-main p { color: #737c75; }
:root[data-theme="light"] .server-name,
:root[data-theme="light"] .server-meta strong,
:root[data-theme="light"] .status-row b,
:root[data-theme="light"] .item-main strong { color: #2b332d; }
:root[data-theme="light"] .rule,
:root[data-theme="light"] .status-row { border-color: #e4e7e4; }
:root[data-theme="light"] .button.primary { background: #1c211e; color: #f7f8f6; }
:root[data-theme="light"] .button.ghost { background: #eef1ee; border-color: #d9ded9; color: #303832; }
:root[data-theme="light"] input { border-color: #d7ddd7; background: #fff; color: #171a18; }
:root[data-theme="light"] input:focus { border-color: #8d9890; }
:root[data-theme="light"] select { border-color: #d7ddd7; background: #fff; color: #171a18; }
:root[data-theme="light"] select:focus { border-color: #8d9890; }
:root[data-theme="light"] .account-menu { border-color: #d7dbd7; background: #fff; box-shadow: 0 14px 34px rgba(25, 35, 28, .16); }
:root[data-theme="light"] .account-menu-title { color: #7b847d; }
:root[data-theme="light"] .account-menu-item { color: #303832; }
:root[data-theme="light"] .account-menu-item:hover { background: #eef1ee; color: #171a18; }
:root[data-theme="light"] .account-menu-item.danger { color: #c64b58; }
:root[data-theme="light"] .account-menu-item.danger:hover { background: #fff0f1; color: #b13947; }
:root[data-theme="light"] .account-menu-divider { background: #e2e5e2; }
:root[data-theme="light"] .login-card { background: #fff; }
:root[data-theme="light"] .toast { border-color: #cbd3cb; background: #fff; color: #202721; box-shadow: 0 8px 24px rgba(25, 35, 28, .12); }
:root[data-theme="light"] .dialog-card { border-color: #d7dbd7; background: #fff; box-shadow: 0 18px 60px rgba(25, 35, 28, .2); }
:root[data-theme="light"] .dialog-card h2 { color: #171a18; }
:root[data-theme="light"] .dialog-message { color: #6f7771; }
:root[data-theme="light"] .dialog-label { color: #303832; }

@media (max-width: 850px) {
  .dashboard { display: block; }
  .sidebar { min-height: auto; border-right: 0; border-bottom: 1px solid #171a19; }
  .side-title { margin-top: 24px; }
  .side-nav { display: flex; overflow-x: auto; }
  .side-nav .tab { width: auto; white-space: nowrap; }
  .sidebar-spacer { display: none; }
  .user-card { width: 220px; }
  .content { padding: 0 18px 44px; }
  .utilitybar { height: 55px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .overview-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .utility-icons { gap: 14px; }
  .page-heading, .section-head { align-items: flex-start; flex-direction: column; }
  .inline-form { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .media-upload { align-items: flex-start; flex-direction: column; }
  .media-upload input { width: 100%; }
  .item { align-items: flex-start; flex-direction: column; }
  .item-actions { justify-content: flex-start; }
}
