/* Telegram-like panel — high contrast shell */
:root {
  --bg-sidebar: #0a1017;
  --bg-main: #1c2733;
  --bg-card: #131c26;
  --bg-card-2: #182230;
  --bg-hover: #243140;
  --bg-active: #2b5278;
  --bg-input: #0f1720;
  --text: #e8eef4;
  --text-secondary: #8b9bb0;
  --text-dim: #5f738a;
  --blue: #5ca0e6;
  --blue-btn: #2f6fad;
  --blue-btn-hover: #3d82c4;
  --link: #6ab3f3;
  --ok: #4fae4e;
  --warn: #d4a017;
  --bad: #e53935;
  --sep: rgba(255,255,255,.08);
  --sep-strong: rgba(255,255,255,.14);
  --radius: 12px;
  --sidebar-w: 268px;
  --content-max: 780px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg-main);
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
code, .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  color: #9ec9f5;
}

.app {
  display: flex;
  min-height: 100vh;
  background: var(--bg-main);
}

/* LEFT — almost black, clearly separated */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid #000;
  box-shadow: 2px 0 0 rgba(0,0,0,.25);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-head {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--sep);
  background: #070b10;
}
.brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
}
.brand span { color: var(--blue); font-weight: 600; }
.user-chip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #121a24;
  border: 1px solid var(--sep);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.3;
}
.user-chip b {
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  word-break: break-all;
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px 18px;
}
.nav-group {
  margin: 16px 8px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.nav-group:first-child { margin-top: 4px; }
.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #d7e0ea;
  text-decoration: none;
  margin-bottom: 2px;
}
.nav a .nav-title { font-size: 14px; font-weight: 500; line-height: 1.2; }
.nav a:hover {
  background: #151d28;
  text-decoration: none;
}
.nav a.active {
  background: var(--bg-active);
  color: #fff;
}
.nav-badge {
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: #c9564b;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}
.nav a.active .nav-badge { background: rgba(255,255,255,.25); }
.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--sep);
  background: #070b10;
}

/* RIGHT — lighter workspace */
.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 56px;
  display: flex;
  justify-content: center;
  background:
    linear-gradient(180deg, #223041 0%, var(--bg-main) 120px);
}
.main-inner {
  width: 100%;
  max-width: var(--content-max);
}

.page-head { margin-bottom: 16px; }
.page-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.02em;
}
.page-sub {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13.5px;
  max-width: 54ch;
}
.crumb {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--link);
  font-size: 13px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--sep-strong);
  border-radius: var(--radius);
  padding: 16px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 0 rgba(0,0,0,.2);
}
.card > h3, .card-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
}
.card-hint {
  color: var(--text-secondary);
  font-size: 12.5px;
  margin: -2px 0 12px;
}
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.user-meta { color: var(--text-secondary); font-size: 12.5px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--sep-strong);
  border-radius: 10px;
  padding: 12px 14px;
}
.stat .k { color: var(--text-secondary); font-size: 12px; margin-bottom: 4px; }
.stat .v { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }

