:root {
  --bg: #0b1020;
  --bg-soft: #10172a;
  --card: #11182c;
  --card-2: #151f38;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f4f7fb;
  --muted: #9aa7bd;
  --accent: #6d7dff;
  --accent-2: #30d5c8;
  --ok: #2ed47a;
  --warn: #f9c74f;
  --bad: #ef476f;
  --neutral: #77839a;
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(109, 125, 255, 0.22), transparent 34vw),
    radial-gradient(circle at 80% 10%, rgba(48, 213, 200, 0.12), transparent 28vw),
    var(--bg);
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
textarea, select { font: inherit; }
button, a, input { outline-color: var(--accent-2); }
code { color: #c9d1ff; background: rgba(255, 255, 255, 0.06); padding: 2px 6px; border-radius: 8px; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(255,255,255,0.065), rgba(255,255,255,0.03));
  box-shadow: var(--shadow);
}

.login-brand { padding: 0 0 20px; border-bottom: 1px solid var(--border); }
.login-form { display: grid; gap: 14px; margin-top: 20px; }
.login-form label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; }
.login-form input[type="email"], .login-form input[type="password"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 0 13px;
  color: var(--text);
  background: rgba(255,255,255,0.045);
}
.check-row { display: flex !important; grid-template-columns: auto 1fr; align-items: center; }
.form-error { min-height: 20px; color: #ffb8c7; font-size: 13px; margin: 0; }

textarea,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 12px 13px;
  color: var(--text);
  background: rgba(255,255,255,0.045);
}

textarea {
  resize: vertical;
  min-height: 92px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--border);
  background: rgba(10, 15, 30, 0.74);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 6px 8px 18px;
}
.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 800;
  box-shadow: 0 12px 32px rgba(109,125,255,0.28);
}
.brand strong { display: block; font-size: 16px; }
.brand span { color: var(--muted); font-size: 12px; }

.nav { display: grid; gap: 8px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 15px;
  cursor: pointer;
  text-align: left;
  transition: 0.16s ease;
}
.nav-item span { width: 22px; text-align: center; color: #c7d0e9; }
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(109,125,255,0.24), rgba(48,213,200,0.09));
  border-color: rgba(109,125,255,0.3);
  color: var(--text);
}

.sidebar-card {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
}
.sidebar-card strong { display: block; font-size: 14px; }
.sidebar-card small { display: block; color: var(--muted); margin-top: 2px; }

.main {
  min-width: 0;
  padding: 26px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 750;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(28px, 4vw, 36px); line-height: 1.1; }
h2 { margin-bottom: 10px; font-size: clamp(22px, 3vw, 30px); line-height: 1.16; }
h3 { margin-bottom: 0; font-size: 18px; }
.muted { color: var(--muted); line-height: 1.55; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(780px, 58vw);
}
.search-box {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 220px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,0.045);
}
.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}
.search-box input::placeholder { color: #77839a; }
.refresh-button, .primary-action, .secondary-action, .icon-button, .filter-button, .primary-link {
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 11px 14px;
  color: var(--text);
  background: rgba(255,255,255,0.06);
  cursor: pointer;
  white-space: nowrap;
}
.icon-button { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; }
.primary-action, .primary-link {
  border-color: rgba(109,125,255,0.6);
  background: linear-gradient(135deg, var(--accent), #4958d7);
  box-shadow: 0 16px 40px rgba(109,125,255,0.24);
}
.secondary-action { background: rgba(255,255,255,0.06); }
.environment-pill {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  background: rgba(255,255,255,0.035);
}

.section { display: none; animation: fadeIn 0.16s ease; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0.3; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.hero-card, .panel-card, .kpi-card {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.025));
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.hero-card {
  padding: clamp(24px, 4vw, 38px);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  overflow: hidden;
  position: relative;
}
.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -80px -130px auto;
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(109,125,255,0.28), transparent 62%);
}
.hero-card p { max-width: 760px; color: var(--muted); line-height: 1.65; margin-bottom: 0; }
.hero-actions { display: flex; gap: 10px; z-index: 1; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}
.kpi-card { padding: 18px; box-shadow: none; }
.kpi-label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.kpi-card strong { display: block; font-size: 34px; letter-spacing: -0.04em; }
.kpi-card small { color: var(--muted); display: flex; align-items: center; gap: 7px; margin-top: 6px; }

.two-column { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 16px; }
.panel-card { padding: 22px; }
.large-card { min-height: 64vh; }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.card-header.split { align-items: center; }
.action-row, .filter-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.action-row.no-margin { margin-bottom: 0; }

.alert-list { display: grid; gap: 10px; }
.alert {
  display: grid;
  gap: 4px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
}
.alert span { color: var(--muted); font-size: 14px; }
.alert.warn, .alert.attention { border-color: rgba(249,199,79,0.28); }
.alert.problem { border-color: rgba(239,71,111,0.32); }

