/* ─────────────────────────────────────────────
   RUZ – Design System
   Dark minimalist devtool UI
───────────────────────────────────────────── */

:root {
  --bg:              #1a2026;
  --bg-elevated:     #1f262d;
  --surface:         #242c34;
  --surface-hover:   #2b343d;
  --surface-active:  #323c46;

  --border:          #38434f;
  --border-subtle:   #28323b;

  --text-primary:    #e6ebf0;
  --text-secondary:  #8a96a3;
  --text-muted:      #4d5867;

  --accent:          #5b8def;
  --accent-hover:    #7aa3f5;
  --accent-subtle:   rgba(91, 141, 239, 0.12);
  --accent-border:   rgba(91, 141, 239, 0.28);

  --green:           #22c55e;
  --green-subtle:    rgba(34, 197, 94, 0.10);
  --red:             #ef4444;
  --red-subtle:      rgba(239, 68, 68, 0.10);
  --red-border:      rgba(239, 68, 68, 0.22);

  --radius-xs:  4px;
  --radius-sm:  6px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  --header-h:  52px;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;

  --shadow-soft:     0 18px 40px rgba(5, 12, 20, 0.22);
  --theme-toggle-bg: rgba(255, 255, 255, 0.04);
  --theme-toggle-fg: var(--text-secondary);
  --theme-toggle-border: var(--border);
  --theme-toggle-hover-bg: var(--surface-hover);
  --theme-toggle-hover-fg: var(--text-primary);
  --theme-toggle-active-bg: var(--accent-subtle);
  --theme-toggle-active-fg: var(--accent-hover);
  --theme-toggle-active-border: var(--accent-border);
}

html[data-theme="light"] {
  color-scheme: light;

  --bg:              #f3f6fb;
  --bg-elevated:     #ffffff;
  --surface:         #ffffff;
  --surface-hover:   #eef3fb;
  --surface-active:  #e5edf9;

  --border:          #d8e0ec;
  --border-subtle:   #e7edf5;

  --text-primary:    #18212b;
  --text-secondary:  #566575;
  --text-muted:      #7d8a98;

  --accent:          #3569d4;
  --accent-hover:    #2a5cc2;
  --accent-subtle:   rgba(53, 105, 212, 0.10);
  --accent-border:   rgba(53, 105, 212, 0.24);

  --green:           #15803d;
  --green-subtle:    rgba(21, 128, 61, 0.10);
  --red:             #dc2626;
  --red-subtle:      rgba(220, 38, 38, 0.08);
  --red-border:      rgba(220, 38, 38, 0.18);

  --shadow-soft:     0 18px 40px rgba(74, 89, 107, 0.12);
  --theme-toggle-bg: rgba(255, 255, 255, 0.74);
  --theme-toggle-fg: var(--text-secondary);
  --theme-toggle-border: rgba(83, 101, 122, 0.18);
  --theme-toggle-hover-bg: #f4f7fc;
  --theme-toggle-hover-fg: var(--text-primary);
  --theme-toggle-active-bg: rgba(53, 105, 212, 0.12);
  --theme-toggle-active-fg: var(--accent);
  --theme-toggle-active-border: rgba(53, 105, 212, 0.18);
}

/* ─── Reset ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { border: none; cursor: pointer; font-family: inherit; background: none; }

body {
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background 0.2s ease, color 0.2s ease;
}

/* ─── App Shell ──────────────────────────── */
.app-shell {
  min-height: 100dvh;
}

/* ─── Bottom Nav ─────────────────────────── */
.mobile-bottomnav {
  display: block;
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  z-index: 500;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}

.bottomnav-list {
  display: flex;
  width: 100%;
  justify-content: space-around;
}

.bottomnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}

.bottomnav-item svg {
  width: 20px;
  height: 20px;
}

.bottomnav-item.is-active {
  color: var(--accent-hover);
}

.bottomnav-item:hover {
  color: var(--text-secondary);
}

.bottomnav-item:active,
.bottomnav-item:focus-visible {
  background: var(--surface-hover);
  border-color: var(--border);
  outline: none;
}

/* ─── Main Content ───────────────────────── */
.main-pane {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.page-header-inline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.page-heading-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.page-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  align-self: flex-start;
  margin-left: auto;
}

/* Page body */
.page-body {
  flex: 1;
  padding: 24px 28px calc(92px + env(safe-area-inset-bottom));
}

.page-body-inner {
  max-width: 960px;
  margin: 0 auto;
}

.guest-theme-bar {
  display: flex;
  justify-content: flex-end;
  width: min(960px, calc(100% - 32px));
  margin: 20px auto -6px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--theme-toggle-border);
  background: var(--theme-toggle-bg);
  color: var(--theme-toggle-fg);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  appearance: none;
}

.theme-toggle:hover {
  background: var(--theme-toggle-hover-bg);
  color: var(--theme-toggle-hover-fg);
  outline: none;
}

.theme-toggle:focus-visible {
  outline: none;
  border-color: var(--theme-toggle-border);
  box-shadow: var(--shadow-soft);
}

.theme-toggle:active {
  transform: translateY(1px);
  background: var(--theme-toggle-hover-bg);
  color: var(--theme-toggle-hover-fg);
  outline: none;
  box-shadow: var(--shadow-soft);
}

