:root {
  --bg: #090e14;
  --bg-2: #0d131b;
  --surface: #111820;
  --surface-2: #151d27;
  --surface-3: #1a2430;
  --border: #27313c;
  --border-soft: #1d2732;
  --text: #f4f7fb;
  --muted: #9aa7b6;
  --muted-2: #6f7c8b;
  --green: #22d96b;
  --green-dark: #0d6f39;
  --blue: #3498ff;
  --purple: #9b62ff;
  --amber: #f5a623;
  --red: #f14d55;
  --shadow: 0 22px 60px rgba(0, 0, 0, .34);
  --radius: 12px;
  --sidebar: 224px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: radial-gradient(circle at 70% -20%, #15212b 0, var(--bg) 42%); color: var(--text); font-size: 14px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 20%, rgba(34, 217, 107, .13), transparent 26%),
    radial-gradient(circle at 80% 78%, rgba(52, 152, 255, .1), transparent 28%),
    #090e14;
}
.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(22,31,41,.98), rgba(13,19,27,.98));
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 34px;
}
.brand { font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
.brand span { color: var(--green); font-weight: 800; }
.brand strong { font-weight: 600; }
.brand-login { font-size: 22px; margin-bottom: 28px; }
.login-card h1 { font-size: 26px; margin: 0 0 9px; letter-spacing: -.03em; }
.login-card > p { margin: 0 0 26px; color: var(--muted); line-height: 1.6; }
.login-card form { display: grid; gap: 17px; }
label { display: grid; gap: 8px; color: #d9e0e8; font-weight: 600; font-size: 13px; }
input, select {
  width: 100%;
  border: 1px solid var(--border);
  background: #0b1118;
  color: var(--text);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 12px;
  outline: none;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(34,217,107,.1); }
.form-error { color: #ff9da2; background: rgba(241,77,85,.1); border: 1px solid rgba(241,77,85,.32); padding: 10px 12px; border-radius: 8px; }
.login-note { color: var(--muted-2); font-size: 12px; line-height: 1.5; margin-top: 18px; text-align: center; }

.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--text);
  font-weight: 700;
  transition: .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button-primary { background: var(--green); color: #04120a; }
.button-secondary { background: #17334a; border-color: #285579; color: #cfeaff; }
.button-danger { background: #8d252b; border-color: #bd3941; }
.button-ghost { background: #151d26; border-color: var(--border); color: #c5ced8; }
.button-block { width: 100%; min-height: 44px; }
.button-small { min-height: 34px; padding: 0 11px; font-size: 12px; }

.app { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: linear-gradient(180deg, #111820, #0d131a);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.sidebar .brand { min-height: 72px; display: flex; align-items: center; padding: 0 24px; border-bottom: 1px solid var(--border-soft); }
.nav { display: grid; gap: 5px; padding: 15px 10px; }
.nav-item {
  border: 0;
  color: #c6d0db;
  background: transparent;
  min-height: 43px;
  border-radius: 8px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font-weight: 600;
}
.nav-item:hover { background: #151f29; color: #fff; }
.nav-item.active { background: rgba(34, 217, 107, .13); color: var(--green); }
.nav-icon { width: 18px; text-align: center; color: #aeb9c5; }
.badge { margin-left: auto; min-width: 20px; height: 20px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--red); color: white; font-size: 11px; }
.sidebar-status { margin-top: auto; border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft); padding: 18px 20px; display: flex; gap: 10px; align-items: flex-start; }
.status-dot { width: 9px; height: 9px; margin-top: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px rgba(34,217,107,.65); flex: 0 0 auto; }
.sidebar-status strong { display: block; font-size: 12px; margin-bottom: 5px; }
.sidebar-status small { color: var(--green); font-size: 11px; line-height: 1.45; }
.sidebar-footer { color: var(--muted-2); font-size: 11px; line-height: 1.6; padding: 16px 20px 22px; }

.main { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 72px;
  padding: 0 22px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(9,14,20,.84);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #141c25;
  color: #d8e0e8;
  font-size: 18px;
  display: inline-grid;
  place-items: center;
}
.icon-button:hover { border-color: #3c4b5b; background: #18232e; }
.page-title { display: grid; gap: 3px; }
.page-title strong { font-size: 14px; }
.page-title span { color: var(--muted-2); font-size: 11px; }
.secure-label { color: var(--green); font-size: 12px; }
.clock { color: #c3ccd6; font-variant-numeric: tabular-nums; font-size: 12px; }
.account-button { min-height: 36px; border: 1px solid var(--border); background: #151e27; color: #dbe2ea; border-radius: 8px; padding: 0 12px; display: flex; align-items: center; gap: 8px; }
.mobile-only { display: none; }

.content { padding: 20px; width: 100%; max-width: 1800px; margin: 0 auto; }
.page-section { display: none; }
.page-section.active { display: block; }
.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.metric-card {
  min-height: 126px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(145deg, #151d26, #10171f);
  padding: 17px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.metric-card::after { content: ""; position: absolute; width: 100px; height: 100px; border-radius: 50%; background: rgba(255,255,255,.025); right: -38px; top: -48px; }
.metric-icon { width: 42px; height: 42px; flex: 0 0 42px; border-radius: 11px; border: 1px solid var(--border-soft); background: #1a232d; display: grid; place-items: center; color: #d7e0ea; font-size: 21px; }
.metric-card span { color: #d2dae3; font-size: 12px; }
.metric-card strong { display: block; font-size: 25px; margin: 6px 0 5px; letter-spacing: -.03em; }
.metric-card small { color: var(--muted); font-size: 11px; }
.sparkline { position: absolute; right: 12px; bottom: 11px; width: 92px; height: 28px; }

.overview-grid { display: grid; grid-template-columns: 35% 65%; gap: 12px; margin-top: 12px; }
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(180deg, #121a23, #0f161e); box-shadow: 0 8px 26px rgba(0,0,0,.12); }
.panel-heading { min-height: 48px; padding: 0 16px; border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading h2 { margin: 0; font-size: 14px; letter-spacing: -.01em; }
.panel-heading select { min-height: 32px; width: auto; font-size: 12px; }
.live-chip { color: var(--green); border: 1px solid rgba(34,217,107,.25); background: rgba(34,217,107,.08); border-radius: 99px; padding: 4px 8px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.spec-list { margin: 0; padding: 6px 16px 12px; }
.spec-list > div { display: grid; grid-template-columns: 132px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.spec-list > div:last-child { border-bottom: 0; }
.spec-list dt { color: #dbe3eb; font-weight: 600; }
.spec-list dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.chart-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 14px 12px 12px; }
.chart-box { min-width: 0; padding: 5px 8px 2px; border-right: 1px solid var(--border-soft); }
.chart-box:last-child { border-right: 0; }
.chart-box h3 { font-size: 11px; margin: 0 0 8px; color: #d7dfe8; }
.chart-box canvas { display: block; width: 100%; height: 168px; }

.container-panel { margin-top: 12px; }
.table-heading { padding-block: 8px; }
.table-tools { display: flex; gap: 8px; }
.table-tools input { min-height: 34px; width: 240px; }
.table-wrap { overflow-x: auto; }
.container-table { width: 100%; border-collapse: collapse; min-width: 1080px; }
.container-table th { height: 38px; padding: 0 12px; background: #19222c; color: #dbe3ec; text-align: left; font-size: 11px; white-space: nowrap; }
.container-table td { padding: 10px 12px; border-top: 1px solid var(--border-soft); color: #c7d0da; font-size: 12px; vertical-align: middle; }
.container-table tr:hover td { background: rgba(255,255,255,.018); }
.service-name { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #eef3f8; }
.service-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(34,217,107,.4); }
.service-dot.offline { background: var(--red); box-shadow: 0 0 8px rgba(241,77,85,.4); }
.muted { color: var(--muted-2); }
.status-pill { display: inline-flex; align-items: center; min-height: 22px; border-radius: 5px; padding: 0 7px; font-weight: 700; font-size: 10px; }
.status-running, .status-healthy { color: #57ee91; background: rgba(34,217,107,.12); }
.status-stopped, .status-failed, .status-unhealthy { color: #ff858b; background: rgba(241,77,85,.13); }
.status-pending, .status-starting { color: #ffd176; background: rgba(245,166,35,.12); }
.resource-cell { min-width: 110px; }
.resource-value { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.progress { height: 4px; border-radius: 99px; background: #202a35; overflow: hidden; }
.progress > span { height: 100%; display: block; border-radius: inherit; background: var(--green); }
.progress.warning > span { background: var(--amber); }
.progress.danger > span { background: var(--red); }
.action-buttons { display: flex; flex-wrap: wrap; gap: 5px; min-width: 390px; }
.action-button { min-height: 29px; border-radius: 6px; padding: 0 9px; border: 1px solid var(--border); background: #17212b; color: #dbe3ec; font-size: 10px; font-weight: 700; }
.action-button:hover { filter: brightness(1.15); }
.action-start { border-color: #26496d; background: #142b41; color: #b9ddff; }
.action-restart { border-color: #246b9e; background: #123d5b; color: #b9e4ff; }
.action-rebuild { border-color: #8f5c0f; background: #663c08; color: #ffe0a2; }
.action-repair { border-color: #7040aa; background: #44256d; color: #dfc5ff; }
.action-logs { border-color: #5d3f8b; background: #33224f; color: #d8c5ff; }
.action-stop { border-color: #8a3136; background: #64242a; color: #ffd3d6; }
.action-button:disabled { opacity: .32; cursor: not-allowed; }

.lower-grid { display: grid; grid-template-columns: 1fr 1fr 1.05fr; gap: 12px; margin-top: 12px; }
.ranking-list { padding: 12px 16px 15px; display: grid; gap: 11px; }
.ranking-row { display: grid; grid-template-columns: minmax(80px, 1fr) 70px; gap: 10px; align-items: center; }
.ranking-row strong { font-size: 11px; font-weight: 600; color: #d8e1ea; }
.ranking-row span { text-align: right; font-size: 11px; color: #d7e0e8; }
.ranking-row .progress { grid-column: 1 / -1; margin-top: -5px; }
.alert-list { padding: 8px 16px 15px; display: grid; gap: 3px; }
.alert-item { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.alert-item:last-child { border-bottom: 0; }
.alert-icon { font-size: 17px; color: var(--amber); }
.alert-item.danger .alert-icon { color: var(--red); }
.alert-item strong { display: block; font-size: 12px; margin-bottom: 5px; }
.alert-item p { color: var(--muted); font-size: 11px; line-height: 1.45; margin: 0; }
.alert-item time { color: var(--muted-2); font-size: 10px; }
.empty-state { color: var(--muted); padding: 24px 4px; text-align: center; line-height: 1.55; }

.section-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-header h1 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.section-header p { margin: 7px 0 0; color: var(--muted); }
.logs-page-panel { min-height: 610px; }
.logs-toolbar { display: grid; grid-template-columns: 220px 150px auto auto; gap: 10px; align-items: center; padding: 14px; border-bottom: 1px solid var(--border-soft); }
.toggle { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--muted); }
.toggle input { display: none; }
.toggle span { width: 34px; height: 19px; background: #26313d; border-radius: 99px; position: relative; transition: .2s; }
.toggle span::after { content: ""; position: absolute; width: 13px; height: 13px; border-radius: 50%; left: 3px; top: 3px; background: #9ba8b6; transition: .2s; }
.toggle input:checked + span { background: rgba(34,217,107,.3); }
.toggle input:checked + span::after { left: 18px; background: var(--green); }
.log-output { margin: 0; padding: 16px; min-height: 520px; max-height: 68vh; overflow: auto; background: #070b10; color: #b9d6c3; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.spec-card-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.spec-card { border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(180deg,#141c25,#10171f); padding: 20px; }
.spec-card h2 { margin: 0 0 16px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.spec-card strong { display: block; font-size: 24px; letter-spacing: -.03em; margin-bottom: 8px; }
.spec-card p { margin: 0; color: #c3ccd6; line-height: 1.55; overflow-wrap: anywhere; }
.alert-list.large { padding: 12px 18px 20px; }
.alert-list.large .alert-item { padding: 18px 4px; }
.backup-note { padding: 14px 16px; color: #ffd998; background: rgba(245,166,35,.08); border-bottom: 1px solid rgba(245,166,35,.18); }
.backup-list { padding: 8px 16px 18px; }
.backup-item { display: grid; grid-template-columns: minmax(160px,1fr) 120px 120px 2fr; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.backup-item:last-child { border-bottom: 0; }
.backup-item strong { font-size: 12px; }
.backup-item span, .backup-item small { color: var(--muted); }
.backup-files { display: flex; flex-wrap: wrap; gap: 6px; }
.backup-files span { border: 1px solid var(--border); background: #151e27; border-radius: 6px; padding: 4px 7px; font-size: 10px; }
.footer { min-height: 46px; margin-top: auto; padding: 0 20px; border-top: 1px solid var(--border-soft); display: flex; justify-content: space-between; align-items: center; color: var(--muted-2); font-size: 11px; }

.modal { position: fixed; inset: 0; z-index: 100; background: rgba(2,5,8,.76); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; }
.modal-card { width: min(760px, 100%); max-height: 90vh; overflow: auto; border: 1px solid #34404d; border-radius: 14px; background: #111820; box-shadow: var(--shadow); position: relative; }
.confirm-card { width: min(500px,100%); padding: 24px; }
.modal-card h2 { margin: 0 0 10px; font-size: 20px; }
.modal-card p { color: var(--muted); line-height: 1.55; }
.modal-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border: 1px solid var(--border); background: #17202a; color: #dbe3eb; border-radius: 7px; font-size: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.job-card { width: min(880px,100%); }
.job-title-row { min-height: 82px; padding: 20px 54px 16px 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border-soft); }
.job-title-row h2 { margin-bottom: 5px; }
.job-title-row p { margin: 0; }
.job-output { min-height: 400px; max-height: 62vh; }
.toast-container { position: fixed; z-index: 200; right: 18px; bottom: 18px; display: grid; gap: 10px; }
.toast { width: min(360px, calc(100vw - 36px)); border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: 9px; background: #151e27; color: #e8eef4; padding: 13px 15px; box-shadow: var(--shadow); animation: toast-in .2s ease; }
.toast.error { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 1380px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .metric-card:nth-child(4), .metric-card:nth-child(5) { grid-column: span 1; }
  .overview-grid { grid-template-columns: 40% 60%; }
  .lower-grid { grid-template-columns: 1fr 1fr; }
  .alert-panel { grid-column: 1 / -1; }
}
@media (max-width: 1080px) {
  :root { --sidebar: 208px; }
  .overview-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-card:last-child { grid-column: span 2; }
  .spec-card-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-right .clock, .topbar-right .secure-label { display: none; }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .mobile-only { display: inline-grid; }
  .topbar { height: 64px; padding: 0 12px; }
  .topbar-right .account-button { display: none; }
  .content { padding: 12px; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card:last-child { grid-column: auto; }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-box { border-right: 0; border-bottom: 1px solid var(--border-soft); }
  .chart-box:last-child { border-bottom: 0; }
  .lower-grid, .spec-card-grid { grid-template-columns: 1fr; }
  .alert-panel { grid-column: auto; }
  .section-header { align-items: flex-start; flex-direction: column; }
  .logs-toolbar { grid-template-columns: 1fr 1fr; }
  .logs-toolbar .toggle { grid-column: 1 / -1; }
  .backup-item { grid-template-columns: 1fr 1fr; }
  .backup-files { grid-column: 1 / -1; }
  .footer { flex-direction: column; justify-content: center; gap: 4px; }
}
@media (max-width: 480px) {
  .login-card { padding: 24px 20px; }
  .topbar-right #logoutButton { font-size: 0; width: 36px; padding: 0; }
  .topbar-right #logoutButton::after { content: "↪"; font-size: 16px; }
  .table-tools input { width: 170px; }
  .logs-toolbar { grid-template-columns: 1fr; }
  .logs-toolbar .toggle { grid-column: auto; }
  .backup-item { grid-template-columns: 1fr; }
}
