/* MONOLITH cabinet/admin/auth — shared styles */
@import url('style.css');

:root {
  --bg-app: #050608;
  --bg-panel: rgba(14, 18, 24, 0.7);
  --bg-panel-strong: rgba(20, 26, 34, 0.92);
  --bg-input: rgba(255, 255, 255, 0.04);
  --border-soft: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --cyan: hsl(190, 100%, 50%);
  --cyan-soft: hsla(190, 100%, 50%, 0.15);
  --cyan-dim: hsla(190, 100%, 50%, 0.6);
  --text-primary: #f0f4f8;
  --text-secondary: #a4b0bc;
  --text-muted: #6b7886;
  --danger: #ff5263;
  --warn: #ffb547;
  --success: #58e0a8;
}

body.app {
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: 'Outfit', 'Inter', system-ui, sans-serif;
  min-height: 100vh;
  margin: 0;
  letter-spacing: 0.01em;
}
body.app::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 12% 8%, hsla(190, 100%, 50%, 0.06), transparent 45%),
    radial-gradient(circle at 92% 88%, hsla(190, 100%, 50%, 0.04), transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ─────── AUTH ─────── */
.auth-wrap {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
}
.auth-card {
  width: 100%;
  max-width: 480px;
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 2.5rem 2.25rem;
  backdrop-filter: blur(12px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.auth-logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem;
  letter-spacing: 0.4em;
  color: var(--cyan);
  text-align: center;
  margin-bottom: 0.4rem;
}
.auth-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 2.25rem;
}
.auth-tabs {
  display: flex;
  border-radius: 10px;
  background: var(--bg-input);
  padding: 4px;
  margin-bottom: 2rem;
}
.auth-tab {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  cursor: pointer;
  transition: all 0.18s ease;
}
.auth-tab.active {
  background: var(--cyan);
  color: #021016;
  font-weight: 700;
}
.auth-field { margin-bottom: 1.1rem; }
.auth-field label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.auth-field input,
.auth-field select,
.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 0.85rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.18s ease, background 0.18s ease;
  box-sizing: border-box;
}
.auth-field input:focus,
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--cyan);
  background: rgba(255, 255, 255, 0.06);
}
.auth-action {
  width: 100%;
  padding: 1rem;
  margin-top: 0.6rem;
  background: var(--cyan);
  color: #021016;
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 0.18s ease, transform 0.1s ease;
}
.auth-action:hover { filter: brightness(1.1); }
.auth-action:active { transform: scale(0.985); }
.auth-action.ghost {
  background: transparent;
  color: var(--cyan);
  border: 1px solid var(--border-strong);
}
.auth-msg {
  font-size: 0.82rem;
  color: var(--danger);
  margin-top: 0.8rem;
  min-height: 1.1rem;
}
.auth-msg.ok { color: var(--success); }
.auth-foot {
  text-align: center;
  margin-top: 1.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.auth-foot a { color: var(--cyan-dim); text-decoration: none; }
.auth-foot a:hover { color: var(--cyan); }

/* ─────── APP LAYOUT ─────── */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}
.side {
  background: rgba(8, 11, 16, 0.85);
  border-right: 1px solid var(--border-soft);
  padding: 2rem 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.side-logo {
  display: block;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.55rem;
  letter-spacing: 0.36em;
  color: var(--cyan);
  padding: 0 1.5rem;
  margin-bottom: 0.2rem;
  text-decoration: none;
  transition: opacity 0.15s ease;
}
.side-logo:hover { opacity: 0.8; }
.side-role {
  padding: 0 1.5rem;
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 1rem;
}
.side-home {
  display: inline-block;
  margin: 0 1.5rem 1.5rem;
  padding: 0.45rem 0.8rem;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--cyan);
  background: var(--cyan-soft);
  border: 1px solid var(--cyan-dim);
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
  align-self: flex-start;
}
.side-home:hover {
  background: var(--cyan);
  color: #000;
}
.side-nav { flex: 1; }
.side-nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.78rem 1.5rem;
  color: var(--text-secondary);
  font-size: 0.86rem;
  letter-spacing: 0.04em;
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.side-nav a:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}
.side-nav a.active {
  color: var(--cyan);
  border-left-color: var(--cyan);
  background: var(--cyan-soft);
}
.side-nav .nav-ic {
  display: inline-block;
  width: 14px;
  text-align: center;
  color: var(--cyan-dim);
}
.side-foot {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.75rem;
  color: var(--text-muted);
}
.side-foot .side-logout {
  display: inline-block;
  margin-top: 0.4rem;
  color: var(--cyan-dim);
  cursor: pointer;
  text-decoration: none;
}
.side-foot .side-logout:hover { color: var(--cyan); }

