:root {
  --bg: #070d18;
  --panel: #0e1a2c;
  --panel-2: #122138;
  --border: #1d2f4b;
  --text: #e7eefb;
  --muted: #93a7c4;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --radius: 14px;
  --shadow: 0 16px 40px rgba(2, 8, 20, 0.45);
  --font: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --mono: "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(37, 99, 235, 0.18), transparent 60%),
    radial-gradient(700px 400px at 95% 0%, rgba(14, 116, 144, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 24px; letter-spacing: -0.01em; }
h2 { font-size: 15.5px; font-weight: 600; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 12.5px; background: rgba(96, 165, 250, 0.1); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.hint { color: #7d93b4; font-size: 12.5px; margin-top: 8px; }
.pre-line { white-space: pre-line; }
.text-danger { color: var(--danger) !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* layout */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 236px;
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px 14px;
  background: linear-gradient(180deg, #0b1525, #08111e);
  border-right: 1px solid rgba(93, 126, 173, 0.16);
  z-index: 40; overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; border-bottom: 1px solid rgba(93, 126, 173, 0.16); margin-bottom: 6px; }
.brand-mark {
  width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center;
  border-radius: 11px; background: linear-gradient(145deg, #2563eb, #1d4ed8);
  color: #eff6ff; font-weight: 700; font-size: 17px;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
}
.brand-mark--lg { width: 44px; height: 44px; flex-basis: 44px; border-radius: 13px; font-size: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14.5px; letter-spacing: 0.02em; }
.brand-text small { color: var(--muted); font-size: 10.5px; letter-spacing: 0.12em; text-transform: uppercase; }

.nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  color: #b9c9e2; font-size: 13.5px; border: 1px solid transparent;
}
.nav-link:hover { background: rgba(59, 130, 246, 0.08); color: var(--text); }
.nav-link.is-active { background: rgba(59, 130, 246, 0.14); border-color: rgba(59, 130, 246, 0.28); color: #dbeafe; font-weight: 500; }
.nav-icon { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; color: #7f95b8; flex: 0 0 auto; }
.nav-link.is-active .nav-icon { color: #7db3ff; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; padding: 14px 10px 2px; border-top: 1px solid rgba(93, 126, 173, 0.16); color: #6f84a6; font-size: 11.5px; }

.main { flex: 1; min-width: 0; margin-left: 236px; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30; height: 62px;
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  background: rgba(7, 13, 24, 0.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(93, 126, 173, 0.16);
}
.topbar-title { font-weight: 600; font-size: 14px; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-name { color: var(--muted); font-size: 12.5px; }
.menu-toggle { display: none; }

.content { padding: 24px 26px 60px; width: 100%; max-width: 1400px; animation: fade 0.2s ease; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; background: transparent; border: 1px solid var(--border); color: #b9c8e0; }
.icon-btn:hover { background: rgba(59, 130, 246, 0.1); }

/* headings */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .muted { margin-top: 5px; font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-block; color: var(--muted); font-size: 12.5px; margin-bottom: 6px; }
.back:hover { color: var(--text); }
.link { color: #8cbcff; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* cards */
.card {
  background: linear-gradient(180deg, rgba(18, 33, 56, 0.75), rgba(12, 23, 40, 0.94));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card--flush { padding: 0; overflow: hidden; }
.card--attention { border-color: rgba(251, 191, 36, 0.35); }
.card--danger { border-color: rgba(248, 113, 113, 0.3); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  padding: 15px 17px; border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(18, 33, 56, 0.82), rgba(11, 21, 37, 0.96));
  border: 1px solid var(--border); overflow: hidden;
}
.stat::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: #334a6e; }
.stat span { font-size: 12px; color: var(--muted); }
.stat strong { font-size: 28px; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat small { font-size: 11.5px; color: #7d93b4; }
.stat--success::after { background: var(--success); } .stat--success strong { color: #6ee7b7; }
.stat--info::after { background: var(--accent); } .stat--info strong { color: #bfdbfe; }
.stat--warning::after { background: var(--warning); } .stat--warning strong { color: #fcd34d; }
.stat--danger::after { background: var(--danger); } .stat--danger strong { color: #fca5a5; }

/* grid */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }

/* tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 10px 14px; font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: #7e93b4; border-bottom: 1px solid var(--border);
  background: rgba(9, 17, 30, 0.6); white-space: nowrap;
}
.table td { padding: 11px 14px; border-bottom: 1px solid rgba(29, 47, 75, 0.6); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: rgba(59, 130, 246, 0.05); }
.table--compact td { padding: 8px 10px; }
.cell-title { font-weight: 550; display: inline-flex; align-items: center; gap: 6px; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.actions form { display: inline; }

/* badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px;
  border-radius: 999px; font-size: 11.5px; border: 1px solid transparent;
  background: rgba(148, 163, 184, 0.12); color: #a9bad4; white-space: nowrap;
}
.badge--online { background: rgba(52, 211, 153, 0.12); border-color: rgba(52, 211, 153, 0.28); color: #6ee7b7; }
.badge--online::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--offline { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.28); color: #fca5a5; }
.badge--offline::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--never { color: #93a7c4; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border);
  background: transparent; color: #c6d6ee; font-size: 13.5px; font-weight: 500;
  white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: rgba(59, 130, 246, 0.09); border-color: rgba(96, 165, 250, 0.35); }
.btn-primary { background: linear-gradient(180deg, #3b82f6, #2563eb); border-color: transparent; color: #f8fbff; box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28); }
.btn-primary:hover { background: linear-gradient(180deg, #4b8ffb, #2f6ff0); }
.btn-ghost { border-color: var(--border); }
.btn-danger { background: rgba(248, 113, 113, 0.13); border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }
.btn-danger:hover { background: rgba(248, 113, 113, 0.22); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); }
.field--wide { grid-column: 1 / -1; }
input, select, textarea {
  width: 100%; background: #0a1423; border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 11px; font-size: 13.5px;
}
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #5f7494; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; padding: 11px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; }
.toolbar input { flex: 1 1 240px; width: auto; }
.toolbar select { width: auto; min-width: 150px; }

/* flashes */
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.flash { padding: 10px 14px; border-radius: 10px; font-size: 13px; border: 1px solid var(--border); background: var(--panel); }
.flash--error { border-color: rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.1); color: #fecaca; }
.flash--ok { border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.1); color: #a7f3d0; }

/* misc lists */
.alert-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.alert-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 8px; }
.status-dot--online { background: var(--success); }
.status-dot--offline { background: var(--danger); }

.rdp-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rdp-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(29, 47, 75, 0.6); }
.rdp-list li:last-child { border-bottom: none; }
.rdp-list strong { display: block; font-size: 13.5px; }
.rdp-list .muted { font-size: 12px; }

.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.file-list li { display: flex; align-items: center; gap: 10px; }
.file-list li > div { flex: 1; display: flex; flex-direction: column; }
.file-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: rgba(59, 130, 246, 0.14); color: #93c5fd; }

.thumb-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.thumb-strip img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* host detail */
.kv { margin: 0 0 8px; display: flex; flex-direction: column; gap: 7px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.code-row { display: flex; gap: 8px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.code { flex: 1; overflow-wrap: anywhere; background: #06101d; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-family: var(--mono); font-size: 12px; }
.code-block {
  background: #06101d; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-family: var(--mono); font-size: 11.5px; line-height: 1.6;
  color: #c8d8f0; overflow-x: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  margin: 10px 0 0;
}

.metric-bars { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.metric { display: grid; grid-template-columns: 44px 1fr 52px; gap: 10px; align-items: center; font-size: 12.5px; }
.metric > span { color: var(--muted); }
.metric b { text-align: right; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: #0a1626; border-radius: 99px; overflow: hidden; border: 1px solid rgba(29, 47, 75, 0.7); }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #2563eb, #60a5fa); border-radius: 99px; }
.bar--warning i { background: linear-gradient(90deg, #b45309, #fbbf24); }
.bar--inline { width: 90px; display: inline-block; vertical-align: middle; }
.metric-value { font-size: 11.5px; color: var(--muted); margin-left: 6px; }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 90px; margin-top: 14px; padding: 8px; background: #06101d; border: 1px solid var(--border); border-radius: 10px; }
.chart-col { flex: 1; min-width: 3px; background: linear-gradient(180deg, #60a5fa, #1d4ed8); border-radius: 3px 3px 0 0; opacity: 0.85; }
.chart-col:hover { opacity: 1; }

/* gallery */
.upload-card summary { cursor: pointer; padding: 2px 0; }
.upload-card[open] summary { margin-bottom: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); color: #b9c9e2; font-size: 12.5px; }
.chip.is-active { background: rgba(59, 130, 246, 0.16); border-color: rgba(59, 130, 246, 0.4); color: #dbeafe; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.photo { margin: 0; position: relative; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--panel); }
.photo img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; transition: transform 0.2s; }
.photo:hover img { transform: scale(1.03); }
.photo figcaption { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: 12px; }
.photo figcaption > span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-delete { width: 26px; height: 26px; border-radius: 7px; border: 1px solid rgba(248, 113, 113, 0.4); background: rgba(248, 113, 113, 0.12); color: #fca5a5; font-size: 16px; line-height: 1; }
.photo-delete:hover { background: rgba(248, 113, 113, 0.25); }

/* help */
.steps { margin: 10px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.bullets { margin: 10px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 13.5px; }
.card > h2 + p, .card > h2 + ol, .card > h2 + ul { margin-top: 10px; }

/* empty/login */
.empty { text-align: center; padding: 44px 20px; border: 1px dashed var(--border); border-radius: var(--radius); background: rgba(14, 26, 44, 0.4); }
.empty h2 { margin-bottom: 6px; }
.empty p { margin-bottom: 14px; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(700px 480px at 50% -10%, rgba(37, 99, 235, 0.3), transparent 65%), #060c17; }
.login-card { width: 100%; max-width: 400px; padding: 28px; border-radius: 18px; border: 1px solid rgba(59, 130, 246, 0.24); background: linear-gradient(180deg, rgba(17, 31, 54, 0.96), rgba(10, 18, 32, 0.98)); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); display: flex; flex-direction: column; gap: 14px; }
.login-brand { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.login-brand > div { display: flex; flex-direction: column; line-height: 1.3; }
.login-brand strong { font-size: 15px; }
.login-brand small { color: var(--muted); font-size: 11.5px; }
.login-card h1 { font-size: 20px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-note { color: #7d93b4; font-size: 11.5px; }

.overlay { display: none; }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* responsive */
@media (max-width: 1000px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: 24px 0 60px rgba(0, 0, 0, 0.45); }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 18px 16px 56px; }
  .grid-2 { grid-template-columns: 1fr; }
  .overlay.is-open { display: block; position: fixed; inset: 0; background: rgba(2, 6, 14, 0.6); z-index: 35; border: none; }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .user-name { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat strong { font-size: 23px; }
  .thumb-strip { grid-template-columns: repeat(3, 1fr); }
  .gallery { grid-template-columns: repeat(2, 1fr); }
}
