/* ════════════════════════════════════════════════════════════════
   Интеграл — main.css
   Dark glassmorphism theme
   FILE 16
   ════════════════════════════════════════════════════════════════ */

/* ─── CSS variables ──────────────────────────────────────────────────────────── */
:root {
  --bg:          #0f1117;
  --bg-2:        #161b27;
  --bg-3:        #1d2333;
  --card:        rgba(255, 255, 255, 0.04);
  --card-border: rgba(255, 255, 255, 0.09);
  --text:        #e2e8f0;
  --text-2:      #94a3b8;
  --text-3:      #64748b;
  --accent:      #4f8ef7;
  --accent-2:    #3b7de8;
  --accent-glow: rgba(79, 142, 247, 0.25);
  --success:     #00d4aa;
  --warning:     #f7c44f;
  --danger:      #ff6b6b;
  --orange:      #f7a044;
  --purple:      #a78bfa;
  --radius:      .75rem;
  --radius-sm:   .4rem;
  --shadow:      0 4px 24px rgba(0, 0, 0, .35);
  --shadow-lg:   0 12px 48px rgba(0, 0, 0, .5);
  --nav-width:   240px;
  --topbar-h:    56px;
  --transition:  .2s ease;
}

/* ─── Reset & base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

/* ─── Scrollbars ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar              { width: 6px; height: 6px; }
::-webkit-scrollbar-track        { background: transparent; }
::-webkit-scrollbar-thumb        { background: rgba(255,255,255,.12); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover  { background: rgba(255,255,255,.2); }

/* ─── Keyframes ──────────────────────────────────────────────────────────────── */
@keyframes fadeIn    { from { opacity: 0 } to { opacity: 1 } }
@keyframes fadeOut   { to   { opacity: 0 } }
@keyframes slideIn   { from { opacity: 0; transform: translateY(12px) } to { opacity: 1; transform: none } }
@keyframes toastIn   { from { opacity: 0; transform: translateX(1rem) } to { opacity: 1; transform: none } }
@keyframes toastOut  { to   { opacity: 0; transform: translateX(1rem) } }
@keyframes spin      { to   { transform: rotate(360deg) } }
@keyframes pulse     { 0%, 100% { opacity: 1 } 50% { opacity: .4 } }
@keyframes float     {
  0%, 100% { transform: translateY(0) }
  50%      { transform: translateY(-20px) }
}
@keyframes blink     {
  0%, 80%, 100% { transform: scale(0.8); opacity: .4 }
  40%           { transform: scale(1);   opacity: 1 }
}

/* ─── Glassmorphism card ─────────────────────────────────────────────────────── */
.glass-card {
  background:    var(--card);
  border:        1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem 1.1rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500; cursor: pointer;
  transition: background var(--transition), opacity var(--transition), box-shadow var(--transition);
  white-space: nowrap; line-height: 1.4;
}
.btn:disabled { opacity: .45; pointer-events: none; }

.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover { background: var(--accent-2); box-shadow: 0 0 16px var(--accent-glow); }

.btn-ghost {
  background: rgba(255,255,255,.06); color: var(--text-2); border-color: var(--card-border);
}
.btn-ghost:hover { background: rgba(255,255,255,.1); color: var(--text); }

.btn-danger {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger:hover { background: #e85a5a; }

.btn-full  { width: 100%; }
.btn-icon  { padding: .5rem; border-radius: var(--radius-sm); min-width: 2.25rem; }

/* ─── Forms ──────────────────────────────────────────────────────────────────── */
.form-group       { display: flex; flex-direction: column; gap: .35rem; }
.form-group-full  { grid-column: 1 / -1; }
.form-label       { font-size: .8rem; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.form-grid        { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.form-input, .form-select, .form-range {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .55rem .85rem;
  font-size: .875rem; width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-input::placeholder  { color: var(--text-3); }
.form-input:focus,
.form-select:focus        {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input.error         { border-color: var(--danger); }
textarea.form-input       { resize: vertical; }
select.form-select option { background: var(--bg-3); color: var(--text); }

.form-range {
  padding: 0; height: 6px;
  -webkit-appearance: none; appearance: none;
  cursor: pointer; background: rgba(255,255,255,.1);
}
.form-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 18px; height: 18px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow); cursor: pointer;
}

.form-error { color: var(--danger); font-size: .8rem; min-height: 1rem; }

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; padding: .2rem .6rem;
  border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .03em;
}
.badge-sm { font-size: .68rem; padding: .15rem .45rem; }

/* ─── App shell layout ───────────────────────────────────────────────────────── */
#integral-app { min-height: 100vh; width: 100%; }

#app-auth { width: 100%; }

.auth-mode body { overflow: hidden; }

#app-shell {
  display: flex;
  min-height: 100vh;
}

.app-nav {
  width: var(--nav-width);
  flex-shrink: 0;
  background: rgba(22, 27, 39, .96);
  border-right: 1px solid var(--card-border);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.app-main {
  flex: 1;
  margin-left: var(--nav-width);
  padding: 1.75rem 2rem;
  max-width: calc(100vw - var(--nav-width));
  overflow-x: hidden;
  min-height: 100vh;
}

/* ─── Nav components ─────────────────────────────────────────────────────────── */
.nav-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--card-border);
}

.nav-logo {
  display: flex; align-items: center; gap: .6rem;
}
.nav-logo-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 900; color: #fff;
  box-shadow: 0 4px 12px var(--accent-glow);
}
.nav-logo-text { font-size: 1.1rem; font-weight: 700; color: var(--text); }

