/* =========================================================================
   TutorMe — UI v11 (modern refresh)
   Design tokens + component styles. Class names preserved for app.js.
   ========================================================================= */

:root {
  /* surfaces */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef1f6;

  /* ink */
  --ink: #161a22;
  --ink-2: #4a5163;
  --muted: #8a93a6;
  --muted-2: #aab2c2;

  /* lines */
  --line: #edf0f5;
  --line-2: #e2e7f0;

  /* brand */
  --brand: #1677ff;
  --brand-600: #0a5cdf;
  --brand-700: #0846b8;
  --brand-50: #eef5ff;
  --brand-100: #dbe9ff;

  /* status */
  --success: #2ba24c;
  --success-bg: #effaf1;
  --success-line: #b7e6c2;
  --warn: #d48806;
  --warn-bg: #fff8e8;
  --warn-line: #ffe2a6;
  --danger: #e5484d;
  --danger-bg: #fff0f0;
  --danger-line: #ffc9c9;
  --violet: #7c5cff;

  /* radius */
  --r-xs: 7px;
  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* shadow */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 14px 40px rgba(16, 24, 40, 0.14);
  --ring: 0 0 0 3px rgba(22, 119, 255, 0.16);

  --sidebar-w: 240px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-xs);
}

/* slim scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: #cdd4e0 transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: #cdd4e0;
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
*::-webkit-scrollbar-thumb:hover {
  background: #b3bccd;
  background-clip: padding-box;
}

h1,
h2,
h3,
p {
  margin: 0;
}

/* =========================================================================
   Login
   ========================================================================= */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 16% 18%, rgba(22, 119, 255, 0.22), transparent 30%),
    radial-gradient(circle at 84% 8%, rgba(124, 92, 255, 0.16), transparent 26%),
    radial-gradient(circle at 70% 90%, rgba(22, 119, 255, 0.1), transparent 30%),
    linear-gradient(140deg, #eaf1ff 0%, #f3f6fc 48%, #ffffff 100%);
}

.login-screen.hidden {
  display: none;
}