/* Action tiles on home */
.tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 4px;
}
.tile {
  display: block;
  background: var(--bg-card);
  border: 1px solid var(--sep-strong);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  color: inherit;
  text-decoration: none;
  transition: border-color .12s, background .12s;
}
.tile:hover {
  background: var(--bg-card-2);
  border-color: rgba(92,160,230,.45);
  text-decoration: none;
}
.tile .tile-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 6px;
}
.tile .tile-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}
.tile .tile-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.35;
}
.tile .tile-go {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--link);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: var(--blue-btn);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--blue-btn-hover); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary {
  background: #243140;
  color: var(--text);
  border: 1px solid var(--sep-strong);
}
.btn.secondary:hover { background: #2c3b4d; color: var(--text); }
.btn.danger { background: #b33b32; }
.btn.danger:hover { background: #d14a40; }
.btn.success { background: #2f8f46; }
.btn.success:hover { background: #37a352; }
.btn.ghost {
  background: transparent;
  color: var(--link);
  min-height: 32px;
  padding: 0 8px;
}
.btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; }

label.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 600;
}
input[type=text],
input[type=password],
input[type=number],
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--sep-strong);
  background: var(--bg-input);
  border-radius: 9px;
  padding: 9px 12px;
  color: var(--text);
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #5a6d80; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(92,160,230,.18);
}

.list {
  border: 1px solid var(--sep-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  margin-bottom: 12px;
}
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--sep);
  color: inherit;
  text-decoration: none;
}
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--bg-hover); text-decoration: none; }
.list-item .title { font-size: 14px; font-weight: 600; }
.list-item .sub { margin-top: 2px; font-size: 12.5px; color: var(--text-secondary); }
.list-item .grow { flex: 1; min-width: 0; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}
.status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-dim); flex-shrink: 0;
}
.status.ok { color: #7dd87a; }
.status.ok .dot { background: var(--ok); }
.status.warn { color: #e0b84a; }
.status.warn .dot { background: var(--warn); }
.status.bad { color: #ff8a80; }
.status.bad .dot { background: var(--bad); }
.status.mute { color: var(--text-secondary); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255,255,255,.08);
  color: var(--text-secondary);
}
.badge.ok { background: rgba(79,174,78,.18); color: #7dd87a; }
.badge.warn { background: rgba(212,160,23,.18); color: #e0b84a; }
.badge.bad { background: rgba(229,57,53,.18); color: #ff8a80; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 11px 10px;
  border-bottom: 1px solid var(--sep);
  vertical-align: middle;
  font-size: 13px;
}
.table th {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.table tr:last-child td { border-bottom: 0; }

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--sep);
}
.switch:last-child { border-bottom: 0; }
.switch .label { font-size: 14px; font-weight: 500; }

.alert {
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 13.5px;
  line-height: 1.4;
  border: 1px solid transparent;
}
.alert.info {
  background: #173049;
  border-color: rgba(92,160,230,.35);
  color: #c5ddf5;
}
.alert.warn {
  background: #3a2e12;
  border-color: rgba(212,160,23,.4);
  color: #f0d27a;
}
.alert.bad {
  background: #3a1816;
  border-color: rgba(229,57,53,.4);
  color: #ff9b93;
}
.alert a { color: inherit; font-weight: 700; text-decoration: underline; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}
.section-gap { margin-top: 16px; }
.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13.5px;
}
.worker-card {
  background: var(--bg-input);
  border: 1px solid var(--sep-strong);
  border-radius: 10px;
  padding: 12px 12px 12px;
}
.th-stack {
  line-height: 1.25;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #2b5278;
  color: #fff;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 32px));
  display: none;
  box-shadow: 0 10px 28px rgba(0,0,0,.4);
}
.toast.show { display: block; }
.toast.err { background: #b3261e; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0a1017;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #131c26;
  border: 1px solid var(--sep-strong);
  border-radius: 14px;
  padding: 28px 22px 22px;
  text-align: center;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 700; }
.login-card > p { color: var(--text-secondary); margin: 0 0 20px; font-size: 13.5px; }
.login-widget { display: flex; justify-content: center; min-height: 44px; }
.err-banner {
  background: #3a1816;
  border: 1px solid rgba(229,57,53,.4);
  color: #ff9b93;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  text-align: left;
}

@media (max-width: 900px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    box-shadow: none;
    border-right: 0;
    border-bottom: 1px solid #000;
  }
  .nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    overflow-x: auto;
    padding: 8px;
  }
  .nav-group { display: none; }
  .nav a { white-space: nowrap; flex-shrink: 0; max-width: 220px; }
  .nav a .nav-desc { display: none; }
  .main {
    padding: 18px 14px 36px;
    background: var(--bg-main);
  }
}
