:root {
  --bg: #071428;
  --row: #0f2744;
  --green: #0f4d3a;
  --red: #8a6b00;
  --fg: #f7f4ea;
  --muted: #9eb0c8;
  --btn: #16355a;
  --btn2: #1c3f68;
  --accent: #f5c518;
  --danger: #e8b006;
  --online: #f5c518;
  --navy: #00205b;
  --card: rgba(8, 24, 48, 0.92);
  --line: rgba(245, 197, 24, 0.16);
  --font: "Outfit", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
}

.layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background:
    linear-gradient(180deg, rgba(245, 197, 24, 0.12) 0%, transparent 42%),
    linear-gradient(165deg, #0a1c38 0%, #06101f 100%);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.sidebar::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 180%;
  height: 140px;
  background: radial-gradient(ellipse at 20% 0%, rgba(245, 197, 24, 0.22), transparent 60%);
  pointer-events: none;
}

.sidebar-head {
  position: relative;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}
.online-pulse {
  position: absolute;
  right: 0;
  top: 2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
  box-shadow: 0 0 0 0 rgba(245, 197, 24, 0.55);
  animation: pulse-dot 1.8s ease-out infinite;
}
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(245, 197, 24, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(245, 197, 24, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 197, 24, 0); }
}
.online-title {
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--online);
  margin-bottom: 12px;
}
.me-line {
  display: flex;
  align-items: center;
  gap: 10px;
}
.me-avatar,
.online-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  background: linear-gradient(145deg, #1a3a6a, #0c2244);
  border: 1px solid rgba(245, 197, 24, 0.45);
  color: var(--accent);
  flex-shrink: 0;
}
.me-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.me-name { font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.online-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.online-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 10px;
  font-size: 0.9rem;
}
.online-item:hover { background: rgba(255, 255, 255, 0.04); }
.online-item.is-me {
  background: rgba(245, 197, 24, 0.1);
  border: 1px solid rgba(245, 197, 24, 0.28);
}
.online-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(245, 197, 24, 0.55);
}
.online-avatar {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
  border-radius: 8px;
  background: #132c4e;
  border-color: var(--line);
}
.online-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.badge {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--accent);
  color: #071428;
  padding: 2px 6px;
  border-radius: 999px;
}
.you {
  font-size: 0.62rem;
  color: var(--online);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.muted { color: var(--muted); font-size: 0.85rem; padding: 8px; }

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.sidebar-actions .btn {
  text-align: center;
  text-decoration: none;
  display: block;
  border-radius: 10px;
}

.app { max-width: 720px; margin: 0 auto; padding: 12px 10px 28px; flex: 1; width: 100%; }

.auth-page {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  overflow: hidden;
  font-family: var(--font);
}
.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(245, 197, 24, 0.28), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(0, 32, 91, 0.55), transparent 50%),
    linear-gradient(160deg, #04101f 0%, #0a1c38 45%, #061428 100%);
  z-index: 0;
}
.auth-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  opacity: 0.5;
  animation: grid-drift 22s linear infinite;
}
@keyframes grid-drift {
  from { transform: translateY(0); }
  to { transform: translateY(48px); }
}
.auth-card,
.auth-card-modern {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 36px 28px 28px;
  backdrop-filter: blur(16px);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: card-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.auth-brand {
  font-weight: 800;
  font-size: clamp(2rem, 6vw, 2.45rem);
  letter-spacing: -0.03em;
  text-align: center;
  line-height: 1.05;
  background: linear-gradient(180deg, #fff8d6 20%, #f5c518 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0 0 6px;
}
.auth-tagline {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 22px;
}
.auth-error {
  background: rgba(245, 197, 24, 0.12);
  border: 1px solid rgba(245, 197, 24, 0.4);
  color: #ffe082;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 14px;
  text-align: center;
}
.auth-form { display: flex; flex-direction: column; gap: 2px; }
.auth-page .field span {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.auth-page .field input {
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  padding: 12px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.auth-page .field input:focus {
  outline: none;
  border-color: rgba(245, 197, 24, 0.65);
  box-shadow: 0 0 0 3px rgba(245, 197, 24, 0.18);
}
.auth-submit {
  width: 100%;
  padding: 13px;
  margin-top: 12px;
  font-size: 1rem;
  border-radius: 12px;
}

.admin-app { max-width: 980px; }
.admin-card {
  background: var(--row);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
}
.admin-card h2 { margin: 0 0 12px; font-size: 1.1rem; }
.admin-table-wrap { overflow-x: auto; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid #3a3a3a;
  vertical-align: middle;
}
.admin-table th { color: var(--muted); font-weight: 600; }
.admin-table code {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: #ffe082;
}
.admin-row-actions { white-space: nowrap; }
.admin-row-actions .btn { display: inline-block; margin: 2px; }
.reset-form {
  display: flex;
  gap: 4px;
  align-items: center;
  margin: 0;
}
.reset-form input {
  width: 110px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #555;
  background: #111;
  color: var(--fg);
  font-size: 0.8rem;
}

.header { text-align: center; margin-bottom: 8px; }
.sys-clock { font-weight: 700; font-size: 1.05rem; margin-bottom: 10px; font-family: var(--mono); }

.tabs { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.tab {
  border: 0;
  background: var(--btn);
  color: var(--fg);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 10px 18px;
  cursor: pointer;
  border-radius: 8px;
  font-family: var(--font);
}
.tab.active { background: var(--accent); color: #071428; }

.panel { display: none; }
.panel.active { display: block; }

h1 { text-align: center; font-size: 1.5rem; margin: 14px 0 4px; font-weight: 800; }
.hint { text-align: center; color: var(--muted); font-size: 0.82rem; margin: 0 0 12px; }
.api-status { text-align: center; font-size: 0.85rem; margin: 0 0 10px; min-height: 1.2em; color: #ffe082; }
.api-status.err { color: #ffcc80; font-weight: 700; }
.api-status.ok { color: #ffe082; }

.list { display: flex; flex-direction: column; gap: 8px; }

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  background: var(--row);
  padding: 12px 14px;
  border-radius: 10px;
}
.row.green { background: var(--green); }
.row.red { background: var(--red); }
.row.idle { background: var(--row); }

.row-main { min-width: 0; }
.row-top { display: flex; align-items: baseline; gap: 12px; }
.ch { font-weight: 700; font-size: 1rem; width: 2.5rem; flex-shrink: 0; }
.by {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #071428;
  background: var(--accent);
  border-radius: 999px;
  padding: 2px 7px;
  max-width: 7.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  align-self: center;
}
.timer { font-weight: 700; font-size: 1.55rem; letter-spacing: 0.02em; font-family: var(--mono); }
.detail { margin-top: 4px; font-size: 0.82rem; color: var(--muted); }
.row.green .detail { color: #b8e6d4; }
.row.red .detail { color: #ffe9a8; }

.row-actions { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }

.btn {
  border: 0;
  border-radius: 8px;
  color: var(--fg);
  font-weight: 700;
  cursor: pointer;
  padding: 8px 10px;
  font-size: 0.85rem;
  background: var(--btn);
  font-family: var(--font);
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-muted { background: var(--btn2); }
.btn-danger { background: var(--danger); color: #071428; }
.btn-sm { padding: 6px 10px; font-size: 0.8rem; background: var(--btn2); }

.footer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
}
.footer-actions .btn { padding: 12px 10px; font-size: 0.95rem; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal.hidden { display: none; }
.modal-card {
  background: #222;
  border-radius: 12px;
  padding: 18px;
  width: min(360px, 100%);
  border: 1px solid var(--line);
}
.modal-card h2 { margin: 0 0 6px; font-size: 1.1rem; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; font-size: 0.9rem; }
.field input {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #555;
  background: #111;
  color: var(--fg);
  font-size: 1rem;
  font-family: var(--font);
}
.preview { color: #ffe082; font-weight: 700; min-height: 1.2em; margin: 0 0 10px; }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .btn { flex: 1; }

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 260px;
  }
  .online-list { max-height: 110px; }
  .sidebar-actions { flex-direction: row; }
  .sidebar-actions .btn { flex: 1; }
}

@media (max-width: 520px) {
  .row { grid-template-columns: 1fr; }
  .row-actions { flex-direction: row; flex-wrap: wrap; }
  .row-actions .btn { flex: 1; min-width: 100px; }
  .footer-actions { grid-template-columns: 1fr; }
}
