:root {
  --ink: #261f20;
  --muted: #756868;
  --paper: #f8f3ed;
  --surface: #fffdfa;
  --surface-soft: #f2e9e2;
  --line: #e6d8cf;
  --wine: #a40c12;
  --wine-dark: #79070b;
  --rose: #e5a099;
  --rose-soft: #f8e4e0;
  --green: #277255;
  --green-soft: #e4f3eb;
  --amber: #946514;
  --amber-soft: #fff0cf;
  --blue: #315d88;
  --blue-soft: #e5eef7;
  --danger: #a40c12;
  --shadow: 0 18px 55px rgba(74, 35, 30, .09);
  font-family: Inter, Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--wine); font-size: 11px; font-weight: 800; letter-spacing: .15em; }
h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; }
h1 { margin: 0; font-size: clamp(30px, 3vw, 44px); line-height: 1.05; }
h2 { margin: 0; font-size: 24px; }
h3 { margin: 0; font-size: 18px; }

/* Login */
.login-page {
  background:
    radial-gradient(circle at 82% 12%, rgba(229,160,153,.35), transparent 28%),
    linear-gradient(135deg, #2b2021 0 35%, var(--paper) 35% 100%);
}
.login-layout { min-height: 100vh; padding: 48px; display: grid; grid-template-columns: minmax(180px, .55fr) minmax(320px, 1fr); gap: 8vw; align-items: center; }
.login-brand, .sidebar-brand { font: 500 40px/1 Georgia, serif; text-decoration: none; color: white; letter-spacing: -.04em; }
.login-brand span, .sidebar-brand span { color: var(--rose); }
.login-card { max-width: 620px; width: 100%; padding: clamp(32px, 6vw, 72px); border: 1px solid var(--line); border-radius: 32px; background: rgba(255,253,250,.96); box-shadow: var(--shadow); }
.login-card h1 { font-size: clamp(42px, 6vw, 70px); }
.login-owner { margin: 12px 0 38px; color: var(--muted); font-size: 20px; }
.stack-form { display: grid; gap: 18px; }
label { display: grid; gap: 8px; color: #55494a; font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 11px 13px; border: 1px solid #cfc0b9; border-radius: 11px; outline: none; background: #fff; color: var(--ink); transition: .18s ease;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--wine); box-shadow: 0 0 0 3px rgba(164,12,18,.11); }
.form-error { margin: 0 0 20px; padding: 12px 14px; border-radius: 12px; color: var(--wine-dark); background: var(--rose-soft); }
.back-link { display: inline-block; margin-top: 24px; color: var(--muted); font-size: 13px; text-decoration: none; }

/* Application shell */
.dashboard-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); background: var(--paper); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 30px 20px 22px; display: flex; flex-direction: column; color: #f9eae6; background: linear-gradient(180deg, #2b2021, #211819); overflow-y: auto; z-index: 20; }
.sidebar-brand { margin: 0 12px 34px; font-size: 32px; }
.main-nav { display: grid; gap: 4px; }
.main-nav a { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 9px 12px; border-radius: 11px; color: #d6c4c1; font-size: 13px; text-decoration: none; transition: .17s ease; }
.main-nav a:hover { color: white; background: rgba(255,255,255,.07); }
.main-nav a.active { color: white; background: var(--wine); box-shadow: 0 8px 24px rgba(164,12,18,.24); }
.nav-icon { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.2); border-radius: 7px; font-size: 12px; }
.sidebar-footer { margin-top: auto; padding-top: 26px; display: grid; gap: 16px; }
.user-chip { display: flex; gap: 10px; align-items: center; }
.user-chip > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: #381f20; background: var(--rose); font-weight: 800; }
.user-chip div { display: grid; min-width: 0; }
.user-chip b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { margin-top: 3px; color: #ae9895; font-size: 10px; }
.logout-link { color: #c7afac; font-size: 12px; text-decoration: none; }
.workspace { min-width: 0; padding: 34px clamp(22px, 4vw, 64px); }
.workspace-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 88px; margin-bottom: 26px; }
.page-title-row { display: flex; align-items: center; gap: 12px; }
.section-guide-button { width: 34px; height: 34px; padding: 0; display: inline-grid; place-items: center; flex: 0 0 auto; border: 2px solid var(--wine); border-radius: 50%; color: var(--wine); background: var(--surface); box-shadow: 0 6px 18px rgba(164,12,18,.12); font: italic 700 20px/1 Georgia, serif; transition: .17s ease; }
.section-guide-button:hover { transform: translateY(-1px); color: white; background: var(--wine); box-shadow: 0 9px 24px rgba(164,12,18,.2); }
.section-guide-button:focus-visible { outline: 3px solid rgba(164,12,18,.22); outline-offset: 3px; }
.workspace-header .muted { margin: 8px 0 0; font-size: 13px; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.header-actions:empty { display: none; }
.mobile-menu { display: none !important; }
.sidebar-backdrop { display: none; }
.content { min-height: 58vh; }
.app-footer { margin: 28px 0 0; color: #a38f8b; font-size: 11px; }

/* Controls */
.button { min-height: 42px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-weight: 750; font-size: 13px; transition: .17s ease; }
.button:hover { transform: translateY(-1px); border-color: #c9b5ac; box-shadow: 0 8px 20px rgba(70,26,26,.08); }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.button.primary { border-color: var(--wine); color: white; background: var(--wine); }
.button.primary:hover { background: var(--wine-dark); }
.button.danger { color: var(--danger); border-color: #e4b8b4; background: #fff6f4; }
.button.small { min-height: 32px; padding: 6px 11px; font-size: 11px; }
.button.text { min-height: auto; padding: 0; border: 0; border-radius: 0; color: var(--wine); background: transparent; box-shadow: none; }
.wide-button { width: 100%; justify-content: center; }
.icon-button { width: 42px; height: 42px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: var(--surface); color: var(--ink); font-size: 20px; }
.segmented { display: inline-flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-soft); }
.segmented button { min-height: 32px; padding: 6px 12px; border: 0; border-radius: 999px; color: var(--muted); background: transparent; font-size: 11px; }
.segmented button.active { color: white; background: var(--wine); }
.filters { margin: 0 0 16px; padding: 14px; display: flex; align-items: end; gap: 12px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,253,250,.75); }
.filters label { min-width: 150px; flex: 1; }
.filters input, .filters select { min-height: 38px; padding: 8px 10px; }

/* Cards and tables */
.metrics-grid { margin-bottom: 20px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card, .panel, .empty-state, .loading-card { border: 1px solid var(--line); background: var(--surface); box-shadow: 0 10px 30px rgba(70,26,26,.055); }
.metric-card { min-height: 140px; padding: 20px; display: grid; align-content: space-between; gap: 8px; border-radius: 20px; border-top: 4px solid var(--rose); text-align: left; }
button.metric-card { width: 100%; color: inherit; cursor: pointer; }
.metric-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.metric-card.selected { outline: 3px solid rgba(109,145,182,.35); box-shadow: var(--shadow); }
.metric-card[hidden] { display: none; }
.metric-card.wine { border-top-color: var(--wine); }
.metric-card.green { border-top-color: #6e9d83; }
.metric-card.amber { border-top-color: #d0a24b; }
.metric-card.blue { border-top-color: #6d91b6; }
.metric-card span { color: var(--muted); font-size: 12px; }
.metric-card strong { font: 500 34px/1 Georgia, serif; color: var(--wine); }
.metric-card small { color: #a18e89; font-size: 10px; }
.period-toolbar { margin-bottom: 16px; display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.period-toolbar > strong { min-width: 170px; align-self: center; text-align: center; text-transform: capitalize; }
.period-toolbar label { display: grid; gap: 4px; color: var(--muted); font-size: 11px; }
.period-toolbar input { min-width: 220px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, .8fr); gap: 18px; }
.panel { padding: 20px; border-radius: 20px; overflow: hidden; }
.panel + .panel, .panel-stack .panel { margin-top: 16px; }
.panel-head { margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.panel-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 9px; border-bottom: 1px solid var(--line); color: #8b7773; font-size: 9px; font-weight: 850; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 9px; border-bottom: 1px solid #f0e5df; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fff8f4; }
.cell-main { display: grid; gap: 3px; min-width: 150px; }
.cell-main b { font-size: 12px; }
.cell-main small { color: var(--muted); font-size: 10px; }
.row-actions { display: flex; justify-content: flex-end; gap: 7px; white-space: nowrap; }
.schedule-feed { display: grid; gap: 8px; }
.schedule-feed-item { min-width: 0; padding: 14px; display: grid; grid-template-columns: 145px minmax(160px, 1fr) minmax(150px, .8fr) auto; align-items: center; gap: 16px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.schedule-feed-item time { font-size: 12px; font-weight: 750; white-space: nowrap; }
.schedule-feed-main { min-width: 0; display: grid; gap: 3px; }
.schedule-feed-main b, .schedule-feed-main span, .schedule-feed-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.schedule-feed-main b { font-size: 14px; }
.schedule-feed-main span { font-size: 12px; }
.schedule-feed-main small { color: var(--muted); font-size: 11px; }
.schedule-feed-status { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.schedule-feed-actions { min-width: 95px; align-self: center; }
.schedule-feed-actions summary { display: inline-flex; align-items: center; justify-content: center; list-style: none; white-space: nowrap; cursor: pointer; }
.schedule-feed-actions summary::-webkit-details-marker { display: none; }
.schedule-feed-actions > div { max-width: 220px; padding-top: 9px; display: grid; gap: 6px; }
.schedule-feed-actions:not([open]) > div { display: none; }
.schedule-feed-actions > div .button { width: 100%; text-align: center; }
.calendar-panel { margin-bottom: 16px; }
.calendar-toolbar, .calendar-navigation, .calendar-mode-switch, .calendar-filter-head, .calendar-teacher-list { display: flex; align-items: center; gap: 8px; }
.calendar-toolbar { justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.calendar-navigation { flex-wrap: wrap; }
.calendar-navigation h2 { margin-left: 8px; font-size: clamp(20px, 2.4vw, 28px); text-transform: capitalize; }
.calendar-mode-switch { padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.calendar-mode-switch button { padding: 8px 14px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; }
.calendar-mode-switch button[aria-pressed="true"] { background: var(--wine); color: white; }
.calendar-filter { margin: 18px 0 8px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.calendar-filter-head { margin-bottom: 10px; justify-content: space-between; flex-wrap: wrap; }
.calendar-filter-head b { font-size: 12px; }
.calendar-filter-head input { width: min(250px, 100%); min-height: 35px; padding: 7px 10px; font-size: 12px; }
.calendar-teacher-list { flex-wrap: wrap; }
.calendar-color-0 { --calendar-accent: #a40c12; --calendar-fill: #f2ddde; --calendar-outline: #e0acae; }
.calendar-color-1 { --calendar-accent: #315d88; --calendar-fill: #e2e8ee; --calendar-outline: #b9c8d7; }
.calendar-color-2 { --calendar-accent: #277255; --calendar-fill: #e1ebe7; --calendar-outline: #b6cfc5; }
.calendar-color-3 { --calendar-accent: #946514; --calendar-fill: #f0e9de; --calendar-outline: #dbcbaf; }
.calendar-color-4 { --calendar-accent: #674b9a; --calendar-fill: #eae6f1; --calendar-outline: #cbc2dd; }
.calendar-color-5 { --calendar-accent: #9a4a6b; --calendar-fill: #f1e6ea; --calendar-outline: #ddc1cd; }
.calendar-color-6 { --calendar-accent: #316e72; --calendar-fill: #e2ebeb; --calendar-outline: #b9cecf; }
.calendar-color-unassigned { --calendar-accent: #756868; --calendar-fill: #eceaea; --calendar-outline: #d0cccc; }
.calendar-teacher-chip { display: inline-flex; align-items: center; justify-content: flex-start; gap: 7px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--ink); font-size: 11px; font-weight: 700; text-align: left; white-space: nowrap; }
.calendar-teacher-chip.selected { border-color: var(--calendar-accent, var(--wine)); background: var(--calendar-fill, var(--rose-soft)); color: var(--calendar-accent, var(--wine-dark)); }
.calendar-color { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--calendar-accent); }
.calendar-count { margin: 10px 0 14px; color: var(--muted); font-size: 11px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; }
.calendar-count .button { margin-left: auto; }
.calendar-scroll { width: 100%; overflow-x: auto; }
.calendar-week-desktop .calendar-scroll { max-height: min(68vh, 740px); min-height: 420px; overflow: auto; overscroll-behavior: contain; border: 1px solid var(--line); border-radius: 14px; }
.calendar-week-grid { min-width: 770px; display: grid; grid-template-columns: 50px repeat(7, minmax(100px, 1fr)); grid-template-rows: 54px max-content; align-content: start; }
.calendar-time-corner, .calendar-week-day-head { min-height: 53px; padding: 10px; border-bottom: 1px solid var(--line); background: #faf5f0; }
.calendar-time-corner, .calendar-week-day-head { position: sticky; top: 0; z-index: 4; }
.calendar-week-day-head { border-left: 1px solid var(--line); display: grid; gap: 2px; text-align: center; }
.calendar-week-day-head b { font-size: 12px; text-transform: capitalize; }
.calendar-week-day-head small { color: var(--muted); font-size: 10px; }
.calendar-week-day-head.today { color: var(--wine); background: var(--rose-soft); }
.calendar-hour-labels { position: relative; background: #faf5f0; }
.calendar-hour-labels span { position: absolute; right: 6px; transform: translateY(-7px); color: var(--muted); font-size: 10px; }
.calendar-week-column { position: relative; border-left: 1px solid var(--line); background: repeating-linear-gradient(to bottom, #fffdfa 0, #fffdfa 63px, var(--line) 63px, var(--line) 64px); }
.calendar-week-slot { position: absolute; z-index: 1; left: 0; width: 100%; height: 64px; border: 0; background: transparent; color: var(--wine); text-align: right; }
.calendar-week-slot span { visibility: hidden; padding: 3px 7px; background: white; border-radius: 50%; }
.calendar-week-slot:hover, .calendar-week-slot:focus-visible { background: rgba(164,12,18,.06); }
.calendar-week-slot:hover span, .calendar-week-slot:focus-visible span { visibility: visible; }
.calendar-positioned { position: absolute; z-index: 2; padding: 2px; min-width: 0; }
.calendar-event { width: 100%; height: 100%; min-height: 28px; padding: 5px 7px; display: flex; flex-direction: column; gap: 2px; overflow: hidden; border: 1px solid var(--calendar-outline); border-left: 4px solid var(--calendar-accent); border-radius: 7px; background: var(--calendar-fill); color: var(--ink); text-align: left; }
.calendar-event:hover, .calendar-event:focus-visible { outline: 2px solid var(--calendar-accent); outline-offset: -2px; }
.calendar-event time { font-size: 10px; font-weight: 800; }
.calendar-event b { display: block; overflow: hidden; font-size: 11px; line-height: 1.2; text-overflow: ellipsis; }
.calendar-event small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; }
.calendar-event em { color: var(--amber); font-size: 9px; font-style: normal; font-weight: 800; }
.calendar-event.needs-review { border-left-color: var(--amber); background: var(--amber-soft); }
.calendar-event.cancelled { opacity: .55; text-decoration: line-through; }
.calendar-week-mobile { display: none; }
.calendar-month-grid { min-width: 770px; display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.calendar-month-weekday { padding: 9px 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #faf5f0; color: var(--muted); font-size: 11px; font-weight: 800; text-align: center; }
.calendar-month-cell { min-width: 0; min-height: 164px; padding: 7px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: white; }
.calendar-month-cell.outside { background: #faf8f6; color: var(--muted); }
.calendar-month-cell.today { background: #fff7f4; }
.calendar-month-cell-head { display: flex; align-items: center; gap: 4px; min-height: 27px; margin-bottom: 6px; }
.calendar-month-cell-head button { width: 24px; height: 24px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: inherit; font-size: 11px; font-weight: 800; cursor: pointer; }
.calendar-month-cell-head button:hover { background: var(--rose-soft); color: var(--wine); }
.calendar-month-cell.today .calendar-month-date { background: var(--wine); color: white; }
.calendar-month-day-count { padding: 2px 5px; border-radius: 999px; background: #f2ece8; color: var(--muted); font-size: 9px; font-weight: 800; line-height: 1; }
.calendar-month-cell-head .calendar-month-add { margin-left: auto; color: var(--muted); font-size: 17px; font-weight: 500; }
.calendar-month-date.mobile-date, .calendar-month-day-dots, .calendar-month-mobile-detail { display: none; }
.calendar-month-events { display: grid; align-content: start; gap: 4px; }
.calendar-month-event { width: 100%; min-width: 0; padding: 5px 6px; display: grid; gap: 2px; overflow: hidden; border: 1px solid var(--calendar-outline); border-left: 3px solid var(--calendar-accent); border-radius: 7px; background: var(--calendar-fill); color: var(--ink); text-align: left; cursor: pointer; }
.calendar-month-event:hover, .calendar-month-event:focus-visible { outline: 2px solid var(--calendar-accent); outline-offset: -2px; }
.calendar-month-event-main { min-width: 0; display: flex; align-items: baseline; gap: 4px; }
.calendar-month-event-main time { flex: 0 0 auto; color: var(--calendar-accent); font-size: 10px; font-weight: 800; }
.calendar-month-event-main b { min-width: 0; overflow: hidden; font-size: 10px; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }
.calendar-month-event-meta { overflow: hidden; color: var(--muted); font-size: 9px; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
.calendar-month-event-meta em { color: var(--amber); font-style: normal; font-weight: 800; }
.calendar-month-event.needs-review { border-style: dashed; }
.calendar-month-event.cancelled { opacity: .55; text-decoration: line-through; }
.calendar-more { width: 100%; padding: 3px 5px; border: 0; background: transparent; color: var(--wine); font-size: 10px; font-weight: 800; text-align: left; cursor: pointer; }
.calendar-lesson-detail p { font-size: 13px; }
.calendar-detail-actions { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; gap: 5px; min-height: 25px; padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; white-space: nowrap; }
.pill.success { color: var(--green); background: var(--green-soft); }
.pill.warning { color: var(--amber); background: var(--amber-soft); }
.pill.danger { color: var(--danger); background: var(--rose-soft); }
.pill.info { color: var(--blue); background: var(--blue-soft); }
.pill.neutral { color: var(--muted); background: #eee7e2; }
.issue-list { display: grid; gap: 10px; }
.issue-card { padding: 14px; display: grid; gap: 7px; border: 1px solid var(--line); border-left: 4px solid #d0a24b; border-radius: 13px; background: #fffdfa; }
.issue-card.critical { border-left-color: var(--wine); }
.issue-card.info { border-left-color: #6d91b6; }
.issue-card b { font-size: 12px; }
.issue-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.issue-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.entity-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.entity-card { min-height: 150px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 9px 26px rgba(70,26,26,.05); }
.entity-card h3 { margin-bottom: 6px; }
.entity-card p { margin: 5px 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.entity-card .card-footer { margin-top: 16px; padding-top: 12px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #f0e5df; }
.teacher-card-head { margin-bottom: 12px; padding-top: 12px; border-top: 1px solid #f0e5df; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.teacher-card-head h3 { margin: 0; }
.teacher-card-tools { display: inline-flex; align-items: center; gap: 8px; }
.contact-icon { width: 36px; height: 36px; padding: 0; display: inline-grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: var(--surface); text-decoration: none; transition: .17s ease; }
.contact-icon:hover { transform: translateY(-1px); border-color: #c9b5ac; background: #fff8f4; box-shadow: 0 8px 20px rgba(70,26,26,.08); }
.contact-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.teacher-card-actions { justify-content: flex-start !important; flex-wrap: wrap; gap: 8px; }
.checkbox-field { display: flex; grid-column: 1 / -1; align-items: center; gap: 10px; }
.checkbox-field input { width: 18px; min-height: 18px; }
.money { font-variant-numeric: tabular-nums; font-weight: 800; white-space: nowrap; }
.integration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.integration-card { padding: 17px; display: flex; gap: 13px; align-items: center; border: 1px solid var(--line); border-radius: 15px; background: #fff; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: #b6a7a3; box-shadow: 0 0 0 4px #eee7e2; }
.status-dot.connected, .status-dot.configured { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.status-dot.attention { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 0 4px var(--rose-soft); }
.status-dot.disabled, .status-dot.manual { background: #8b7773; box-shadow: 0 0 0 4px #eee7e2; }
.integration-card b { display: block; font-size: 12px; }
.integration-card small { color: var(--muted); font-size: 10px; }
.calendar-run-error { margin-top: 7px; color: var(--danger); font-size: 11px; }
.calendar-run-error summary { cursor: pointer; font-weight: 700; }
.calendar-run-error code { display: block; margin-top: 5px; overflow-wrap: anywhere; white-space: pre-wrap; }
.integration-card .calendar-run-error + .button { margin-top: 9px; }
.calendar-diagnostics { margin-top: 16px; padding: 13px 16px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.calendar-diagnostics summary { color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; }
.calendar-diagnostics p { margin: 11px 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.calendar-diagnostics > .button { margin: 2px 0 4px; }
.calendar-diagnostics .table-wrap { margin-top: 12px; }
.calendar-pending-more { margin-top: 14px; }
.calendar-pending-more summary { color: var(--wine); font-weight: 800; cursor: pointer; }
.calendar-pending-more .table-wrap { margin-top: 12px; }

/* States */
.empty-state, .loading-card { min-height: 260px; padding: 34px; border-radius: 20px; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--muted); text-align: center; }
.empty-state strong { color: var(--ink); font: 500 22px Georgia, serif; }
.empty-state p, .loading-card p { max-width: 430px; margin: 0; font-size: 12px; line-height: 1.55; }
.empty-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; color: var(--wine); background: var(--rose-soft); font: 500 22px Georgia, serif; }
.spinner { width: 26px; height: 26px; border: 3px solid var(--rose-soft); border-top-color: var(--wine); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { margin: 0 0 18px; padding: 13px 15px; border: 1px solid #e4b8b4; border-radius: 13px; color: var(--wine-dark); background: var(--rose-soft); font-size: 12px; }
.notice.success { color: var(--green); border-color: #b8dac9; background: var(--green-soft); }
.toast-stack { position: fixed; right: 22px; bottom: 22px; width: min(360px, calc(100vw - 44px)); display: grid; gap: 8px; z-index: 80; }
.toast { padding: 13px 15px; border-radius: 13px; color: white; background: #2b2021; box-shadow: 0 14px 35px rgba(0,0,0,.2); font-size: 12px; animation: rise .2s ease; }
.toast.error { background: var(--wine-dark); }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

/* Modal */
.modal { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 0; border-radius: 24px; background: transparent; }
.modal::backdrop { background: rgba(26,18,19,.62); backdrop-filter: blur(4px); }
.modal-card { max-height: calc(100vh - 28px); padding: 24px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: 0 30px 90px rgba(0,0,0,.24); overflow-y: auto; }
.modal-head { margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.modal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.modal-grid .full { grid-column: 1 / -1; }
.modal-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 9px; }
.choice-list { max-height: 250px; padding: 5px; display: grid; gap: 8px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.participant-row { padding: 10px; display: grid; grid-template-columns: auto 1fr 130px; align-items: center; gap: 10px; border-radius: 9px; background: #faf5f0; }
.participant-row input[type=checkbox] { width: 18px; min-height: 18px; }
.participant-row input[type=number] { min-height: 38px; }
.participant-heading { margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.participant-heading label { display: block; }
.participant-heading small { color: var(--muted); font-size: 11px; }
.participant-search { margin-bottom: 10px; min-height: 42px; background: #fff; }
.lesson-participants { min-width: 0; }
.lesson-selected { display: grid; gap: 7px; }
.lesson-selected:not(:empty) { margin-bottom: 10px; }
.lesson-selected-row { min-width: 0; padding: 9px 11px; display: grid; grid-template-columns: minmax(120px, 1fr) 130px 170px auto; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 11px; background: #faf5f0; }
.lesson-selected-row > div { min-width: 0; display: grid; gap: 2px; }
.lesson-selected-row b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.lesson-selected-row small { color: var(--muted); font-size: 10px; }
.lesson-selected-row label { gap: 3px; font-size: 10px; }
.lesson-selected-row input { min-height: 34px; padding: 6px 9px; }
.lesson-selected-row select { min-height: 34px; padding: 6px 9px; }
.lesson-edit-scope { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; padding: 10px 12px 12px; border: 1px solid var(--line); border-radius: 12px; }
.lesson-edit-scope legend { padding: 0 5px; color: var(--ink); font-size: 13px; font-weight: 750; }
.lesson-edit-scope label { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.lesson-edit-scope label:has(input:checked) { border-color: var(--wine); background: #fff5f2; }
.lesson-edit-scope input[type=radio] { width: 18px; min-height: 18px; padding: 0; margin: 0; flex: 0 0 18px; accent-color: var(--wine); }
.lesson-edit-scope .form-hint { grid-column: 1 / -1; margin: 0; }
.lesson-search-results { max-height: 280px; margin-top: -2px; padding: 5px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; background: white; }
.lesson-search-results .form-hint { margin: 9px; }
.lesson-search-result, .lesson-search-create { width: 100%; padding: 9px 11px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 0; border-radius: 9px; background: transparent; text-align: left; font-size: 12px; }
.lesson-search-result:hover, .lesson-search-result:focus-visible, .lesson-search-create:hover, .lesson-search-create:focus-visible { background: #faf0ea; }
.lesson-search-result span:first-child { display: grid; gap: 2px; }
.lesson-search-result small { color: var(--muted); font-size: 10px; }
.lesson-search-create { color: var(--wine); font-weight: 750; }
.lesson-new-student { margin-top: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #faf5f0; }
.lesson-new-student h3 { margin: 0 0 12px; font-size: 18px; }
.lesson-new-actions { margin-top: 12px; display: flex; justify-content: flex-end; gap: 8px; }
.toggle-field { padding: 14px 16px; display: flex; grid-column: 1 / -1; grid-template-columns: none; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 14px; background: #faf5f0; cursor: pointer; }
.toggle-field > input { position: absolute; width: 1px; min-height: 1px; opacity: 0; pointer-events: none; }
.toggle-control { width: 46px; height: 26px; padding: 3px; flex: 0 0 auto; border-radius: 999px; background: #cfc0b9; transition: .18s ease; }
.toggle-control span { width: 20px; height: 20px; display: block; border-radius: 50%; background: white; box-shadow: 0 2px 8px rgba(38,31,32,.2); transition: .18s ease; }
.toggle-field > input:checked + .toggle-control { background: var(--wine); }
.toggle-field > input:checked + .toggle-control span { transform: translateX(20px); }
.toggle-field > input:focus-visible + .toggle-control { outline: 3px solid rgba(164,12,18,.2); outline-offset: 3px; }
.toggle-field > span:last-child { display: grid; gap: 3px; }
.toggle-field b { color: var(--ink); font-size: 13px; }
.toggle-field small { color: var(--muted); font-size: 10px; font-weight: 500; }
.recurrence-options { padding: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.form-hint { margin: 5px 0 0; color: var(--muted); font-size: 10px; font-weight: 500; line-height: 1.4; }
.code-box { padding: 12px; border: 1px dashed #c9b5ac; border-radius: 12px; background: #f8f1eb; word-break: break-all; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.section-guide { display: grid; gap: 18px; }
.section-guide-intro { margin: 0; color: #55494a; font-size: 14px; line-height: 1.65; }
.section-guide h3 { font-size: 20px; }
.section-guide ol { margin: -4px 0 0; padding-left: 24px; display: grid; gap: 12px; }
.section-guide li { padding-left: 5px; color: #55494a; font-size: 13px; line-height: 1.55; }
.section-guide li::marker { color: var(--wine); font-weight: 850; }
.section-guide-note { padding: 15px 17px; border: 1px solid #e6c4bb; border-left: 4px solid var(--wine); border-radius: 13px; background: var(--rose-soft); }
.section-guide-note b { color: var(--wine-dark); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.section-guide-note p { margin: 5px 0 0; color: #63494a; font-size: 12px; line-height: 1.55; }

/* Full guide */
.guide-page { min-height: 100vh; background: var(--paper); scroll-behavior: smooth; }
.guide-topbar { position: sticky; top: 0; z-index: 20; min-height: 74px; padding: 14px clamp(20px, 4vw, 56px); display: flex; align-items: center; justify-content: space-between; gap: 18px; color: white; background: rgba(38,31,32,.97); backdrop-filter: blur(12px); }
.guide-topbar .sidebar-brand { margin: 0; font-size: 29px; }
.guide-topbar .button { color: white; border-color: rgba(255,255,255,.24); background: rgba(255,255,255,.08); text-decoration: none; }
.guide-shell { width: min(1280px, calc(100% - 36px)); margin: 0 auto; display: grid; grid-template-columns: 260px minmax(0, 820px); justify-content: center; gap: clamp(28px, 5vw, 72px); }
.guide-toc { position: sticky; top: 100px; height: fit-content; max-height: calc(100vh - 120px); padding: 26px 0; overflow-y: auto; }
.guide-toc nav { display: grid; gap: 3px; }
.guide-toc a { padding: 9px 12px; border-radius: 10px; color: var(--muted); font-size: 12px; font-weight: 700; text-decoration: none; }
.guide-toc a:hover { color: var(--wine); background: var(--rose-soft); }
.guide-document { padding: 54px 0 90px; }
.guide-hero { margin-bottom: 54px; }
.guide-hero h1 { max-width: 760px; font-size: clamp(42px, 6vw, 72px); }
.guide-hero > p:last-child { max-width: 650px; margin: 18px 0 0; color: var(--muted); font-size: 16px; line-height: 1.65; }
.guide-section { padding: 36px 0; border-top: 1px solid var(--line); scroll-margin-top: 96px; }
.guide-section:target { animation: guide-highlight 1.2s ease; }
@keyframes guide-highlight { from { background: var(--rose-soft); box-shadow: 0 0 0 18px var(--rose-soft); } }
.guide-section-heading { width: fit-content; display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.guide-section-heading h2 { font-size: clamp(28px, 4vw, 40px); }
.guide-section-heading span { color: transparent; font-size: 20px; transition: .16s ease; }
.guide-section-heading:hover span { color: var(--wine); }
.guide-intro { max-width: 720px; margin: 13px 0 22px; color: #55494a; font-size: 14px; line-height: 1.7; }
.guide-section ol { margin: 0 0 22px; padding-left: 25px; display: grid; gap: 12px; }
.guide-section li { padding-left: 6px; color: #55494a; font-size: 13px; line-height: 1.6; }
.guide-section li::marker { color: var(--wine); font-weight: 850; }
.guide-back-top { display: inline-block; margin-top: 16px; color: var(--wine); font-size: 11px; font-weight: 800; text-decoration: none; }

@media (max-width: 1120px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .entity-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .schedule-feed-item { grid-template-columns: 145px minmax(0, 1fr) auto; }
  .schedule-feed-status { grid-column: 2 / 3; grid-row: 2; }
  .schedule-feed-actions { grid-column: 3; grid-row: 1 / 3; }
}

@media (max-width: 1199px) {
  .calendar-week-desktop { display: none; }
  .calendar-week-mobile { display: block; }
  .calendar-mobile-days { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; }
  .calendar-mobile-days button { flex: 0 0 auto; }
  .calendar-mobile-events { display: grid; gap: 8px; }
  .calendar-mobile-events .calendar-event { min-height: 62px; }
  .calendar-mobile-events > .button { justify-self: start; }
  .calendar-month-grid { min-width: 0; grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .calendar-month-weekday { padding: 7px 2px; font-size: 10px; }
  .calendar-month-cell { min-height: 67px; padding: 4px 2px; }
  .calendar-month-cell.selected { box-shadow: inset 0 0 0 2px var(--wine); }
  .calendar-month-cell-head { min-height: 40px; margin: 0; display: grid; grid-template-rows: 24px 14px; justify-items: center; gap: 1px; }
  .calendar-month-cell-head .desktop-date, .calendar-month-cell-head .calendar-month-add, .calendar-month-events { display: none; }
  .calendar-month-cell-head .mobile-date { display: block; grid-row: 1; }
  .calendar-month-day-count { grid-row: 2; padding: 1px 4px; font-size: 8px; }
  .calendar-month-day-dots { min-height: 7px; display: flex; justify-content: center; align-items: center; gap: 2px; }
  .calendar-month-day-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--calendar-accent); }
  .calendar-month-mobile-detail { margin-top: 16px; padding-top: 14px; display: block; border-top: 1px solid var(--line); }
  .calendar-month-mobile-detail h3 { margin-bottom: 12px; font-size: 18px; text-transform: capitalize; }
}

@media (max-width: 800px) {
  .dashboard-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-104%); width: min(290px, 88vw); transition: transform .2s ease; box-shadow: 18px 0 55px rgba(0,0,0,.2); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open + .sidebar-backdrop { position: fixed; z-index: 19; inset: 0; display: block; padding: 0; border: 0; background: rgba(33,24,25,.34); }
  .workspace { padding: 22px 16px; }
  .workspace-header { align-items: flex-start; }
  .mobile-menu { display: inline-grid !important; flex: 0 0 auto; }
  .header-actions { position: fixed; left: 14px; right: 14px; bottom: 14px; padding: 10px; justify-content: stretch; border: 1px solid var(--line); border-radius: 18px; background: rgba(255,253,250,.94); box-shadow: var(--shadow); backdrop-filter: blur(10px); z-index: 15; }
  .header-actions .button { flex: 1; }
  .app-footer { margin-bottom: 80px; }
  .dashboard-shell:not(.has-header-actions) .app-footer { margin-bottom: 0; }
  .login-page { background: var(--paper); }
  .login-layout { padding: 24px; grid-template-columns: 1fr; gap: 24px; align-content: center; }
  .login-brand { color: var(--ink); }
  .guide-shell { width: min(100% - 30px, 760px); display: block; }
  .guide-toc { position: static; max-height: none; padding: 24px 0 0; }
  .guide-toc nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guide-document { padding-top: 36px; }
}

@media (max-width: 560px) {
  .calendar-navigation h2 { flex-basis: 100%; margin-left: 0; }
  .calendar-toolbar { align-items: stretch; }
  .calendar-mode-switch { width: 100%; }
  .calendar-mode-switch button { flex: 1; }
  .calendar-filter-head input { width: 100%; }
  .metrics-grid, .entity-grid, .integration-grid, .modal-grid { grid-template-columns: 1fr; }
  .modal-grid .full { grid-column: auto; }
  .metric-card { min-height: 120px; }
  .workspace-header { gap: 12px; }
  .workspace-header h1 { font-size: 30px; }
  .page-title-row { gap: 9px; }
  .section-guide-button { width: 32px; height: 32px; font-size: 18px; }
  .panel { padding: 15px; border-radius: 16px; }
  .schedule-feed-item { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 10px; }
  .schedule-feed-item time { grid-column: 1 / -1; }
  .schedule-feed-main { grid-column: 1; grid-row: 2; }
  .schedule-feed-status { grid-column: 1 / -1; grid-row: 3; }
  .schedule-feed-actions { grid-column: 2; grid-row: 2; }
  .participant-row { grid-template-columns: auto 1fr; }
  .participant-row input[type=number] { grid-column: 2; }
  .lesson-selected-row { grid-template-columns: minmax(0, 1fr) auto; }
  .lesson-selected-row label { grid-column: 1 / -1; }
  .lesson-selected-row label:first-of-type { grid-row: 2; }
  .lesson-selected-row label:nth-of-type(2) { grid-row: 3; }
  .lesson-edit-scope { grid-template-columns: 1fr; }
  .recurrence-options { grid-template-columns: 1fr; }
  .login-card { padding: 28px 22px; border-radius: 22px; }
  .guide-topbar { min-height: 66px; padding: 11px 15px; }
  .guide-topbar .sidebar-brand { font-size: 25px; }
  .guide-topbar .button { min-height: 36px; padding: 7px 11px; font-size: 11px; }
  .guide-toc nav { grid-template-columns: 1fr; }
  .guide-document { padding-bottom: 60px; }
  .guide-hero { margin-bottom: 38px; }
  .guide-section { padding: 30px 0; }
}

/* Keep the initial lesson form within a laptop viewport; expanded editors remain reachable. */
.lesson-form #participant-list[hidden] { display: none; }
.reschedule-cell { display: grid; justify-items: start; gap: 5px; }
.reschedule-cell small { color: var(--muted); font-size: 10px; line-height: 1.4; }
.reschedule-summary { display: grid; gap: 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #faf5f0; }
.reschedule-summary span { color: var(--muted); font-size: 12px; }
.reschedule-mode-list { display: grid; gap: 8px; }
.reschedule-mode { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.reschedule-mode:has(input:checked) { border-color: var(--wine); background: #fff5f2; }
.reschedule-mode input[type=radio] { width: 18px; min-height: 18px; margin: 1px 0 0; accent-color: var(--wine); flex: 0 0 18px; }
.reschedule-mode > span { display: grid; gap: 4px; }
.reschedule-mode small { color: var(--muted); font-size: 11px; font-weight: 500; }
.reschedule-contact-warning { margin: 0; padding: 10px 12px; border-radius: 10px; background: #fff3d8; color: #8c6419; font-size: 11px; line-height: 1.5; }
.reschedule-modal .modal-head { margin-bottom: 14px; }
.reschedule-modal .modal-grid { gap: 10px 14px; }
.reschedule-modal textarea { min-height: 68px; height: 68px; }
.reschedule-modal .modal-actions { margin-top: 14px; }
@media (min-width: 801px) {
  .lesson-modal { width: min(860px, calc(100vw - 32px)); }
  .lesson-modal .modal-card { padding: 18px 22px; }
  .lesson-modal .modal-head { margin-bottom: 12px; }
  .lesson-modal .modal-head h2 { font-size: 28px; }
  .lesson-modal .modal-head .eyebrow { margin-bottom: 5px; }
  .lesson-modal .modal-grid { gap: 10px 16px; }
  .lesson-modal label { gap: 5px; }
  .lesson-modal input, .lesson-modal select { min-height: 38px; padding: 8px 12px; }
  .lesson-modal textarea { min-height: 58px; height: 58px; padding: 8px 12px; }
  .lesson-modal .participant-heading { margin-bottom: 5px; }
  .lesson-modal .participant-search { margin-bottom: 0; }
  .lesson-modal .toggle-field { padding: 10px 12px; }
  .lesson-modal .modal-actions { margin-top: 14px; }
  .lesson-modal .lesson-search-results { max-height: 150px; margin-top: 8px; }
}
