:root {
  --bg: #0b1020;
  --bg-soft: #121933;
  --bg-elev: #162041;
  --line: #263255;
  --text: #edf2ff;
  --muted: #98a6cf;
  --brand: #5b8cff;
  --brand-2: #7a5cff;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --cyan: #06b6d4;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 18px 60px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: radial-gradient(circle at top, #15224a 0%, #0b1020 45%); color: var(--text); font-family: Inter, system-ui, sans-serif; min-height: 100%; }
body { overflow-x: hidden; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }
.mobile-only { display: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #33416b; border-radius: 999px; }

.login-shell {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  padding: 24px; background: radial-gradient(circle at 20% 20%, rgba(91,140,255,.25), transparent 30%), rgba(6,10,20,.75);
  backdrop-filter: blur(10px);
}
.login-card {
  width: min(100%, 460px); background: rgba(15,22,45,.95); border: 1px solid rgba(255,255,255,.08);
  border-radius: 28px; padding: 28px; box-shadow: var(--shadow);
}
.brand-lockup { display: flex; gap: 16px; align-items: center; margin-bottom: 24px; }
.brand-lockup h1 { margin: 0 0 4px; font-size: 1.7rem; }
.brand-lockup p { margin: 0; color: var(--muted); }
.brand-mark {
  width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: white; font-size: 1.3rem;
  box-shadow: 0 12px 35px rgba(91,140,255,.35);
}
.brand-mark.small { width: 42px; height: 42px; border-radius: 14px; font-size: 1rem; }
.login-form { display: grid; gap: 14px; }
.field label { display: block; color: var(--muted); margin-bottom: 8px; font-size: .9rem; font-weight: 600; }
.field input, .field select, .field textarea, .search-input, .json-box, .table-select {
  width: 100%; background: rgba(255,255,255,.04); border: 1px solid var(--line); color: var(--text);
  border-radius: 14px; padding: 12px 14px; outline: none;
}
.field textarea, .json-box { min-height: 100px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .search-input:focus, .json-box:focus { border-color: var(--brand); }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 48px; }
.password-wrap .icon-only { position: absolute; top: 7px; right: 6px; }
.login-footnote { margin-top: 18px; color: var(--muted); font-size: .88rem; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 270px; background: rgba(10,16,33,.92); border-right: 1px solid rgba(255,255,255,.06);
  backdrop-filter: blur(14px); display: flex; flex-direction: column; z-index: 20; transform: translateX(0); transition: transform .22s ease;
}
.sidebar.collapsed { transform: translateX(-100%); }
.sidebar-top, .sidebar-foot { padding: 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.06); border-bottom: 0; margin-top: auto; display: flex; gap: 10px; align-items: center; }
.sidebar-branding { display: flex; gap: 12px; align-items: center; }
.sidebar-branding strong { display: block; }
.sidebar-branding span { color: var(--muted); font-size: .84rem; }
.sidebar-search { padding: 14px 18px; position: relative; }
.sidebar-search i { position: absolute; top: 26px; left: 32px; color: var(--muted); }
.sidebar-search input { padding-left: 38px; }
.nav-list { padding: 6px 10px 18px; overflow: auto; }
.nav-label { color: #7f8db9; text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; font-weight: 700; padding: 12px 10px 6px; }
.nav-item {
  width: 100%; border: 0; background: transparent; color: var(--muted); display: flex; gap: 12px; align-items: center;
  padding: 12px 14px; border-radius: 14px; margin-bottom: 4px; text-align: left; transition: .18s ease;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(91,140,255,.18), rgba(122,92,255,.18)); color: white; border: 1px solid rgba(122,92,255,.28); }
.admin-chip {
  flex: 1; display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.06);
  border-radius: 999px; padding: 10px 14px; color: var(--muted); min-width: 0;
}
.admin-chip span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 10; margin-left: 270px; display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; background: rgba(11,16,32,.82); backdrop-filter: blur(14px); border-bottom: 1px solid rgba(255,255,255,.06);
}
.page-root { margin-left: 270px; padding: 24px; }
.eyebrow { color: var(--muted); text-transform: uppercase; letter-spacing: .12em; font-size: .7rem; font-weight: 700; margin-bottom: 4px; }
.topbar h2 { margin: 0; font-size: 1.35rem; }
.topbar-left, .topbar-right { display: flex; gap: 14px; align-items: center; }
.status-pill {
  display: inline-flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: 999px; background: rgba(255,255,255,.05); color: var(--muted); border: 1px solid rgba(255,255,255,.06);
}
.status-dot { width: 10px; height: 10px; border-radius: 999px; background: var(--green); box-shadow: 0 0 0 6px rgba(34,197,94,.12); }