.nav-links {
  flex: 1;
  overflow-y: auto;
  padding: .75rem .5rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

.nav-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .65rem .85rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: .875rem; font-weight: 500;
  transition: all var(--transition);
  position: relative;
  text-decoration: none;
}
.nav-link:hover  { background: rgba(255,255,255,.06); color: var(--text); text-decoration: none; }
.nav-link.active {
  background: rgba(79, 142, 247, .14);
  color: var(--accent);
}
.nav-link.active::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-icon  { font-size: 1.05rem; line-height: 1; }
.nav-label { flex: 1; }

.nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; border-radius: 999px;
  background: var(--danger); color: #fff;
  font-size: .68rem; font-weight: 700; padding: 0 .3rem;
}

.nav-footer {
  padding: .75rem .5rem 1rem;
  border-top: 1px solid var(--card-border);
  display: flex; align-items: center; gap: .5rem;
}
.nav-user { flex: 1; display: flex; align-items: center; gap: .6rem; min-width: 0; }
.nav-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.nav-user-info  { min-width: 0; }
.nav-user-name  { font-size: .8rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-user-role  { font-size: .7rem; color: var(--text-3); }
.nav-logout     { flex-shrink: 0; font-size: 1rem; }

/* ─── Mobile topbar & overlay ────────────────────────────────────────────────── */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(22,27,39,.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  z-index: 200;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

.nav-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,.5);
}

/* ─── Page header ────────────────────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap;
}
.page-title { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.page-sub   { color: var(--text-2); font-size: .9rem; margin-top: .25rem; }
.page-actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }

/* ─── Filter bar ─────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.25rem;
}
.filter-group { display: flex; gap: .35rem; flex-wrap: wrap; }

/* ─── Stats grid ─────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
  display: flex; align-items: center; gap: 1rem;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--text-2); margin-top: .2rem; }

/* ─── Dashboard grid ─────────────────────────────────────────────────────────── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}
.dashboard-section .section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .75rem;
}
.dashboard-section h3 { font-size: 1rem; font-weight: 600; color: var(--text); }
.section-link         { font-size: .8rem; color: var(--accent); }

.recent-list      { display: flex; flex-direction: column; gap: .6rem; }
.recent-item      { display: flex; align-items: flex-start; gap: .75rem; }
.recent-item.unread .recent-title { font-weight: 700; }
.recent-info      { flex: 1; min-width: 0; }
.recent-title     { font-size: .875rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-meta      { font-size: .75rem; color: var(--text-3); margin-top: .1rem; }
.recent-badge     { padding: .15rem .45rem; border-radius: var(--radius-sm); font-size: .7rem; font-weight: 700; flex-shrink: 0; }

/* ─── Auth page ──────────────────────────────────────────────────────────────── */
.auth-bg {
  min-height: 100vh; width: 100%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(79,142,247,.18) 0%, transparent 70%),
              radial-gradient(ellipse at 80% 80%, rgba(167,139,250,.12) 0%, transparent 60%),
              var(--bg);
  padding: 1rem; position: relative; overflow: hidden;
}

