:root {
  color-scheme: light;
  --bg: #eef8ff;
  --panel: #ffffff;
  --ink: #173044;
  --muted: #5f7890;
  --line: #cfe3f3;
  --brand: #2f8fce;
  --brand-2: #91e6a7;
  --warn: #fff0bd;
  --danger: #ffd4dc;
  --slot: #e8f4fd;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: env(safe-area-inset-top) 14px calc(82px + env(safe-area-inset-bottom));
}

.topbar {
  align-items: flex-start;
  display: flex;
  justify-content: space-between;
  padding: 14px 2px 12px;
}

.header-actions {
  align-items: center;
  display: flex;
  gap: 4px;
  margin-right: -14px;
  padding-top: 0;
}

.eyebrow,
.date-ai-trigger {
  color: var(--muted);
  font-size: 12px;
  margin: 0 0 3px;
}

.date-ai-trigger {
  align-items: baseline;
  background: transparent;
  border: 0;
  display: inline-flex;
  gap: 6px;
  padding: 0;
}

.date-ai-trigger span {
  color: #7e57c2;
  font-size: 11px;
  font-weight: 900;
}

.date-ai-trigger strong {
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

.app-version {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: inline-flex;
  font-size: 11px;
  gap: 5px;
  min-height: 0;
  margin-top: 3px;
  opacity: 0.75;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: rgba(95, 120, 144, 0.35);
}

.app-version::before {
  align-items: center;
  background: #d9f7df;
  border: 1px solid #58c577;
  border-radius: 999px;
  color: #1f9d55;
  content: "i";
  display: inline-flex;
  font-size: 9px;
  font-weight: 900;
  height: 13px;
  justify-content: center;
  line-height: 1;
  width: 13px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  letter-spacing: 0;
}

.site-title-link {
  color: inherit;
  display: block;
  text-decoration: none;
}

.site-title-link:hover {
  color: var(--brand);
}

h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.icon-btn {
  align-items: center;
  background: var(--brand);
  border: 0;
  border-radius: 18px;
  color: white;
  display: grid;
  font-size: 28px;
  height: 52px;
  place-items: center;
  width: 52px;
}

.small-icon-btn {
  background: var(--brand);
  color: white;
  height: 52px;
  width: 52px;
}

.small-icon-btn svg {
  fill: none;
  height: 25px;
  stroke: currentColor;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 25px;
}

.header-icon-btn {
  align-items: center;
  background: #f3f9fe;
  border: 1px solid #d7e9f6;
  border-radius: 10px;
  color: #6f8799;
  display: grid;
  height: 31px;
  justify-content: center;
  padding: 0;
  width: 31px;
}

.header-settings-btn {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.header-training-btn {
  background: #def8e6;
  border-color: #8bd8a5;
  box-shadow: 0 2px 8px rgba(35, 141, 77, 0.16);
  color: #168947;
}

.header-training-btn:active {
  background: #d9f4e1;
  color: #176d39;
}

.header-icon-btn:active {
  background: #e5f3fd;
  color: var(--brand);
  transform: translateY(1px);
}

.header-icon-btn svg {
  fill: none;
  height: 15px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  width: 15px;
}

.header-support-btn {
  background: #fff7e8;
  border-color: #f2d8ae;
  color: #b7792e;
}

.header-support-btn:active {
  background: #ffefd2;
  color: #9a6121;
}

.header-support-btn svg {
  fill: rgba(183, 121, 46, 0.12);
}

.header-stars-btn {
  width: 43px;
}

.header-stars-btn span {
  color: #3bbf6a;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.settings-row {
  margin-bottom: 12px;
}

.settings-row label {
  max-width: 220px;
}

.settings-block {
  background: #f4fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px;
}

.settings-title-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.settings-icon-actions {
  align-items: center;
  display: flex;
  gap: 6px;
}

.settings-icon-btn {
  align-items: center;
  background: #f3f9fe;
  border: 1px solid #d7e9f6;
  border-radius: 10px;
  color: #6f8799;
  display: grid;
  height: 34px;
  justify-content: center;
  padding: 0;
  width: 34px;
}

.settings-icon-btn:active {
  background: #e5f3fd;
  color: var(--brand);
  transform: translateY(1px);
}

.settings-icon-btn svg {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  width: 18px;
}

.rate-stars-btn {
  width: 58px;
}

.rate-stars-btn span {
  color: #3bbf6a;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: -1px;
  line-height: 1;
}

.settings-inline-toast {
  color: #7d93a4;
  font-size: 11px;
  min-height: 14px;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.settings-inline-toast.visible {
  opacity: 1;
}

.toggle-line {
  align-items: center;
  display: flex;
  flex-direction: row;
  gap: 9px;
}

.toggle-line input {
  width: auto;
}

.settings-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin: 0;
}

.settings-link {
  align-items: center;
  background: transparent;
  border: 0;
  color: #9bacb8;
  display: inline-flex;
  font-size: 11px;
  font-weight: 500;
  justify-content: center;
  justify-self: center;
  min-height: 18px;
  opacity: 0.58;
  padding: 0 4px;
  text-align: center;
  text-decoration: underline;
  text-decoration-color: rgba(155, 172, 184, 0.35);
}

.training-promo {
  align-items: center;
  background: #edf8ff;
  border: 1px solid #cbe8f7;
  border-radius: 12px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  padding: 12px;
}

.training-promo h3 {
  margin: 0;
}

.training-book-link {
  align-items: center;
  background: var(--brand);
  border-radius: 10px;
  box-shadow: 0 6px 14px rgba(47, 143, 206, 0.24);
  color: #fff;
  display: inline-flex;
  flex: 0 0 auto;
  height: 42px;
  justify-content: center;
  text-decoration: none;
  width: 42px;
}

.training-book-link svg {
  fill: none;
  height: 23px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
  width: 23px;
}

.clear-data-btn {
  background: transparent;
  border: 1px solid #f1c8d0;
  border-radius: 8px;
  color: #bd6675;
  font-size: 12px;
  font-weight: 700;
  min-height: 34px;
  opacity: 0.72;
  padding: 8px 10px;
}

.clear-data-btn:active {
  background: #fff4f6;
  opacity: 1;
}

.online-link-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1.35fr) minmax(105px, 0.65fr);
}