.main {
  padding: 2rem 2.5rem 4rem;
  min-width: 0;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.page-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.4rem;
  letter-spacing: 0.12em;
  color: var(--text-primary);
  margin: 0;
}
.page-sub {
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0.2rem 0 0;
}
.head-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; }

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 1.5rem 1.6rem;
  backdrop-filter: blur(10px);
  margin-bottom: 1.4rem;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.1rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.panel-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.18em;
  margin: 0;
}
.panel-tag {
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cyan-dim);
  margin-bottom: 0.35rem;
  display: block;
}

/* kpis */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.kpi {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 1.2rem 1.3rem;
}
.kpi-label {
  font-size: 0.68rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.kpi-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2rem;
  letter-spacing: 0.04em;
  color: var(--cyan);
  margin-top: 0.4rem;
  line-height: 1;
}
.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.45rem;
}
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.good .kpi-value { color: var(--success); }

/* ref link */
.ref-link {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  background: var(--bg-input);
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-family: ui-monospace, 'SF Mono', monospace;
  font-size: 0.88rem;
  color: var(--cyan);
  word-break: break-all;
}
.ref-link button {
  background: transparent;
  border: 1px solid var(--cyan);
  color: var(--cyan);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-family: inherit;
  cursor: pointer;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  white-space: nowrap;
}
.ref-link button:hover { background: var(--cyan-soft); }
.ref-link .copy-ok { color: var(--success); border-color: var(--success); }

/* level grid */
.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
}
.level-card {
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 1.1rem 1.15rem;
  position: relative;
  transition: border-color 0.2s, transform 0.15s;
}
.level-card:hover { transform: translateY(-2px); }
.level-card.active { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan-soft) inset; }
.level-card.locked { opacity: 0.45; }
.level-num {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  color: var(--cyan-dim);
  letter-spacing: 0.3em;
}
.level-card.active .level-num { color: var(--cyan); }
.level-name {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.16em;
  margin: 0.2rem 0 0.5rem;
}
.level-pct {
  color: var(--cyan);
  font-weight: 700;
  font-size: 1.1rem;
}
.level-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
  display: flex;
  justify-content: space-between;
}
.level-status {
  position: absolute;
  top: 0.7rem;
  right: 0.8rem;
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.level-status.on { background: var(--cyan-soft); color: var(--cyan); }
.level-status.off { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); }

/* tables */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.tbl thead th {
  text-align: left;
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border-soft);
  font-weight: 500;
}
.tbl tbody td {
  padding: 0.85rem 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  vertical-align: middle;
}
.tbl tbody tr:hover td { background: rgba(255, 255, 255, 0.02); color: var(--text-primary); }
.tbl tbody td strong { color: var(--text-primary); }
.tbl .num { font-variant-numeric: tabular-nums; }
.tbl .center { text-align: center; }
.tbl .right { text-align: right; }
.tbl-empty {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  padding: 3px 9px;
  font-size: 0.65rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border-radius: 4px;
  font-weight: 600;
}
.badge.ok      { background: rgba(88, 224, 168, 0.13); color: var(--success); }
.badge.pending { background: rgba(255, 181, 71, 0.13); color: var(--warn); }
.badge.bad     { background: rgba(255, 82, 99, 0.13);  color: var(--danger); }
.badge.muted   { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); }
.badge.cyan    { background: var(--cyan-soft); color: var(--cyan); }