.primary-btn, .secondary-btn, .ghost-btn, .danger-btn {
  border: 0; border-radius: 14px; padding: 11px 15px; display: inline-flex; align-items: center; gap: 10px; justify-content: center; transition: .18s ease;
}
.primary-btn { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: white; box-shadow: 0 12px 26px rgba(91,140,255,.25); }
.primary-btn:hover { transform: translateY(-1px); }
.secondary-btn { background: rgba(255,255,255,.05); color: var(--text); border: 1px solid rgba(255,255,255,.06); }
.secondary-btn:hover, .ghost-btn:hover { background: rgba(255,255,255,.08); }
.ghost-btn { background: transparent; color: var(--muted); }
.danger-btn { background: rgba(239,68,68,.14); color: #ffb6b6; border: 1px solid rgba(239,68,68,.2); }
.icon-only { width: 40px; height: 40px; padding: 0; }
.full-btn { width: 100%; }

.page-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 22px; }
.page-header h3 { margin: 0 0 6px; font-size: 1.5rem; }
.page-header p { margin: 0; color: var(--muted); }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.metric-card, .panel, .chart-card, .table-card, .hero-card {
  background: rgba(17,25,48,.84); border: 1px solid rgba(255,255,255,.06); border-radius: 22px; box-shadow: var(--shadow);
}
.metric-card { padding: 18px; position: relative; overflow: hidden; }
.metric-card::after { content: ''; position: absolute; inset: auto -10% -40% auto; width: 120px; height: 120px; border-radius: 999px; background: rgba(255,255,255,.04); }
.metric-card .meta { color: var(--muted); font-size: .84rem; font-weight: 600; }
.metric-card .value { margin-top: 10px; font-size: 2rem; font-weight: 800; }
.metric-card .delta { margin-top: 6px; font-size: .84rem; color: var(--muted); }
.metric-card.blue { border-color: rgba(91,140,255,.18); }
.metric-card.green { border-color: rgba(34,197,94,.18); }
.metric-card.yellow { border-color: rgba(245,158,11,.18); }
.metric-card.red { border-color: rgba(239,68,68,.18); }

.two-col, .three-col { display: grid; gap: 16px; margin-bottom: 22px; }
.two-col { grid-template-columns: 1.4fr 1fr; }
.three-col { grid-template-columns: repeat(3, minmax(0,1fr)); }
.panel, .chart-card, .table-card, .hero-card { padding: 18px; }
.panel-head, .table-head, .chart-head { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 14px; }
.panel-head h4, .table-head h4, .chart-head h4 { margin: 0; font-size: 1.05rem; }
.subtle { color: var(--muted); font-size: .9rem; }
.hero-card { padding: 22px; margin-bottom: 22px; background: linear-gradient(135deg, rgba(91,140,255,.14), rgba(122,92,255,.1)); }
.hero-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 18px; }
.quick-list, .mini-list { display: grid; gap: 10px; }
.quick-item, .mini-item {
  display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 16px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.04);
}
.quick-item strong, .mini-item strong { display: block; }
.quick-item span, .mini-item span { color: var(--muted); font-size: .86rem; }