.theme-toggle:focus,
.theme-toggle:focus-within {
  outline: none;
  box-shadow: var(--shadow-soft);
}

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}

.theme-toggle-icon svg {
  width: 18px;
  height: 18px;
}

html[data-theme="dark"] .theme-toggle-icon-moon-filled,
html[data-theme="light"] .theme-toggle-icon-moon-outline {
  display: none;
}

html[data-theme="light"] .theme-toggle {
  color: var(--theme-toggle-fg);
}

/* ─── Cards ──────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-soft);
}

.card + .card,
.card + .card-section {
  margin: 10px;
}

.card-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.card-body {
  padding: 4px 20px;
}

/* ─── Data Rows ──────────────────────────── */
.data-list { display: flex; flex-direction: column; }

.data-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.data-row:last-child { border-bottom: none; }

.data-key {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.data-val {
  font-size: 12px;
  color: var(--text-primary);
  text-align: right;
  word-break: break-all;
}

.data-val.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.data-val.dim { color: var(--text-secondary); }

/* ─── Buttons ────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  cursor: pointer;
}

.btn-sm  { padding: 5px 12px; font-size: 12px; }
.btn-md  { padding: 7px 14px; font-size: 13px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-danger {
  background: var(--red-subtle);
  color: var(--red);
  border: 1px solid var(--red-border);
}
.btn-danger:hover {
  background: rgba(239, 68, 68, 0.16);
}

/* ─── Badges ─────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
}

.badge-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-ok {
  background: var(--green-subtle);
  color: var(--green);
}

.badge-error {
  background: var(--red-subtle);
  color: var(--red);
}

.badge-neutral {
  background: var(--surface-hover);
  color: var(--text-secondary);
}

/* ─── Status text ────────────────────────── */
.text-ok    { color: var(--green); }
.text-error { color: var(--red); }
.text-muted { color: var(--text-muted); font-size: 12px; }
.text-dim   { color: var(--text-secondary); }

/* ─── Schedule ───────────────────────────── */
.schedule-table-shell {
  position: relative;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--border-subtle);
  overflow: hidden;
}

.schedule-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: inherit;
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
  font-size: 12px;
}

.schedule-table th,
.schedule-table td {
  border: 1px solid var(--border-subtle);
  vertical-align: top;
  text-align: left;
}

.schedule-table thead th {
  background: var(--bg-elevated);
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

.schedule-table thead th:first-child {
  position: sticky;
  left: -1px;
  z-index: 3;
  text-align: center;
  box-shadow: 1px 0 0 var(--border-subtle);
}

.schedule-table tbody th {
  background: var(--bg-elevated);
  padding: 10px 12px;
  min-width: 90px;
  font-weight: 500;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  position: sticky;
  left: -1px;
  z-index: 2;
  text-align: center;
  box-shadow: 1px 0 0 var(--border-subtle);
}

.schedule-table thead th:not(:first-child) {
  text-align: center;
}

.schedule-table td {
  background: var(--surface);
  padding: 7px;
  min-width: 160px;
}

.schedule-empty-cell {
  width: 100%;
  height: 34px;
}

/* ─── Lesson Cards ───────────────────────── */
.lesson-card {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  border-left: 3px solid var(--border);
  background: var(--bg-elevated);
}

.lesson-card + .lesson-card { margin-top: 5px; }

.lesson-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.lesson-meta {
  font-size: 10px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.lesson-card--lecture      { border-left-color: #5b8def; background: rgba(91,141,239,0.08); }
.lesson-card--practice     { border-left-color: #10b981; background: rgba(16,185,129,0.07); }
.lesson-card--seminar      { border-left-color: #8b5cf6; background: rgba(139,92,246,0.07); }
.lesson-card--lab          { border-left-color: #f97316; background: rgba(249,115,22,0.07); }
.lesson-card--exam         { border-left-color: #ef4444; background: rgba(239,68,68,0.07); }
.lesson-card--credit       { border-left-color: #eab308; background: rgba(234,179,8,0.07); }
.lesson-card--graded-credit{ border-left-color: #d97706; background: rgba(217,119,6,0.07); }
.lesson-card--consultation { border-left-color: #ec4899; background: rgba(236,72,153,0.07); }
.lesson-card--internship   { border-left-color: #22c55e; background: rgba(34,197,94,0.07); }
.lesson-card--default      { border-left-color: var(--border); background: var(--bg-elevated); }

/* ─── Login Page ─────────────────────────── */
.login-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 16px;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: var(--shadow-soft);
}

.login-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-subtle);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
}

.login-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.login-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

#telegram-auth-status {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  min-height: 18px;
}

/* ─── Info Grid (homepage stat cards) ──────── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.info-tile-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 500;
}

.info-tile-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ─── Divider ────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 16px 0;
}

/* ─── Responsive ─────────────────────────── */
@media (max-width: 768px) {
  .page-header-inline {
    gap: 12px;
    margin-bottom: 16px;
  }

  .page-body {
    padding: 14px 14px calc(92px + env(safe-area-inset-bottom));
  }

  .guest-theme-bar {
    width: calc(100% - 28px);
    margin-top: 14px;
  }

  .theme-toggle {
    margin-left: auto;
  }
}

.schedule-wrap {
  padding-bottom: 0;
}

.schedule-scrollbar:not([hidden]) {
  display: block;
}