.app-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.05rem;
  background: var(--cyan);
  color: #021016;
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.15s ease;
}
.app-btn:hover { filter: brightness(1.1); }
.app-btn.ghost {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}
.app-btn.ghost:hover { border-color: var(--cyan); color: var(--cyan); }
.app-btn.sm { padding: 0.4rem 0.75rem; font-size: 0.68rem; letter-spacing: 0.16em; }
.app-btn.danger { background: var(--danger); color: #fff; }

.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.4rem; }
.split-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* tree */
.tree {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tree li {
  border-left: 1px dashed rgba(255, 255, 255, 0.08);
  margin-left: 0.4rem;
  padding-left: 1rem;
  padding-top: 0.4rem;
}
.tree-node {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.7rem;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 0.84rem;
}
.tree-node .tn-name { color: var(--text-primary); font-weight: 500; }
.tree-node .tn-code { color: var(--cyan-dim); font-family: ui-monospace, monospace; font-size: 0.78rem; }
.tree-node .tn-vol { color: var(--text-muted); margin-left: auto; font-variant-numeric: tabular-nums; }

/* modal */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
}
.modal-back.on { display: flex; }
.modal {
  width: 100%;
  max-width: 480px;
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 1.8rem;
}
.modal h3 {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.16em;
  margin: 0 0 1rem;
  font-size: 1.3rem;
}
.modal .modal-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
  margin-top: 1.2rem;
}

/* form rows */
.field { margin-bottom: 0.9rem; }
.field label {
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }

.toolbar {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.toolbar input,
.toolbar select {
  padding: 0.55rem 0.8rem;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: 7px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
}
.toolbar input:focus, .toolbar select:focus {
  outline: none;
  border-color: var(--cyan);
}
.toolbar .grow { flex: 1; min-width: 240px; }

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--bg-panel-strong);
  border: 1px solid var(--cyan);
  color: var(--text-primary);
  padding: 0.85rem 1.2rem;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 200;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.18s, transform 0.18s;
}
.toast.on { opacity: 1; transform: translateY(0); }
.toast.bad { border-color: var(--danger); }
.toast.ok  { border-color: var(--success); }

.progress {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.6rem;
}
.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--cyan-dim), var(--cyan));
}

/* mobile nav toggle */
.side-mob-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 50;
  background: var(--bg-panel-strong);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  color: var(--cyan);
  cursor: pointer;
  font-size: 1.3rem;
}

@media (max-width: 1080px) {
  .split { grid-template-columns: 1fr; }
  .split-3 { grid-template-columns: 1fr; }
  .main { padding: 2rem 1.5rem 3rem; }
}
@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .side {
    position: fixed;
    top: 0; left: 0;
    width: 80%;
    max-width: 280px;
    height: 100vh;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  .side.open { transform: translateX(0); }
  .side-mob-toggle { display: block; }
  .main { padding: 4rem 1.2rem 3rem; }
  .page-title { font-size: 1.8rem; }
  .field-row { grid-template-columns: 1fr; }
  /* tables: let panels scroll horizontally on small screens */
  .panel { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 480px; }
  /* page-head — give some breathing room */
  .page-head { margin-bottom: 1.4rem; }
  .head-actions .app-btn { font-size: 0.7rem; padding: 0.55rem 0.85rem; }
}
@media (max-width: 480px) {
  .auth-card { padding: 1.8rem 1.4rem; }
  .panel { padding: 1.1rem; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
  .kpi { padding: 1rem 0.9rem; }
  .kpi-value { font-size: 1.4rem; }
  .kpi-label { font-size: 0.62rem; }
  .page-title { font-size: 1.5rem; }
  .page-sub { font-size: 0.72rem; }
  .main { padding: 4rem 0.9rem 3rem; }
  .side-home { margin: 0 1.2rem 1.2rem; font-size: 0.74rem; }
  .side-logo { font-size: 1.35rem; letter-spacing: 0.3em; }
  .auth-logo { font-size: 1.7rem; letter-spacing: 0.3em; }
  .auth-sub { font-size: 0.7rem; letter-spacing: 0.18em; margin-bottom: 1.6rem; }
  .auth-tab { font-size: 0.7rem; letter-spacing: 0.1em; padding: 0.65rem 0.6rem; }
  /* prevent iOS Safari auto-zoom on focus: inputs need >= 16px */
  .auth-field input,
  .auth-field select,
  .field input,
  .field textarea,
  .field select { font-size: 16px; }
}

/* Telegram in-app webview: kill backdrop-filter (causes flicker on scroll) */
@media (pointer: coarse) {
  .auth-card,
  .panel,
  .side {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
  .auth-card { background: rgba(20, 26, 34, 0.98); }
  .side { background: rgba(8, 10, 14, 0.98); }
}