.quick-grid, .project-grid, .server-grid, .finance-layout, .settings-grid {
  display: grid;
  gap: 12px;
}
.quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quick-grid a, .quick-tile {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: rgba(255,255,255,0.045);
  color: #dde5f7;
  transition: 0.16s ease;
}
.quick-grid a:hover, .project-card:hover, .server-card:hover, .quick-tile:hover {
  transform: translateY(-1px);
  border-color: rgba(109,125,255,0.35);
}

.project-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.project-card {
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255,255,255,0.045);
  transition: 0.16s ease;
}
.project-card header { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 8px; }
.project-card strong { font-size: 16px; }
.project-card p { color: var(--muted); font-size: 13px; line-height: 1.45; min-height: 38px; }
.project-links { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.project-links a, .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.055);
  color: #dce5f8;
  font-size: 12px;
}
.project-links a[href=""] { display: none; }
.badge.ok, .badge.live { color: #aff3ce; border-color: rgba(46,212,122,0.3); }
.badge.warn, .badge.attention, .badge.warning { color: #ffe49c; border-color: rgba(249,199,79,0.3); }
.badge.bad, .badge.problem, .badge.error { color: #ffb8c7; border-color: rgba(239,71,111,0.3); }
.badge.neutral, .badge.dev, .badge.paused { color: #c5cee0; }

.status-dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 50%;
  background: var(--neutral);
  box-shadow: 0 0 0 4px rgba(119,131,154,0.12);
}
.status-dot.ok, .status-dot.live { background: var(--ok); box-shadow: 0 0 0 4px rgba(46,212,122,0.12); }
.status-dot.warn, .status-dot.attention { background: var(--warn); box-shadow: 0 0 0 4px rgba(249,199,79,0.12); }
.status-dot.bad, .status-dot.problem { background: var(--bad); box-shadow: 0 0 0 4px rgba(239,71,111,0.12); }
.status-dot.neutral, .status-dot.dev, .status-dot.paused { background: var(--neutral); }

.finance-layout { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.settings-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.finance-card, .server-card, .mail-row, .domain-row {
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
}
.finance-card span { color: var(--muted); font-size: 13px; }
.finance-card strong { display: block; margin: 8px 0 4px; font-size: 22px; overflow-wrap: anywhere; }
.finance-card small, .server-card small, .mail-row small { color: var(--muted); }
.mail-list, .domain-list { display: grid; gap: 10px; }
.mail-row, .domain-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.mail-row strong { margin-right: auto; }
.server-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.server-card { display: grid; gap: 8px; }
.domain-row span { color: var(--muted); }
.domain-links { display: flex; flex-wrap: wrap; gap: 7px; justify-content: flex-end; }
.empty-state {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed rgba(255,255,255,0.16);
  border-radius: 20px;
}
.filter-button.active { border-color: rgba(109,125,255,0.45); color: var(--text); background: rgba(109,125,255,0.16); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 7, 18, 0.76);
  backdrop-filter: blur(10px);
}

.modal-panel {
  width: min(860px, 100%);
  max-height: min(860px, calc(100vh - 40px));
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(21,31,56,0.98), rgba(12,18,34,0.98));
  box-shadow: var(--shadow);
}

.project-form {
  display: grid;
  gap: 14px;
}

.project-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.project-form input {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 0 13px;
  color: var(--text);
  background: rgba(255,255,255,0.045);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.kpi-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 0;
}

.stats-grid,
.mail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.stats-card p {
  min-height: auto;
}

.mail-card {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255,255,255,0.045);
}

.mail-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.mail-card header strong,
.mail-card header small {
  display: block;
}

.mail-card header small {
  color: var(--muted);
  margin-top: 3px;
}

.mail-count {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.mail-error {
  margin: 12px 0 0;
  color: #ffb8c7;
  font-size: 13px;
  line-height: 1.45;
}

.mail-subjects {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.mail-subjects div {
  padding-top: 9px;
  border-top: 1px solid var(--border);
}

.mail-subjects span,
.mail-subjects small {
  display: block;
}

.mail-subjects span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-subjects small {
  margin-top: 3px;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .server-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .topbar { align-items: stretch; flex-direction: column; }
  .topbar-actions { min-width: 0; flex-wrap: wrap; }
  .kpi-grid, .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-grid.compact, .stats-grid, .mail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column, .finance-layout, .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .main { padding: 16px; }
  .sidebar { padding: 16px; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-card { align-items: stretch; flex-direction: column; }
  .hero-actions, .topbar-actions { flex-direction: column; align-items: stretch; }
  .action-row.no-margin { align-items: stretch; flex-direction: column; width: 100%; }
  .kpi-grid, .kpi-grid.compact, .project-grid, .quick-grid, .server-grid, .stats-grid, .mail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .mail-row, .domain-row { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
