:root {
  --bg: #f5f8fb;
  --card: #ffffff;
  --ink: #142233;
  --muted: #697789;
  --line: #dbe4ee;
  --primary: #0b7285;
  --primary-dark: #075866;
  --accent: #19a974;
  --danger: #c92a2a;
  --warn: #d9480f;
  --shadow: 0 18px 45px rgba(20, 34, 51, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(25, 169, 116, .10), transparent 34rem),
    linear-gradient(180deg, #f9fbfd 0%, var(--bg) 100%);
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }
.auth-page { display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 34px;
}
.auth-card.wide { width: min(760px, 100%); }
.auth-logo { display: block; width: 126px; margin: 0 auto 18px; }
.auth-card h1 { margin: 0 0 8px; text-align: center; font-size: 28px; }
.auth-card p { color: var(--muted); text-align: center; }
.app-shell { display: grid; grid-template-columns: 270px 1fr; min-height: 100vh; transition: grid-template-columns .2s ease; }
.app-shell.sidebar-collapsed { grid-template-columns: 92px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  background: #0f2433;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow: hidden;
}
.brand-row { min-height: 92px; display: flex; align-items: center; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 700; min-width: 0; }
.brand img { width: 92px; background: #fff; border-radius: 6px; padding: 6px; }
.brand span { line-height: 1.3; }
.app-shell.sidebar-collapsed .brand { justify-content: center; }
.app-shell.sidebar-collapsed .brand img { width: 54px; }
.app-shell.sidebar-collapsed .brand span,
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .sidebar-footer small { display: none; }
.nav { display: grid; gap: 8px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,.78);
  padding: 12px 14px;
  border-radius: 7px;
  min-height: 46px;
}
.nav a.active, .nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  color: #7ce3cf;
}
.nav-icon svg,
.sidebar-toggle svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}
.app-shell.sidebar-collapsed .nav a,
.app-shell.sidebar-collapsed .sidebar-footer a { justify-content: center; padding-inline: 10px; }
.sidebar-footer { margin-top: auto; display: grid; gap: 8px; color: rgba(255,255,255,.72); }
.sidebar-footer a { color: #fff; display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 7px; }
.sidebar-footer a:hover { background: rgba(255,255,255,.12); }
.main { padding: 24px; overflow: hidden; }
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 22px;
}
.topbar h1 { margin: 0; font-size: 28px; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  flex: 0 0 42px;
}
.stats-grid, .quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.quick-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-card, .quick-card, .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.stat-card { padding: 22px; }
.stat-card span { display: block; color: var(--muted); margin-bottom: 10px; }
.stat-card strong { font-size: 34px; }
.quick-card { padding: 20px; font-weight: 700; color: var(--ink); }
.card { padding: 22px; margin-bottom: 18px; }
.card.narrow { max-width: 920px; }
.grid-layout { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 18px; align-items: start; }
.grid-layout.even { grid-template-columns: 1fr 1fr; }
.section-head { display: flex; gap: 14px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 19px; }
.hint, .muted, small { color: var(--muted); }
.center { text-align: center; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 7px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 94px; resize: vertical; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: #fff; border-color: var(--danger); background: var(--danger); }
.btn.small { min-height: 32px; padding: 6px 10px; font-size: 13px; }
.alert { padding: 12px 14px; border-radius: 7px; margin-bottom: 16px; border: 1px solid var(--line); background: #fff; }
.alert.success { border-color: rgba(25,169,116,.35); color: #087f5b; }
.alert.error { border-color: rgba(201,42,42,.35); color: var(--danger); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; }
td small { display: block; margin-top: 4px; }
code { font-family: Consolas, monospace; font-size: 12px; background: #edf7f8; color: #075866; padding: 3px 5px; border-radius: 5px; }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; background: #edf2f7; color: var(--muted); font-size: 12px; font-weight: 700; }
.badge.ok { background: #e6fcf5; color: #087f5b; }
.badge.warn { background: #fff4e6; color: var(--warn); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions form { margin: 0; }
.search, .filters { display: flex; gap: 10px; align-items: center; }
.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.segmented legend { color: var(--muted); font-weight: 700; }
.segmented label, .check { display: flex; align-items: center; gap: 8px; }
.segmented input, .check input { width: auto; min-height: auto; }
.dropzone {
  min-height: 150px;
  place-items: center;
  text-align: center;
  border: 1.5px dashed #9eb4c8;
  border-radius: 8px;
  background: #fbfdff;
  color: var(--muted);
}
.dropzone input { max-width: 420px; }
.progress-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdff;
}
.progress-panel div { display: flex; justify-content: space-between; margin-bottom: 8px; }
progress { width: 100%; height: 14px; accent-color: var(--primary); }
.server-limits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}
.server-limits span {
  border: 1px solid var(--line);
  background: #f8fbfd;
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}
.event-list { display: grid; gap: 10px; max-height: 440px; overflow: auto; }
.event-item { border-bottom: 1px solid var(--line); padding-bottom: 10px; display: grid; gap: 3px; }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-shell.sidebar-collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: 280px; transform: translateX(-105%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .app-shell.sidebar-collapsed .brand span,
  .app-shell.sidebar-collapsed .nav-label,
  .app-shell.sidebar-collapsed .sidebar-footer small { display: inline; }
  .app-shell.sidebar-collapsed .brand img { width: 92px; }
  .app-shell.sidebar-collapsed .nav a,
  .app-shell.sidebar-collapsed .sidebar-footer a { justify-content: flex-start; padding: 12px 14px; }
  .grid-layout, .grid-layout.even, .stats-grid, .quick-grid, .form-grid.two, .segmented { grid-template-columns: 1fr; }
  .main { padding: 18px; }
  .topbar { align-items: flex-start; justify-content: flex-start; }
}

@media (max-width: 560px) {
  .auth-card, .card { padding: 18px; }
  .section-head, .search, .filters { align-items: stretch; flex-direction: column; }
  .topbar h1 { font-size: 23px; }
}