.auth-particles {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.auth-particle {
  position: absolute;
  border-radius: 50%;
  background: var(--accent);
  animation: float linear infinite;
  bottom: -10%;
}

.auth-card {
  width: 100%; max-width: 420px; position: relative; z-index: 10;
  animation: slideIn .35s ease;
  padding: 2rem 2rem 1.75rem;
}

.auth-logo {
  display: flex; align-items: center; gap: .8rem;
  margin-bottom: 1.75rem;
}
.auth-logo-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; font-weight: 900; color: #fff;
  box-shadow: 0 6px 20px var(--accent-glow);
}
.auth-logo-title { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.auth-logo-sub   { font-size: .75rem; color: var(--text-3); }

.auth-heading { font-size: 1.3rem; font-weight: 700; margin-bottom: .4rem; color: var(--text); }
.auth-desc    { font-size: .875rem; color: var(--text-2); margin-bottom: 1.25rem; }
.auth-step    { animation: fadeIn .25s ease; }

.auth-back {
  background: none; border: none; color: var(--text-2); font-size: .8rem;
  cursor: pointer; padding: 0 0 1rem; display: inline-block;
}
.auth-back:hover { color: var(--text); }

/* OTP grid */
.otp-grid {
  display: flex; gap: .6rem; justify-content: center;
  margin: 1rem 0;
}
.otp-cell {
  width: 48px; height: 56px;
  text-align: center; font-size: 1.4rem; font-weight: 700;
  background: rgba(255,255,255,.07); border: 2px solid var(--card-border);
  border-radius: .5rem; color: var(--text); outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  caret-color: var(--accent);
}
.otp-cell:focus  { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.otp-cell.filled { border-color: var(--accent); background: rgba(79,142,247,.1); }
.otp-cell.error  { border-color: var(--danger); animation: shake .3s ease; }

@keyframes shake {
  0%, 100% { transform: none }
  25% { transform: translateX(-4px) }
  75% { transform: translateX( 4px) }
}

.otp-timer {
  text-align: center; font-size: .8rem; color: var(--text-3);
  margin: .5rem 0;
}

/* ─── Schedule page ──────────────────────────────────────────────────────────── */
.schedule-controls {
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1rem;
}
.schedule-nav {
  display: flex; align-items: center; gap: .4rem; flex: 1;
}
.schedule-period   { font-weight: 600; color: var(--text); white-space: nowrap; }
.schedule-view-btns { display: flex; gap: .35rem; }
.schedule-legend {
  display: flex; flex-wrap: wrap; gap: .75rem;
  margin-bottom: 1rem;
}
.legend-item { display: flex; align-items: center; gap: .35rem; font-size: .78rem; color: var(--text-2); }
.legend-dot  { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Week grid */
.week-view { overflow-x: auto; }
.week-header {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  border-bottom: 1px solid var(--card-border);
  position: sticky; top: 0;
  background: rgba(15,17,23,.95);
  backdrop-filter: blur(8px);
  z-index: 2;
}
.week-day-header {
  padding: .5rem .25rem;
  text-align: center; border-left: 1px solid var(--card-border);
}
.week-day-header.today .week-day-num {
  background: var(--accent); color: #fff; border-radius: 50%; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center; margin: 0 auto;
}
.week-day-name { font-size: .7rem; color: var(--text-3); }
.week-day-num  { font-size: .9rem; font-weight: 600; color: var(--text); margin-top: .15rem; }

.week-body {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
}
.week-time-col { display: flex; flex-direction: column; }
.week-time-label {
  height: 60px; display: flex; align-items: flex-start; justify-content: flex-end;
  padding: 2px 6px 0 0;
  font-size: .65rem; color: var(--text-3);
}
.week-day-col  { border-left: 1px solid var(--card-border); }
.week-grid-cell {
  height: 60px; border-bottom: 1px solid rgba(255,255,255,.04);
}
.day-view .week-body { grid-template-columns: 56px 1fr; }

.sch-event:hover { filter: brightness(1.15); }

/* ─── Journal ────────────────────────────────────────────────────────────────── */
.table-wrap       { overflow-x: auto; }
.data-table       { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th    { padding: .5rem .75rem; text-align: left; color: var(--text-3); font-weight: 600; font-size: .75rem; text-transform: uppercase; border-bottom: 1px solid var(--card-border); white-space: nowrap; }
.data-table td    { padding: .5rem .75rem; border-bottom: 1px solid rgba(255,255,255,.04); color: var(--text); vertical-align: middle; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }

.grade-cell {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 2rem; height: 1.6rem; border-radius: var(--radius-sm);
  font-weight: 700; font-size: .875rem; padding: 0 .4rem;
}

.journal-table-wrap { max-height: calc(100vh - 280px); overflow: auto; }
.journal-table th,
.journal-table td   { white-space: nowrap; }
.journal-name-col   { min-width: 180px; position: sticky; left: 0; background: var(--bg-2); z-index: 1; }
.journal-date-col   { min-width: 70px; text-align: center; }
.journal-avg-col    { min-width: 90px; }

/* Grade picker */
.grade-picker { display: flex; gap: .4rem; margin: .5rem 0; }
.grade-pick-btn {
  width: 42px; height: 42px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.06); border: 2px solid var(--card-border);
  color: var(--text); font-size: 1.1rem; font-weight: 700; cursor: pointer;
  transition: all var(--transition);
}
.grade-pick-btn:hover { background: var(--gc, var(--accent))22; border-color: var(--gc, var(--accent)); color: var(--gc, var(--accent)); }
.grade-pick-btn.active { background: var(--gc, var(--accent))33; border-color: var(--gc, var(--accent)); color: var(--gc, var(--accent)); box-shadow: 0 0 10px var(--gc, var(--accent-glow))66; }

/* Subject averages */
.subject-averages { display: flex; flex-direction: column; gap: .6rem; }
.subject-avg-row  { display: flex; align-items: center; gap: .75rem; }
.subject-name     { min-width: 130px; font-size: .85rem; color: var(--text-2); }
.avg-bar-wrap     { flex: 1; height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; }
.avg-bar          { height: 100%; border-radius: 3px; transition: width .4s ease; }
.avg-value        { min-width: 36px; text-align: right; font-size: .85rem; font-weight: 700; }

/* ─── Events ─────────────────────────────────────────────────────────────────── */
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.event-card         { display: flex; flex-direction: column; gap: .65rem; cursor: pointer; transition: transform var(--transition), box-shadow var(--transition); }
.event-card:hover   { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.event-card-header  { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.event-card-title   { font-size: .975rem; font-weight: 600; color: var(--text); }
.event-card-desc    { font-size: .8rem; color: var(--text-2); flex: 1; }
.event-card-meta    { font-size: .75rem; color: var(--text-3); }
.event-card-footer  { margin-top: auto; }
.event-progress     { display: flex; align-items: center; gap: .5rem; }
.progress-bar-wrap  { flex: 1; height: 5px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; }
.progress-bar       { height: 100%; border-radius: 3px; transition: width .4s ease; }
.progress-label     { font-size: .7rem; color: var(--text-3); white-space: nowrap; }

.avatar-stack { display: flex; align-items: center; gap: -.25rem; }
.person-chip  { display: flex; align-items: center; gap: .4rem; background: rgba(255,255,255,.06); border: 1px solid var(--card-border); border-radius: 999px; padding: .2rem .5rem .2rem .2rem; font-size: .75rem; color: var(--text-2); }

/* Checklist */
.checklist         { display: flex; flex-direction: column; gap: .5rem; }
.checklist-item    { display: flex; align-items: center; gap: .6rem; cursor: pointer; font-size: .875rem; color: var(--text-2); }
.checklist-item.done .checklist-text { text-decoration: line-through; opacity: .55; }
.checklist-text    { flex: 1; }
.checklist-assignee { font-size: .7rem; color: var(--text-3); margin-left: auto; }

/* Detail grid */
.detail-grid   { display: flex; flex-direction: column; gap: .6rem; }
.detail-row    { display: flex; align-items: baseline; gap: .6rem; font-size: .875rem; }
.detail-icon   { width: 1.4rem; flex-shrink: 0; }
.detail-label  { color: var(--text-3); white-space: nowrap; }
.detail-value  { color: var(--text); }

/* ─── Notifications ──────────────────────────────────────────────────────────── */
.notif-list   { display: flex; flex-direction: column; gap: .6rem; }
.notif-item   {
  display: flex; align-items: stretch; gap: 0;
  transition: transform var(--transition), box-shadow var(--transition);
  padding: 0; overflow: hidden; cursor: pointer;
}
.notif-item:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.notif-item.unread { background: rgba(79,142,247,.06); }
.notif-importance-bar { width: 4px; flex-shrink: 0; }
.notif-content { flex: 1; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .35rem; }
.notif-header  { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.notif-title   { font-size: .925rem; font-weight: 600; color: var(--text); }
.notif-time    { font-size: .75rem; color: var(--text-3); white-space: nowrap; }
.notif-body    { font-size: .85rem; color: var(--text-2); line-height: 1.6; }
.notif-sender  { font-size: .75rem; color: var(--text-3); }

.unread-count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff;
  min-width: 22px; height: 22px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; padding: 0 .35rem;
  margin-left: .5rem; vertical-align: middle;
}

/* ─── Chat ───────────────────────────────────────────────────────────────────── */
.chat-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: calc(100vh - 3.5rem);
  gap: 1rem;
}

.chat-sidebar {
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem; border-bottom: 1px solid var(--card-border);
}
.chat-sidebar-header h2 { font-size: 1rem; font-weight: 700; }
.chat-search { padding: .6rem .75rem; border-bottom: 1px solid var(--card-border); }

.conv-list { flex: 1; overflow-y: auto; }
.conv-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .75rem; cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.conv-item:hover   { background: rgba(255,255,255,.05); }
.conv-item.active  { background: rgba(79,142,247,.1); }
.conv-info         { flex: 1; min-width: 0; }
.conv-header       { display: flex; align-items: center; justify-content: space-between; gap: .4rem; }
.conv-name         { font-size: .875rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time         { font-size: .7rem; color: var(--text-3); white-space: nowrap; flex-shrink: 0; }
.conv-preview      { display: flex; align-items: center; justify-content: space-between; gap: .4rem; margin-top: .1rem; }
.conv-last-msg     { font-size: .78rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-badge        { background: var(--accent); color: #fff; border-radius: 999px; min-width: 18px; height: 18px; font-size: .65rem; font-weight: 700; display: flex; align-items: center; justify-content: center; padding: 0 .3rem; flex-shrink: 0; }

.chat-main    { display: flex; flex-direction: column; overflow: hidden; }
.chat-thread  {
  flex: 1; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); overflow: hidden;
}
.chat-thread-header {
  display: flex; align-items: center; gap: .65rem;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--card-border);
  background: rgba(255,255,255,.02);
}
.chat-messages    { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }

.msg-date-sep {
  display: flex; align-items: center; gap: .5rem; margin: .5rem 0;
}
.msg-date-sep span {
  background: rgba(255,255,255,.06); border-radius: 999px;
  padding: .15rem .75rem; font-size: .72rem; color: var(--text-3);
}
.msg-date-sep::before, .msg-date-sep::after {
  content: ''; flex: 1; height: 1px; background: var(--card-border);
}

.msg-row         { display: flex; align-items: flex-end; gap: .5rem; }
.msg-mine        { flex-direction: row-reverse; }
.msg-bubble      { max-width: 70%; padding: .6rem .85rem; border-radius: 1rem; font-size: .875rem; line-height: 1.5; }
.bubble-mine     { background: rgba(79,142,247,.25); border-bottom-right-radius: .25rem; }
.bubble-theirs   { background: rgba(255,255,255,.07); border-bottom-left-radius: .25rem; }
.msg-sender-name { font-size: .7rem; font-weight: 700; color: var(--accent); margin-bottom: .15rem; }
.msg-text        { color: var(--text); word-break: break-word; }
.msg-time        { font-size: .65rem; color: var(--text-3); margin-top: .25rem; text-align: right; }
.msg-img         { max-width: 200px; max-height: 200px; border-radius: .5rem; object-fit: cover; cursor: pointer; }
.msg-file        { display: flex; align-items: center; gap: .4rem; color: var(--accent); font-size: .8rem; margin-top: .25rem; }

.typing-indicator {
  display: flex; align-items: center; gap: .3rem;
  padding: .5rem 1rem; color: var(--text-3); font-size: .75rem;
}
.typing-indicator span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--text-3);
  animation: blink 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }

.chat-input-area {
  display: flex; align-items: flex-end; gap: .5rem;
  padding: .75rem;
  border-top: 1px solid var(--card-border);
  background: rgba(255,255,255,.02);
}
.chat-input-wrap { flex: 1; display: flex; flex-direction: column; gap: .35rem; }
.chat-input {
  resize: none; min-height: 38px; max-height: 120px;
  background: rgba(255,255,255,.06); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); color: var(--text); font-size: .875rem;
  padding: .5rem .75rem; outline: none; font-family: inherit;
  transition: border-color var(--transition);
  overflow-y: auto;
}
.chat-input:focus { border-color: var(--accent); }

#filePreviewBar { display: flex; flex-wrap: wrap; gap: .3rem; }
.file-preview-chip {
  display: flex; align-items: center; gap: .3rem;
  background: rgba(79,142,247,.12); border: 1px solid rgba(79,142,247,.3);
  border-radius: var(--radius-sm); padding: .15rem .5rem; font-size: .75rem; color: var(--accent);
}
.remove-file { background: none; border: none; color: var(--text-3); cursor: pointer; font-size: .75rem; }

.user-search-row:hover { background: rgba(79,142,247,.08); }

/* ─── Surveys ────────────────────────────────────────────────────────────────── */
.surveys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.survey-card         { display: flex; flex-direction: column; gap: .65rem; }
.survey-card-header  { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.survey-card-title   { font-size: .975rem; font-weight: 600; color: var(--text); }
.survey-card-desc    { font-size: .8rem; color: var(--text-2); flex: 1; }
.survey-card-meta    { display: flex; gap: 1rem; font-size: .75rem; color: var(--text-3); }

.survey-page         { max-width: 720px; margin: 0 auto; }
.survey-header       { margin-bottom: 1.5rem; }
.survey-progress-bar-wrap { height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; margin-top: .75rem; overflow: hidden; }
.survey-progress-bar      { height: 100%; background: var(--accent); border-radius: 3px; transition: width .3s ease; }
.survey-questions    { display: flex; flex-direction: column; gap: 1rem; }
.survey-question     { animation: fadeIn .2s ease; }
.q-num      { font-size: .7rem; font-weight: 700; text-transform: uppercase; color: var(--text-3); margin-bottom: .25rem; }
.q-text     { font-size: .975rem; font-weight: 600; color: var(--text); margin-bottom: .75rem; }
.q-required { font-size: .7rem; color: var(--danger); margin-bottom: .5rem; display: block; }
.q-input-wrap { }

.survey-option {
  display: flex; align-items: center; gap: .65rem;
  padding: .5rem .75rem; border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  cursor: pointer; margin-bottom: .35rem;
  transition: background var(--transition), border-color var(--transition);
}
.survey-option:hover       { background: rgba(255,255,255,.05); }
.survey-option:has(input:checked) { background: rgba(79,142,247,.1); border-color: var(--accent); }
.option-text { font-size: .875rem; color: var(--text); }

.scale-input-wrap {
  display: flex; align-items: center; gap: .75rem;
}
.range-val { min-width: 2rem; text-align: center; font-weight: 700; color: var(--accent); }

.star-rating { display: flex; gap: .25rem; }
.star {
  font-size: 1.75rem; cursor: pointer; color: rgba(255,255,255,.2);
  transition: color var(--transition), transform var(--transition);
}
.star.filled, .star.hover { color: var(--warning); transform: scale(1.1); }

.survey-complete {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 1rem; padding: 4rem 2rem; text-align: center;
}
.survey-complete-icon { font-size: 4rem; animation: pulse 1.5s ease 2; }
.survey-complete h2   { font-size: 1.5rem; font-weight: 700; }
.survey-complete p    { color: var(--text-2); }

.survey-result-row {
  padding: .6rem 0; border-bottom: 1px solid var(--card-border);
}
.survey-result-row:last-child { border-bottom: none; }

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay { animation: fadeIn .2s ease; }
.modal-box     { animation: slideIn .25s ease; }

/* ─── Spinner ────────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive — tablet ────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .chat-layout { grid-template-columns: 260px 1fr; }
  .form-grid   { grid-template-columns: 1fr; }
  .form-group-full { grid-column: 1; }
}

/* ─── Responsive — mobile ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --nav-width: 280px; }

  .mobile-topbar { display: flex; }

  .app-nav {
    transform: translateX(-100%);
    transition: transform .25s ease;
    top: 0;
  }
  #app-shell.nav-open .app-nav      { transform: none; }
  #app-shell.nav-open .nav-overlay  { display: block; }

  .app-main {
    margin-left: 0;
    max-width: 100vw;
    padding: calc(var(--topbar-h) + 1rem) 1rem 1rem;
  }

  .page-header { flex-direction: column; gap: .5rem; }
  .stats-grid  { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }

  .chat-layout { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h) - 2rem); }
  .hidden-mobile { display: none !important; }

  .week-header { grid-template-columns: 40px repeat(7, 1fr); }
  .week-body   { grid-template-columns: 40px repeat(7, 1fr); }
  .week-time-label { padding: 2px 3px 0 0; font-size: .58rem; }
  .week-day-name   { font-size: .6rem; }
  .week-day-num    { font-size: .75rem; }

  .otp-grid { gap: .35rem; }
  .otp-cell { width: 40px; height: 48px; font-size: 1.2rem; }

  .events-grid, .surveys-grid { grid-template-columns: 1fr; }
  .msg-bubble { max-width: 85%; }

  .week-view { min-width: 600px; }
  .schedule-calendar { overflow-x: auto; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card  { padding: 1.5rem 1.25rem; }
}