.table-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.03);
  padding: 4px 8px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
}
.pagination .subtle {
  font-size: 13px;
  font-weight: 500;
  min-width: 100px;
  text-align: center;
}
.table-wrap { overflow: auto; border-radius: 16px; border: 1px solid rgba(255,255,255,.06); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; text-align: left; vertical-align: top; }
thead th { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .11em; background: rgba(255,255,255,.04); }
tbody tr { border-top: 1px solid rgba(255,255,255,.06); }
tbody tr:hover { background: rgba(255,255,255,.03); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; }
.truncate { max-width: 240px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap;
}
.badge.green { background: rgba(34,197,94,.14); color: #9ff0bb; }
.badge.red { background: rgba(239,68,68,.14); color: #ffb6b6; }
.badge.yellow { background: rgba(245,158,11,.14); color: #ffd68a; }
.badge.blue { background: rgba(91,140,255,.14); color: #b7cbff; }
.badge.grey { background: rgba(255,255,255,.08); color: #ced8f5; }
.badge.purple { background: rgba(122,92,255,.14); color: #d2c4ff; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 16px; }
.entity-card {
  padding: 18px; border-radius: 20px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); display: grid; gap: 12px;
}
.entity-card-top { display: flex; gap: 12px; }
.thumb {
  width: 54px; height: 54px; border-radius: 16px; background: rgba(255,255,255,.06); display: grid; place-items: center; overflow: hidden; flex-shrink: 0;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.meta-list { display: grid; gap: 8px; color: var(--muted); font-size: .88rem; }
.meta-list strong { color: var(--text); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.toggle-row, .switch-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; }
.toggle-chip { display: inline-flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); }

.alert { border-radius: 16px; padding: 12px 14px; margin-bottom: 16px; border: 1px solid transparent; }
.alert.info { background: rgba(6,182,212,.12); color: #b9f3ff; border-color: rgba(6,182,212,.2); }
.alert.error { background: rgba(239,68,68,.12); color: #ffc2c2; border-color: rgba(239,68,68,.2); }
.alert.warning { background: rgba(245,158,11,.12); color: #ffe2af; border-color: rgba(245,158,11,.2); }
.alert.success { background: rgba(34,197,94,.12); color: #bff6cf; border-color: rgba(34,197,94,.2); }

.modal-overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(7,10,20,.72); backdrop-filter: blur(10px); display: grid; place-items: center; padding: 20px;
}
.modal-card {
  width: min(100%, 900px); max-height: calc(100vh - 40px); overflow: auto; background: #0f1730; border-radius: 24px; border: 1px solid rgba(255,255,255,.08); box-shadow: var(--shadow);
}
.modal-head, .modal-foot { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.06); }
.modal-foot { border-top: 1px solid rgba(255,255,255,.06); border-bottom: 0; justify-content: flex-end; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }

.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 70; display: grid; gap: 10px; }
.toast {
  min-width: 260px; max-width: 420px; display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; border-radius: 16px; background: rgba(15,22,45,.98); border: 1px solid rgba(255,255,255,.06); box-shadow: var(--shadow);
}
.toast.success i { color: var(--green); }
.toast.error i { color: var(--red); }
.toast.warning i { color: var(--yellow); }
.toast.info i { color: var(--brand); }

.empty {
  padding: 30px 18px; color: var(--muted); text-align: center;
}
.loading { display: grid; place-items: center; min-height: 220px; color: var(--muted); }
.loading i { font-size: 1.5rem; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.kv:last-child { border-bottom: 0; }
.kv strong { color: var(--muted); }
.package-list, .system-grid { display: grid; gap: 14px; }
.package-item, .ip-card {
  padding: 14px 16px; border-radius: 16px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06);
}
.system-grid { grid-template-columns: 1.2fr .8fr; }

@media (max-width: 1100px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .two-col, .hero-grid, .system-grid, .three-col { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .mobile-only { display: inline-flex; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .topbar, .page-root { margin-left: 0; }
}
@media (max-width: 720px) {
  .metrics-grid, .form-grid { grid-template-columns: 1fr; }
  .topbar { padding: 16px; }
  .page-root { padding: 16px; }
  .page-actions, .toolbar-group { width: 100%; }
  .status-pill { display: none; }
}