.login-card {
  width: min(440px, 100%);
  padding: 38px 36px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 24px 60px rgba(13, 38, 88, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.login-brand {
  padding: 0 0 20px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.login-card h1 {
  margin-top: 22px;
  font-size: 27px;
  font-weight: 750;
  letter-spacing: -0.4px;
}

.login-card > p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13.5px;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.login-hint {
  display: flex;
  gap: 8px;
  padding: 11px 13px;
  border: 1px solid var(--brand-100);
  border-radius: var(--r-sm);
  color: var(--brand-700);
  background: var(--brand-50);
  font-size: 12.5px;
  line-height: 1.5;
}

.login-form .primary-button {
  min-height: 46px;
  margin-top: 4px;
  font-size: 15px;
}

/* =========================================================================
   Shell
   ========================================================================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 0 14px;
  color: rgba(255, 255, 255, 0.78);
  background: linear-gradient(190deg, #0d1b30 0%, #0a1626 60%, #091321 100%);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px 18px;
  margin: 0 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  background: linear-gradient(135deg, #3b91ff 0%, #1677ff 55%, #0a5cdf 100%);
  font-size: 21px;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(22, 119, 255, 0.45);
}

.brand-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #fff;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.42);
  font-size: 11.5px;
}

.nav-list {
  display: grid;
  gap: 4px;
  padding: 6px 12px;
}

.nav-item {
  width: 100%;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 13px;
  border: 0;
  border-radius: var(--r-sm);
  color: rgba(255, 255, 255, 0.72);
  background: transparent;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.07);
}

.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, #2782ff 0%, #1677ff 100%);
  box-shadow: 0 6px 16px rgba(22, 119, 255, 0.4);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

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

.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px 0;
  margin-inline: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.account-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  margin-bottom: 14px;
}

.account-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #3b91ff, #0a5cdf);
  font-weight: 800;
  box-shadow: 0 4px 10px rgba(22, 119, 255, 0.4);
}

.account-meta {
  min-width: 0;
}

.account-meta strong,
.account-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-meta strong {
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  font-weight: 600;
}

.account-meta span,
.version-line span {
  color: rgba(255, 255, 255, 0.42);
  font-size: 11.5px;
}

.version-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.version-line strong {
  color: rgba(255, 255, 255, 0.88);
  font-size: 12.5px;
}

.logout-button {
  width: 100%;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--r-sm);
  color: rgba(255, 255, 255, 0.86);
  background: rgba(255, 255, 255, 0.06);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.logout-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.logout-button:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.12);
}

/* =========================================================================
   Main area + topbar
   ========================================================================= */
.main-area {
  min-width: 0;
  padding: 0 28px 32px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 66px;
  margin: 0 -28px 26px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px) saturate(1.4);
  border-bottom: 1px solid var(--line-2);
  box-shadow: 0 2px 12px rgba(16, 24, 40, 0.04);
}

.eyebrow {
  color: var(--brand);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

h1 {
  margin-top: 3px;
  font-size: 23px;
  font-weight: 750;
  letter-spacing: -0.4px;
}

h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

p {
  color: var(--muted);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.search-box {
  width: min(340px, 34vw);
  height: 42px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.search-box:focus-within {
  border-color: var(--brand);
  box-shadow: var(--ring);
}

.search-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

/* =========================================================================
   Buttons
   ========================================================================= */
.primary-button,
.ghost-button,
.text-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  padding: 0 16px;
  font-size: 13.5px;
  font-weight: 600;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease,
    box-shadow 0.16s ease, transform 0.12s ease;
}

.primary-button {
  color: #fff;
  background: linear-gradient(135deg, #2782ff 0%, #1677ff 100%);
  border-color: var(--brand);
  box-shadow: 0 6px 14px rgba(22, 119, 255, 0.28);
}

.primary-button:hover {
  background: linear-gradient(135deg, #1677ff 0%, #0a5cdf 100%);
  box-shadow: 0 8px 20px rgba(22, 119, 255, 0.36);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(22, 119, 255, 0.3);
}

.ghost-button {
  color: var(--ink-2);
  background: var(--surface);
  border-color: var(--line-2);
}

.ghost-button:hover {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-50);
}

.text-button {
  color: var(--brand);
  background: transparent;
  padding: 0;
  min-height: auto;
  border: 0;
  font-weight: 600;
}

.text-button:hover {
  color: var(--brand-600);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-button {
  width: 38px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.icon-button:hover {
  color: var(--brand);
  background: var(--brand-50);
}

.compact {
  min-height: 36px;
  padding: 0 13px;
}

/* =========================================================================
   Views + cards
   ========================================================================= */
.view {
  display: none;
  animation: viewIn 0.32s ease;
}

.view.active {
  display: block;
}

@keyframes viewIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric-card,
.work-panel,
.detail-panel,
.course-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.metric-card {
  position: relative;
  min-height: 120px;
  padding: 20px 22px;
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.metric-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 16px;
  bottom: 16px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--accent, var(--brand));
}

.metric-card::after {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-soft, rgba(22, 119, 255, 0.12)), transparent 70%);
  pointer-events: none;
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--line-2);
}

.metrics-grid .metric-card:nth-child(1) {
  --accent: #1677ff;
  --accent-soft: rgba(22, 119, 255, 0.14);
}
.metrics-grid .metric-card:nth-child(2) {
  --accent: #2ba24c;
  --accent-soft: rgba(43, 162, 76, 0.14);
}
.metrics-grid .metric-card:nth-child(3) {
  --accent: #7c5cff;
  --accent-soft: rgba(124, 92, 255, 0.14);
}
.metrics-grid .metric-card:nth-child(4) {
  --accent: #e5484d;
  --accent-soft: rgba(229, 72, 77, 0.14);
}

.metric-card span,
.small-text {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.metric-card strong {
  display: block;
  margin: 10px 0 6px;
  font-size: 32px;
  font-weight: 760;
  line-height: 1;
  letter-spacing: -1px;
}

.metric-card small {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--success);
  font-size: 12px;
  font-weight: 600;
}

.metric-card.alert small {
  color: var(--danger);
}

/* analytics */
.analytics-panel {
  margin-bottom: 18px;
}

.chart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 264px;
  gap: 26px;
  align-items: stretch;
}

.bar-chart {
  min-height: 230px;
  display: grid;
  grid-template-columns: repeat(10, minmax(16px, 1fr));
  gap: 16px;
  align-items: end;
  padding: 18px 8px 0;
  border-bottom: 2px solid var(--line);
  background: repeating-linear-gradient(to top, transparent 0, transparent 47px, var(--line) 48px);
}

.bar-chart span {
  height: var(--bar);
  min-height: 30px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #7db8ff 0%, #1677ff 100%);
  box-shadow: 0 -2px 8px rgba(22, 119, 255, 0.2);
  transform-origin: bottom;
  animation: growBar 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition: filter 0.18s ease;
}

.bar-chart span:hover {
  filter: brightness(1.08) saturate(1.1);
}

.bar-chart span:nth-child(2) { animation-delay: 0.04s; }
.bar-chart span:nth-child(3) { animation-delay: 0.08s; }
.bar-chart span:nth-child(4) { animation-delay: 0.12s; }
.bar-chart span:nth-child(5) { animation-delay: 0.16s; }
.bar-chart span:nth-child(6) { animation-delay: 0.2s; }
.bar-chart span:nth-child(7) { animation-delay: 0.24s; }
.bar-chart span:nth-child(8) { animation-delay: 0.28s; }
.bar-chart span:nth-child(9) { animation-delay: 0.32s; }
.bar-chart span:nth-child(10) { animation-delay: 0.36s; }

@keyframes growBar {
  from {
    transform: scaleY(0);
    opacity: 0.4;
  }
  to {
    transform: scaleY(1);
    opacity: 1;
  }
}

.activity-list {
  display: grid;
  gap: 12px;
  align-content: start;
}

.activity-list div {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  transition: border-color 0.18s ease, background 0.18s ease;
}

.activity-list div:hover {
  border-color: var(--brand-100);
  background: var(--brand-50);
}

.activity-list strong {
  color: var(--brand);
  font-size: 23px;
  font-weight: 750;
  letter-spacing: -0.5px;
}

.activity-list span {
  color: var(--ink-2);
  font-size: 13px;
}

/* layout grids */
.dashboard-layout,
.finance-layout,
.profile-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.work-panel,
.detail-panel {
  padding: 20px;
}

.section-head,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-head h2 + p,
.toolbar h2 + p {
  margin-top: 3px;
}

/* lesson / refund / attendance rows */
.lesson-list,
.refund-list,
.attendance-board {
  display: grid;
  gap: 11px;
}

.lesson-row,
.refund-row,
.attendance-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.lesson-row:hover,
.refund-row:hover,
.attendance-row:hover {
  border-color: var(--brand-100);
  box-shadow: var(--shadow-sm);
}

.lesson-row strong,
.refund-row strong,
.attendance-row strong {
  font-size: 14.5px;
  font-weight: 700;
}

.lesson-meta,
.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.lesson-row > div:last-child {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

/* pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 23px;
  padding: 0 10px;
  border: 1px solid var(--success-line);
  border-radius: var(--r-pill);
  color: var(--success);
  background: var(--success-bg);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.pill.warn {
  border-color: var(--warn-line);
  color: var(--warn);
  background: var(--warn-bg);
}

.pill.hot {
  border-color: var(--danger-line);
  color: var(--danger);
  background: var(--danger-bg);
}

/* flow steps */
.flow-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.flow-step {
  position: relative;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  background: var(--surface-2);
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.flow-step:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  border-color: var(--brand-100);
}

.flow-step.active {
  border-color: var(--brand);
  background: var(--brand-50);
  color: var(--brand-700);
}

.flow-step.done {
  border-color: var(--success-line);
  background: var(--success-bg);
  color: var(--success);
}

.flow-step strong {
  font-size: 25px;
  font-weight: 760;
  letter-spacing: -0.5px;
  color: var(--ink);
}

.flow-step.active strong {
  color: var(--brand);
}

.flow-step.done strong {
  color: var(--success);
}

.rule-box {
  margin-top: 16px;
  padding: 14px 16px;
  border: 1px solid var(--brand-100);
  border-left: 4px solid var(--brand);
  border-radius: var(--r-sm);
  background: var(--brand-50);
}

.rule-box strong {
  display: block;
  color: var(--brand-700);
  font-size: 13px;
}

.rule-box span {
  display: block;
  margin-top: 5px;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.6;
}

/* =========================================================================
   Toolbar / segmented
   ========================================================================= */
.toolbar {
  min-height: 46px;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  gap: 2px;
}

.segment {
  min-height: 32px;
  border: 0;
  border-radius: var(--r-xs);
  padding: 0 14px;
  color: var(--ink-2);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  transition: color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.segment:hover {
  color: var(--brand);
}

.segment.active {
  color: var(--brand);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

/* =========================================================================
   Tables
   ========================================================================= */
.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}

.table-panel {
  overflow: hidden;
  padding: 0;
}

.table-panel:has(table) {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13.5px;
}

th {
  position: sticky;
  top: 0;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tr.selectable {
  cursor: pointer;
  transition: background 0.15s ease;
}

tr.selectable:hover {
  background: var(--surface-2);
}

tr.selectable.active-row {
  background: var(--brand-50);
  box-shadow: inset 3px 0 0 var(--brand);
}

.student-name,
.teacher-name {
  font-weight: 700;
  font-size: 14px;
}

/* detail panel */
.detail-panel {
  align-self: start;
  position: sticky;
  top: 90px;
}

.detail-panel h2 {
  margin-bottom: 14px;
  font-size: 17px;
}

.detail-list {
  display: grid;
  gap: 0;
}

.detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}

.detail-list div:last-child {
  border-bottom: 0;
}

.detail-list span {
  color: var(--muted);
  font-size: 13px;
}

.detail-list strong {
  font-weight: 700;
  font-size: 13.5px;
  text-align: right;
}

.detail-note {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.6;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

/* =========================================================================
   Courses
   ========================================================================= */
.course-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.course-card {
  padding: 20px;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.course-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--line-2);
}

.course-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.course-card > p {
  font-size: 12.5px;
}

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

.course-stats div,
.ledger div {
  padding: 12px 13px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.course-stats span,
.ledger span {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
}

.course-stats strong,
.ledger strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
  font-weight: 750;
  letter-spacing: -0.4px;
}

/* =========================================================================
   Attendance
   ========================================================================= */
.attendance-row {
  grid-template-columns: 1.4fr minmax(240px, 1fr) auto;
}

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

.status-button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.status-button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.status-button.active {
  color: #fff;
  background: linear-gradient(135deg, #2782ff, #1677ff);
  border-color: var(--brand);
  box-shadow: 0 4px 10px rgba(22, 119, 255, 0.28);
}

/* =========================================================================
   Ledger
   ========================================================================= */
.ledger {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

/* =========================================================================
   Calendar
   ========================================================================= */
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 14px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.calendar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.calendar-left-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.calendar-left-actions h2 {
  min-width: 124px;
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.4px;
  white-space: nowrap;
  text-align: center;
}

.calendar-arrow {
  color: var(--ink-2);
  font-size: 22px;
  line-height: 1;
}

.today-link {
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--r-xs);
  color: var(--brand);
  background: var(--brand-50);
}

.today-link:hover {
  text-decoration: none;
  background: var(--brand-100);
}

.calendar-search {
  width: 240px;
  height: 40px;
  padding-right: 0;
  overflow: hidden;
}

.calendar-search span {
  width: 52px;
  height: 100%;
  display: grid;
  place-items: center;
  margin: 0 -14px 0 0;
  color: #fff;
  background: linear-gradient(135deg, #2782ff, #1677ff);
}

.calendar-search .search-icon {
  width: 18px;
  height: 18px;
}

.view-switch {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  gap: 2px;
}

.view-switch button {
  width: 48px;
  min-height: 34px;
  border: 0;
  border-radius: var(--r-xs);
  color: var(--ink-2);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.view-switch button:hover {
  color: var(--brand);
}

.view-switch button.active {
  color: var(--brand);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.calendar-caption {
  margin-bottom: 14px;
}

.calendar-caption h2 {
  font-size: 16px;
}

.calendar-layout {
  display: block;
}

.calendar-panel {
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-2);
}

.weekday-row span {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
  border-right: 1px solid var(--line);
}

.weekday-row span:last-child {
  border-right: 0;
}

.calendar-day {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 100%;
  min-height: 122px;
  padding: 8px 9px 10px;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  transition: background 0.15s ease;
}

.calendar-grid > .calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-day:hover {
  background: var(--surface-2);
}

.calendar-day.muted {
  color: var(--muted-2);
  background: #fbfcfe;
}

.calendar-day.today {
  background: var(--brand-50);
}

.calendar-day.selected {
  background: var(--brand-50);
  box-shadow: inset 0 0 0 2px var(--brand);
}

.day-number {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.calendar-day.today .day-number {
  color: var(--brand);
  font-weight: 750;
}

.day-number span {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  color: #fff;
  background: var(--brand);
  font-size: 10.5px;
  font-weight: 700;
}

.calendar-event {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  margin-top: 5px;
  padding: 4px 8px;
  border: 0;
  border-radius: var(--r-xs);
  color: var(--brand-700);
  background: var(--brand-100);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.calendar-event::before {
  content: "";
  flex: 0 0 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
}

.calendar-event.trial {
  color: #1c7a34;
  background: var(--success-bg);
}
.calendar-event.trial::before {
  background: var(--success);
}

.calendar-event.substitute {
  color: #b5630a;
  background: var(--warn-bg);
}
.calendar-event.substitute::before {
  background: #fa8c16;
}

#dayDetail {
  margin-top: 18px;
  position: static;
}

.day-lessons {
  display: grid;
  gap: 11px;
  margin-top: 14px;
}

.day-lesson {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.day-lesson strong,
.day-lesson span {
  display: block;
}

.day-lesson strong {
  font-size: 14px;
  font-weight: 700;
}

.day-lesson span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.day-lesson .pill {
  margin-top: 8px;
}

/* =========================================================================
   Dialog / forms
   ========================================================================= */
dialog {
  width: min(680px, calc(100vw - 32px));
  border: 0;
  border-radius: var(--r-lg);
  padding: 0;
  box-shadow: var(--shadow-lg);
  animation: dialogIn 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

dialog::backdrop {
  background: rgba(13, 27, 48, 0.42);
  backdrop-filter: blur(3px);
}

.dialog-card {
  padding: 24px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h2 {
  font-size: 18px;
}

.dialog-head .icon-button {
  font-size: 20px;
  color: var(--muted);
}

.dialog-actions {
  padding-top: 4px;
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 18px;
  justify-content: flex-end;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

label.wide {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  padding: 11px 13px;
  color: var(--ink);
  background: var(--surface);
  font-weight: 400;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--brand);
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: var(--ring);
}

textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.6;
}

/* =========================================================================
   Toast
   ========================================================================= */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  transform: translateY(16px);
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 240px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 13px 16px;
  border-radius: var(--r-md);
  color: #fff;
  background: linear-gradient(135deg, #1f2a3a, #14202f);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.toast::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3ad17a;
  box-shadow: 0 0 0 4px rgba(58, 209, 122, 0.22);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* =========================================================================
   v13 additions — delete buttons, empty states, day/week views
   ========================================================================= */
.toolbar-spacer {
  flex: 0 0 auto;
}

/* danger / block buttons */
.ghost-button.danger {
  color: var(--danger);
  border-color: var(--danger-line);
  background: var(--danger-bg);
}

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

.ghost-button.block {
  width: 100%;
  margin-top: 10px;
}

/* small × delete on cards */
.card-del {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  min-height: 28px;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  border-radius: var(--r-xs);
}

.card-del:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

.course-card {
  position: relative;
}

.refund-row {
  position: relative;
}

.refund-side {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* empty states */
.empty-cell {
  text-align: center !important;
  color: var(--muted);
  padding: 28px 16px !important;
}

.empty-state {
  padding: 28px 16px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-sm);
  color: var(--muted);
  text-align: center;
  font-size: 13.5px;
  background: var(--surface-2);
}

.calendar-empty {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.calendar-event.muted-event {
  color: var(--muted);
  background: var(--surface-3);
}

.calendar-event.muted-event::before {
  background: var(--muted-2);
}

/* dialog hint */
.dialog-hint {
  margin: -6px 0 4px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.5;
}

/* week / day calendar modes */
.weekday-row.hide {
  display: none;
}

.calendar-grid.mode-day {
  grid-template-columns: 1fr;
}

.calendar-day.day-full {
  min-height: 360px;
  border-right: 0;
}

.calendar-grid.mode-week .calendar-day {
  min-height: 200px;
}

.login-form .login-hint + .primary-button {
  margin-top: 4px;
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .course-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .chart-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1080px) {
  .dashboard-layout,
  .finance-layout,
  .profile-layout,
  .split-layout,
  .calendar-layout {
    grid-template-columns: 1fr;
  }
  .detail-panel {
    position: static;
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 12;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    overflow-x: auto;
  }

  .brand {
    padding: 0;
    margin: 0;
    border-bottom: 0;
    flex: 0 0 auto;
  }

  .brand > div:last-child {
    display: none;
  }

  .nav-list {
    display: flex;
    gap: 4px;
    padding: 0;
    flex: 1;
  }

  .nav-item {
    width: auto;
    flex-direction: column;
    gap: 3px;
    height: auto;
    padding: 7px 12px;
    font-size: 11px;
    white-space: nowrap;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .search-box {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .main-area {
    padding: 0 16px 24px;
  }

  .topbar {
    margin: 0 -16px 20px;
    padding: 14px 16px;
  }

  .metrics-grid,
  .course-grid,
  .flow-steps,
  .ledger,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .section-head,
  .calendar-toolbar,
  .calendar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .calendar-left-actions {
    justify-content: center;
    flex-wrap: wrap;
  }

  .calendar-left-actions h2 {
    flex: 1;
    min-width: 0;
  }

  .attendance-row,
  .lesson-row,
  .refund-row {
    grid-template-columns: 1fr;
  }

  .attendance-actions {
    flex-wrap: wrap;
  }

  .calendar-panel {
    overflow-x: auto;
  }

  .weekday-row,
  .calendar-grid {
    min-width: 680px;
  }

  .calendar-day {
    min-height: 100px;
  }
}