.online-lesson-link,
.online-copy-btn {
  align-items: center;
  background: #e8f4fd;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--brand);
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  justify-content: center;
  min-height: 36px;
  padding: 8px 10px;
  text-decoration: none;
}

.online-copy-btn {
  cursor: pointer;
}

.online-lesson-link::before {
  content: "↗";
  font-size: 13px;
  margin-right: 6px;
}

.online-copy-btn::before {
  content: "⧉";
  font-size: 13px;
  margin-right: 6px;
}

.app-toast {
  background: rgba(23, 48, 68, 0.9);
  border-radius: 12px;
  bottom: calc(88px + env(safe-area-inset-bottom));
  color: #fff;
  font-size: 13px;
  left: 50%;
  line-height: 1.25;
  max-width: calc(100vw - 44px);
  opacity: 0;
  padding: 10px 14px;
  pointer-events: none;
  position: fixed;
  text-align: center;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 20;
}

.app-toast.with-action {
  align-items: center;
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.app-toast.with-action button {
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 6px 10px;
}

.app-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.dialog-title-row {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.dialog-title-row span {
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.day-ai-output {
  background: #f4fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  max-height: min(52dvh, 430px);
  min-height: 96px;
  overflow: auto;
  padding: 12px;
  white-space: pre-wrap;
}

.day-ai-card {
  gap: 10px;
  padding: 14px;
}

.help-card {
  gap: 14px;
}

.help-content {
  display: grid;
  gap: 12px;
}

.help-content section {
  background: #f4fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.help-content h3 {
  color: var(--brand);
  font-size: 15px;
  margin: 0;
}

.help-content p {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
}

.metric,
.day-summary,
.summary-grid,
.month-summary,
.analytics-card,
.list-item {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.metric {
  padding: 13px;
}

.metric span,
.minor {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.metric strong {
  display: block;
  font-size: 22px;
  margin-top: 5px;
}

.ai-metric {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 74px;
  padding: 12px 10px 10px;
  position: relative;
  text-align: left;
}

.ai-metric em {
  background: #f1eaff;
  border-radius: 999px;
  color: #7e57c2;
  font-size: 8px;
  font-style: normal;
  font-weight: 900;
  line-height: 1;
  padding: 4px 5px;
  position: absolute;
  right: 8px;
  top: 7px;
}

.ai-metric span {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.15;
  padding-right: 38px;
}

.ai-metric strong {
  color: #7e57c2;
  font-size: 13px;
  line-height: 1.18;
  margin-top: 4px;
  white-space: nowrap;
}

.ai-metric small {
  color: var(--muted);
  display: block;
  font-size: 10px;
  line-height: 1.25;
  margin-top: 4px;
}

.ai-paywall-card p {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
}

.ai-status {
  background: #eef8ff;
  border: 1px solid #cce8fa;
  border-radius: 8px;
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
  padding: 10px;
}

.summary-grid .active-count strong {
  color: #2b9f6a;
}

.section-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 12px 0 8px;
}

.actions-row {
  display: flex;
  gap: 8px;
}

.mode-switch {
  background: #dff1ff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 14px;
  padding: 4px;
}

.mode {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  min-height: 38px;
}

.mode.active {
  background: var(--panel);
  color: var(--brand);
  font-weight: 800;
}

.text-btn,
.ghost,
.primary {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 13px;
}

.text-btn {
  background: #dff1ff;
  color: var(--brand);
  font-weight: 700;
}

.week-strip {
  display: grid;
  gap: 8px;
  grid-auto-columns: minmax(74px, 1fr);
  grid-auto-flow: column;
  margin-bottom: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.week-totals-strip {
  grid-auto-columns: minmax(142px, 1fr);
}

.week-total {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 3px;
  padding: 9px;
}

.week-total strong {
  font-size: 13px;
}

.week-total span {
  color: var(--brand);
  font-size: 13px;
  font-weight: 800;
}

.week-total small {
  color: var(--muted);
  font-size: 11px;
}

.day-chip {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 58px;
  padding: 7px 8px;
  text-align: left;
}

.day-chip.active {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

.day-chip strong {
  display: block;
  font-size: 16px;
}

.compact-chip {
  min-width: 96px;
}

.compact-chip span {
  font-size: 12px;
  white-space: nowrap;
}

.compact-chip strong {
  font-size: 15px;
}

.month-chip {
  min-width: 106px;
}

.month-chip span {
  font-size: 12px;
}

.month-chip strong {
  font-size: 15px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.day-summary {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 8px;
  padding: 10px;
}

.unpaid-breakdown {
  background: #fff8d8;
  border: 1px solid #ecd56c;
  border-radius: 8px;
  grid-column: 1 / -1;
  justify-self: end;
  padding: 5px 8px;
}

.unpaid-breakdown summary {
  color: #7a6a25;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  list-style-position: inside;
}

.unpaid-breakdown small {
  color: var(--ink);
  display: block;
  font-size: 12px;
  line-height: 1.35;
  margin-top: 4px;
}

.summary-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 12px;
  padding: 10px;
}

.summary-grid strong {
  display: block;
  font-size: 22px;
  margin-top: 4px;
}

.search-input {
  margin-bottom: 12px;
  width: 100%;
}

.day-summary div {
  min-width: 0;
}

.day-summary strong {
  display: block;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.timeline {
  display: grid;
  gap: 8px;
}

.calendar-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 28px;
}

.calendar-grid.month-calendar {
  gap: 4px;
  grid-template-columns: repeat(7, minmax(38px, 1fr));
}

.calendar-grid.year-calendar {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.month-weekday {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.slot-grid {
  display: grid;
  gap: 3px;
  grid-template-columns: 54px repeat(7, minmax(82px, 1fr));
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.slot-grid-head,
.slot-grid-time,
.slot-cell {
  border-radius: 7px;
  min-height: 42px;
  padding: 6px;
}

.slot-grid-head {
  align-content: center;
  background: #dff1ff;
  color: var(--brand);
  display: grid;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.slot-grid-time {
  align-content: center;
  background: var(--bg);
  color: var(--muted);
  display: grid;
  font-size: 12px;
  left: 0;
  position: sticky;
  z-index: 2;
  text-align: right;
}

.slot-grid-head:first-child {
  left: 0;
  position: sticky;
  z-index: 5;
}

.slot-cell {
  background: var(--slot);
  border: 1px dashed #b9d9ee;
  color: var(--muted);
  display: grid;
  font-size: 11px;
  line-height: 1.15;
  min-width: 82px;
  overflow: hidden;
  text-align: left;
}

.slot-cell strong {
  color: var(--ink);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-cell span {
  display: block;
  font-size: 10px;
  line-height: 1.12;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-cell.paid {
  background: #d9f7df;
  border-color: #91e6a7;
  color: #215b31;
}

.slot-cell.debt {
  background: var(--warn);
  border-color: #eccb55;
  color: #4c3b00;
}

.slot-cell.conducted,
.slot-body.conducted,
.student-lesson.conducted {
  background: #f1eafe;
  border-color: #d8cdf5;
  color: #6f55a8;
}

.slot-cell.conducted strong,
.slot-body.conducted .slot-title,
.slot-body.conducted .slot-meta,
.student-lesson.conducted strong {
  color: #6f55a8;
}

.slot-cell.personal,
.slot-body.personal {
  background: #e6f1f7;
  border-color: #b8d3e2;
  color: #506878;
}

.slot-cell.personal strong,
.slot-body.personal .slot-title,
.slot-body.personal .slot-meta {
  color: #405d70;
}

.slot-cell.personal-done,
.slot-body.personal-done {
  background: #ece8f5;
  border-color: #d4cce8;
  color: #695f7c;
}

.slot-cell.personal-done strong,
.slot-body.personal-done .slot-title,
.slot-body.personal-done .slot-meta {
  color: #5e526f;
}

.slot-cell.continuation,
.slot-body.continuation {
  border-style: solid;
}

.slot-cell.continuation {
  align-content: center;
}

.slot-cell.continuation strong,
.slot-body.continuation .slot-title {
  opacity: 0.82;
}

.slot-cell.continuation span:empty,
.slot-body.continuation .slot-meta:empty {
  display: none;
}

.slot-cell.needs-action,
.slot-body.needs-action,
.student-lesson.needs-action {
  box-shadow: inset 0 0 0 2px rgba(126, 87, 194, 0.55);
}

.period-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 5px;
  min-height: 82px;
  padding: 10px;
  text-align: left;
}

.month-calendar .period-card {
  border-radius: 7px;
  min-height: 64px;
  padding: 6px;
}

.month-calendar .period-card strong {
  font-size: 13px;
}

.month-calendar .period-card span {
  font-size: 10px;
  line-height: 1.15;
}

.period-card.muted-period {
  background: #eef2f5;
  border-color: #d8e0e6;
  color: #8a98a5;
  opacity: 1;
}

.period-card.paid {
  background: #d9f7df;
  border-color: #91e6a7;
}

.period-card.partial {
  background: #e3f7ed;
  border-color: #a8dfc4;
}

.period-card.debt {
  background: var(--warn);
  border-color: #eccb55;
}

.period-card strong {
  font-size: 16px;
  overflow-wrap: anywhere;
}

.period-card span {
  color: var(--muted);
  font-size: 12px;
}

.slot {
  align-items: stretch;
  display: grid;
  gap: 8px;
  grid-template-columns: 54px 1fr;
  min-height: 58px;
}

.slot-time {
  color: var(--muted);
  font-size: 13px;
  padding-top: 8px;
  text-align: right;
}

.slot-body {
  background: var(--slot);
  border: 1px dashed #b9d9ee;
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  padding: 9px 11px;
  text-align: left;
}

.slot-body.paid {
  background: #d9f7df;
  border-color: #91e6a7;
  color: #215b31;
}

.slot-body.debt {
  background: var(--warn);
  border-color: #eccb55;
  color: #4c3b00;
}

.slot-title {
  color: var(--ink);
  display: flex;
  font-weight: 800;
  justify-content: space-between;
  gap: 8px;
}

.slot-meta {
  font-size: 13px;
  margin-top: 4px;
}

.slot-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.slot-actions button {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 7px;
  min-height: 32px;
  padding: 0 10px;
}

.slot-actions span {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 7px;
  color: var(--brand);
  display: inline-flex;
  font-weight: 700;
  min-height: 32px;
  padding: 7px 10px 0;
}

.slot-cell em {
  color: var(--brand);
  display: block;
  font-size: 11px;
  font-style: normal;
  font-weight: 700;
  margin-top: 3px;
}

.list {
  display: grid;
  gap: 10px;
}

.attendance-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.attendance-row span {
  display: grid;
  gap: 3px;
}

.attendance-row small {
  color: var(--muted);
  font-size: 12px;
}

.attendance-row.paid-row {
  background: #d9f7df;
  border-color: #91e6a7;
}

.attendance-row.debt-row {
  background: var(--warn);
  border-color: #eccb55;
}

.attendance-row input {
  min-height: 24px;
  width: 24px;
}

.archive-block {
  display: grid;
  gap: 8px;
}

.archive-block summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 8px 2px;
}

.archived {
  opacity: 0.72;
}

.list-item {
  padding: 12px;
}

button.list-item {
  color: var(--ink);
  display: block;
  text-align: left;
  width: 100%;
}

.list-item strong {
  display: block;
  font-size: 16px;
}

.payer-line,
.payer-box {
  background: #f3f9fe;
  border: 1px solid #d8e9f6;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-top: 7px;
  padding: 8px 10px;
}

.payer-box {
  margin-top: 0;
}

.student-schedule {
  display: grid;
  gap: 5px;
}

.student-history-box {
  justify-self: start;
}

.student-history-box summary {
  color: #9bacb8;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  list-style-position: inside;
  opacity: 0.62;
  text-decoration: underline;
  text-decoration-color: rgba(155, 172, 184, 0.35);
}

.student-history-box[open] {
  background: #f7fbfe;
  border: 1px solid #dbeaf4;
  border-radius: 8px;
  padding: 5px 7px 7px;
}

.student-history-box[open] summary {
  margin-bottom: 7px;
}

.student-history-stats {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 6px;
}

.student-history-stats div {
  background: #ffffff;
  border: 1px solid #dcecf6;
  border-radius: 7px;
  padding: 6px;
}

.student-history-stats span {
  color: var(--muted);
  display: block;
  font-size: 10px;
}

.student-history-stats strong {
  color: var(--ink);
  display: block;
  font-size: 11px;
  margin-top: 2px;
}

.student-schedule h3 {
  display: none;
}

.student-schedule-empty,
.student-lesson {
  border-radius: 8px;
  padding: 7px 8px;
}

.student-schedule-empty {
  background: #e8f4fd;
  color: var(--muted);
  font-size: 13px;
}

.student-lesson {
  align-items: center;
  border: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 6px;
  text-align: left;
}

.student-lesson span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.student-lesson span strong {
  font-size: 12px;
}

.student-lesson small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.student-lesson > strong {
  flex: 0 0 auto;
  font-size: 12px;
  text-align: right;
}

.student-lesson.paid {
  background: #d9f7df;
  border-color: #91e6a7;
}

.student-lesson.debt {
  background: #fff0bd;
  border-color: #eccb55;
}

.regular-slots {
  display: grid;
  gap: 7px;
}

.regular-slots-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.regular-slots-head .minor {
  margin: 0;
}

.small-soft-btn {
  background: #e4f4ff;
  border: 1px solid #cfe8f8;
  border-radius: 12px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  min-height: 38px;
  padding: 8px 12px;
}

.regular-slot-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr 86px;
}

.regular-slot-row input[type="time"],
.regular-slot-row input[type="number"] {
  min-width: 0;
}

.list-row {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 8px;
}

.badge.paid {
  background: #d9f7df;
}

.badge.debt {
  background: var(--warn);
}

.month-summary,
.analytics-card {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
}

.analytics {
  display: grid;
  gap: 10px;
}

.tabs {
  background: rgba(255, 253, 247, 0.96);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  left: 0;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  position: fixed;
  right: 0;
  z-index: 10;
}

.tab {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  min-height: 48px;
}

.tab.active {
  background: #dff1ff;
  color: var(--brand);
  font-weight: 800;
}

dialog {
  border: 0;
  border-radius: 12px;
  max-height: calc(100dvh - 28px);
  max-width: 440px;
  padding: 0;
  width: calc(100vw - 24px);
}

dialog::backdrop {
  background: rgba(23, 37, 38, 0.35);
}

#dayAiDialog {
  max-width: 360px;
  width: calc(100vw - 44px);
}

.dialog-card {
  background: var(--panel);
  display: grid;
  gap: 12px;
  max-height: calc(100dvh - 28px);
  max-width: 100%;
  min-width: 0;
  overflow: auto;
  padding: 18px;
  width: 100%;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 5px;
}

.student-price-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.student-price-grid label {
  min-width: 0;
}

.student-price-grid label.hidden {
  display: none;
}

.hidden {
  display: none;
}

input,
select,
textarea {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  max-width: 100%;
  min-height: 43px;
  min-width: 0;
  padding: 8px 10px;
  width: 100%;
}

button {
  min-width: 0;
}

.toggle-line input[type="checkbox"],
.attendance-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: auto;
}

.dialog-actions {
  background: linear-gradient(to top, var(--panel) 82%, rgba(255, 255, 255, 0));
  bottom: 0;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-top: 4px;
  padding-top: 10px;
  position: sticky;
}

.dialog-actions.three {
  grid-template-columns: 1fr 1fr 1fr;
}

.dialog-actions.four {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ghost {
  background: #e8f4fd;
  color: var(--ink);
}

.primary {
  background: var(--brand);
  color: white;
  font-weight: 800;
}

.danger {
  background: #ffe8ed;
  color: #8b3140;
  font-weight: 700;
}

.type-switch {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 5px;
}

.type-switch label {
  align-items: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  display: flex;
  font-weight: 800;
  gap: 6px;
  justify-content: center;
  margin: 0;
  padding: 9px;
}

.type-switch label:has(input:checked) {
  background: white;
  color: var(--brand);
}

.help-content ol {
  color: var(--text);
  margin: 8px 0 0;
  padding-left: 20px;
}

.help-content li {
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 5px;
}

.subtle-danger {
  border: 1px solid #f3b7c2;
}

.conducted-action {
  background: #f1eafe;
  color: #6f55a8;
  font-weight: 800;
}

.conducted-action.active {
  background: #e7dcfb;
  color: #5d4594;
}

@media (min-width: 720px) {
  .app-shell {
    margin: 0 auto;
    max-width: 720px;
  }

  .calendar-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .calendar-grid.month-calendar {
    grid-template-columns: repeat(7, minmax(56px, 1fr));
  }

  .calendar-grid.year-calendar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1040px) {
  body {
    background:
      linear-gradient(90deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 28%),
      var(--bg);
  }

  .app-shell {
    display: grid;
    gap: 18px 22px;
    grid-template-columns: 190px minmax(0, 1fr);
    grid-template-areas:
      "topbar topbar"
      "tabs content";
    grid-template-rows: auto 1fr;
    align-content: start;
    align-items: start;
    margin: 0 auto;
    max-width: 1320px;
    min-height: 100vh;
    padding: 22px 28px 30px;
  }

  .topbar {
    align-items: flex-start;
    grid-area: topbar;
    padding: 0;
  }

  .topbar h1 {
    font-size: 34px;
  }

  .date-ai-trigger strong {
    font-size: 14px;
  }

  .app-version {
    font-size: 12px;
  }

  .header-actions {
    gap: 6px;
    margin-right: -18px;
  }

  .header-icon-btn {
    border-radius: 12px;
    height: 35px;
    width: 35px;
  }

  .header-stars-btn {
    width: 50px;
  }

  main {
    grid-area: content;
    min-width: 0;
  }

  #view-home {
    max-width: 1060px;
  }

  #view-home > * {
    max-width: 1060px;
  }

  .tabs {
    align-self: start;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    border-radius: 12px;
    bottom: auto;
    display: grid;
    gap: 6px;
    grid-area: tabs;
    grid-template-columns: 1fr;
    left: auto;
    padding: 8px;
    position: sticky;
    right: auto;
    top: 22px;
    z-index: 3;
  }

  .tab {
    border-radius: 10px;
    min-height: 44px;
    padding: 0 12px;
    text-align: left;
  }

  .tab.active {
    background: #dff1ff;
  }

  .view.active {
    min-width: 0;
  }

  .metrics {
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 10px;
    width: 820px;
  }

  .ai-metric {
    border-color: #cfe4f3;
    border-radius: 9px;
    min-height: 68px;
    padding: 9px 10px;
  }

  .ai-metric span {
    font-size: 10px;
    padding-right: 36px;
  }

  .ai-metric strong {
    font-size: 12px;
    line-height: 1.15;
    margin-top: 3px;
  }

  .ai-metric small {
    font-size: 9px;
    line-height: 1.15;
    margin-top: 3px;
  }

  .mode-switch {
    max-width: 820px;
    margin-bottom: 12px;
    width: 820px;
  }

  .section-head {
    margin: 10px 0 8px;
  }

  .week-strip {
    grid-auto-columns: minmax(128px, 1fr);
    width: 100%;
  }

  .month-strip {
    grid-auto-columns: minmax(138px, 1fr);
  }

  .day-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .slot-grid {
    grid-template-columns: 64px repeat(7, minmax(118px, 1fr));
    max-width: calc(100vw - 260px);
    gap: 4px;
  }

  .slot-cell {
    min-width: 118px;
  }

  .slot-grid-head,
  .slot-grid-time,
  .slot-cell {
    min-height: 50px;
    padding: 7px;
  }

  .slot-cell {
    border-color: #c5e0f3;
    color: #7890a2;
  }

  .calendar-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .calendar-grid.month-calendar {
    grid-template-columns: repeat(7, minmax(78px, 1fr));
  }

  .calendar-grid.year-calendar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .list {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #paymentsList {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .search-input {
    max-width: 520px;
  }

  dialog {
    max-width: 560px;
  }

  .help-card {
    max-width: 780px;
  }
}
