/* ============================================================
   iTutor SL Operations Console — single stylesheet
   Brand: ink #131110 · orange #F2611B · warm white #F6F4F1
   ============================================================ */
:root {
  --ink: #131110;
  --ink-2: #2a2725;
  --ink-3: #4a4542;
  --orange: #F2611B;
  --orange-dark: #d24f10;
  --paper: #F6F4F1;
  --card: #ffffff;
  --line: #e7e2dc;
  --muted: #8a827b;
  --green: #1d9e5f;  --green-bg: #e3f5ec;
  --amber: #b97a08;  --amber-bg: #fdf1da;
  --red: #c73a3a;    --red-bg: #fbe7e7;
  --blue: #2467c4;   --blue-bg: #e5eefb;
  --grey: #6b6560;   --grey-bg: #efece8;
  --purple: #6B4FA0; --purple-bg: #eee9f7;
  --radius: 10px;
  --sidebar-w: 248px;
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
a { color: var(--orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main { padding: 22px 26px 60px; }

/* ---------- sidebar ---------- */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--ink); color: #d8d3cf;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; background: var(--orange);
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 700; color: #fff; }
.brand-sub { font-size: .75rem; color: #9b938c; }
.nav { flex: 1; padding: 6px 10px 20px; }
.nav-section {
  font-size: .66rem; letter-spacing: .12em; color: #7d756e;
  margin: 16px 8px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: #d8d3cf; font-size: .92rem;
}
.nav-item:hover { background: var(--ink-2); text-decoration: none; }
.nav-item.is-active { background: var(--ink-2); color: #fff; font-weight: 600; }
.nav-dot { width: 6px; height: 6px; border-radius: 50%; background: #565049; flex-shrink: 0; }
.nav-item.is-active .nav-dot { background: var(--orange); }
.nav-count {
  margin-left: auto; background: var(--orange); color: #fff;
  border-radius: 999px; font-size: .7rem; padding: 1px 7px; font-weight: 700;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-top: 1px solid var(--ink-2);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--orange);
  color: #fff; font-size: .8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-user-name { font-size: .85rem; color: #fff; }
.sidebar-user-role { font-size: .7rem; color: #9b938c; }
.logout { margin-left: auto; color: #9b938c; font-size: 1rem; }
.logout:hover { color: #fff; text-decoration: none; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 26px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-search { flex: 1; max-width: 420px; }
.topbar-search input {
  width: 100%; padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--paper); font-size: .9rem;
}
.topbar-month select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); font-weight: 600; font-size: .9rem;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: .88rem; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.96); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-orange { background: var(--orange); color: #fff; }
.btn-outline { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: .78rem; border-radius: 6px; }
button.link { background: none; border: 0; color: var(--orange-dark); cursor: pointer; padding: 0; font-size: inherit; }

/* ---------- cards / layout ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-title h1 { margin: 0; font-size: 1.35rem; }
.page-title p { margin: 2px 0 0; color: var(--muted); font-size: .88rem; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px;
}
.card h2 { margin: 0 0 12px; font-size: 1.02rem; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px)  { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat { padding: 14px 16px; }
.stat .stat-label { color: var(--muted); font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.stat .stat-value { font-size: 1.7rem; font-weight: 700; margin-top: 2px; }
.stat .stat-sub { color: var(--muted); font-size: .8rem; margin-top: 2px; }
.stat-up { color: var(--green); } .stat-down { color: var(--red); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th {
  text-align: left; padding: 9px 10px; color: var(--muted); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .06em; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:hover td { background: #faf8f5; }
.cell-strong { font-weight: 600; }
.cell-muted { color: var(--muted); font-size: .8rem; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; white-space: nowrap;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-grey { background: var(--grey-bg); color: var(--grey); }
.class-both { background: #fdeadd; color: var(--orange-dark); }
.class-theory { background: var(--grey-bg); color: var(--ink); }
.class-revision { background: var(--purple-bg); color: var(--purple); }

/* ---------- forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 18px; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; } }
.field label { display: block; font-size: .8rem; font-weight: 600; margin-bottom: 5px; color: var(--ink-3); }
.field .req { color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: .9rem; background: var(--card); font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(242, 97, 27, .35); border-color: var(--orange);
}
.field .hint { font-size: .75rem; color: var(--muted); margin-top: 4px; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; }
.field-error { color: var(--red); font-size: .78rem; margin-top: 4px; }

/* ---------- filters bar ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: .85rem;
}
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; font-size: .88rem; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { text-decoration: none; color: var(--ink); }
.tab.is-active { color: var(--orange-dark); border-bottom-color: var(--orange); }
.tab .tab-count { font-size: .72rem; background: var(--grey-bg); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }

/* ---------- flash / empty / misc ---------- */
.flash { margin: 14px 26px 0; padding: 11px 16px; border-radius: 8px; font-size: .88rem; font-weight: 600; }
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error { background: var(--red-bg); color: var(--red); }
.flash-info { background: var(--blue-bg); color: var(--blue); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.mono { font-family: Consolas, monospace; font-size: .85em; }
.pagination { display: flex; gap: 6px; margin-top: 14px; }
.pagination a, .pagination span {
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font-size: .82rem;
}
.pagination .current { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- modal ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(19, 17, 16, .55); z-index: 50;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  background: var(--card); border-radius: 12px; max-width: 520px; width: 100%;
  padding: 22px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 14px; }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--ink); padding: 20px;
}
.login-card {
  background: var(--card); border-radius: 14px; padding: 34px; width: 100%; max-width: 400px;
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-card h1 { font-size: 1.2rem; margin: 0; }

/* ---------- error page ---------- */
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--paper); }
.error-box { text-align: center; }
.error-code { font-size: 4rem; font-weight: 800; color: var(--orange); }

/* ---------- public registration form ---------- */
.reg-page { max-width: 720px; margin: 0 auto; padding: 18px 14px 80px; }
.reg-banner {
  background: var(--ink); color: #fff; border-radius: 14px; padding: 26px 24px; margin-bottom: 18px;
}
.reg-banner .accent { color: var(--orange); }
.reg-banner h1 { margin: 0 0 4px; font-size: 1.35rem; }
.reg-banner p { margin: 0; color: #b9b2ac; font-size: .9rem; }
.reg-step { border-left: 3px solid var(--orange); padding-left: 12px; margin: 22px 0 10px; font-weight: 700; }
.choice-row { display: flex; gap: 10px; flex-wrap: wrap; }
.choice {
  flex: 1; min-width: 140px; border: 2px solid var(--line); border-radius: 10px; padding: 14px;
  cursor: pointer; background: var(--card); text-align: center; font-weight: 600;
}
.choice input { display: none; }
.choice .price { display: block; color: var(--muted); font-weight: 500; font-size: .82rem; margin-top: 3px; }
.choice.is-selected { border-color: var(--orange); background: #fdeadd; }
.lookup-box { display: flex; gap: 10px; }
.lookup-box input { flex: 1; }
.autofill-note {
  background: var(--green-bg); color: var(--green); border-radius: 8px;
  padding: 10px 14px; font-size: .85rem; font-weight: 600; margin-top: 10px; display: none;
}
.autofill-note.is-visible { display: block; }

/* ---------- chat widget ---------- */
.chat-page { max-width: 480px; margin: 0 auto; height: 100vh; display: flex; flex-direction: column; background: var(--card); }
.chat-head { background: var(--ink); color: #fff; padding: 14px 18px; display: flex; gap: 10px; align-items: center; }
.chat-head .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; background: var(--paper); }
.chat-msg { max-width: 82%; padding: 9px 13px; border-radius: 12px; margin-bottom: 8px; font-size: .9rem; line-height: 1.35; }
.chat-msg.from-student { margin-left: auto; background: var(--orange); color: #fff; border-bottom-right-radius: 3px; }
.chat-msg.from-bot, .chat-msg.from-admin { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 3px; }
.chat-msg .who { font-size: .68rem; opacity: .7; margin-bottom: 2px; font-weight: 700; }
.chat-quick { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 16px; background: var(--paper); }
.chat-quick button {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 13px; font-size: .8rem; cursor: pointer; font-weight: 600;
}
.chat-input { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.chat-input input { flex: 1; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; }
.chat-input button { border: 0; background: var(--orange); color: #fff; border-radius: 999px; padding: 10px 18px; font-weight: 700; cursor: pointer; }

/* admin chat split view */
.chat-split { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .chat-split { grid-template-columns: 1fr; } }
.chat-list-item { display: block; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); margin-bottom: 8px; background: var(--card); }
.chat-list-item:hover { text-decoration: none; border-color: var(--orange); }
.chat-list-item.is-active { border-color: var(--orange); background: #fdeadd; }

/* movement chart bars */
.trend { display: flex; gap: 18px; align-items: flex-end; height: 120px; padding-top: 10px; }
.trend-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.trend-bars { display: flex; gap: 5px; align-items: flex-end; height: 90px; }
.trend-bar { width: 22px; border-radius: 4px 4px 0 0; min-height: 3px; }
.trend-bar.added { background: var(--green); }
.trend-bar.left { background: var(--red); }
.trend-label { font-size: .72rem; color: var(--muted); }

/* print manifest */
@media print {
  .sidebar, .topbar, .filters, .btn, .flash, .page-head .btn, .no-print { display: none !important; }
  .content { margin: 0; } .main { padding: 0; }
  .card { border: 0; }
}
