/* ── Piano Studio Theme ─────────────────────────────────────────────────────── */
:root {
  --black:   #0d0d0d;
  --ivory:   #f5f5f0;
  --gold:    #c9a227;
  --text:    #1a1a1a;
  --muted:   #6c757d;
  --ok:      #198754;
  --owed:    #dc3545;
  --hdr:     56px;
  --nav:     64px;
  --radius:  14px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--ivory);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
.app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--hdr);
  background: var(--black);
  color: #fff;
  z-index: 200;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}
.header-inner {
  display: flex; align-items: center; height: 100%;
  padding: 0 16px; gap: 10px;
}
.back-btn {
  background: none; border: none; color: #fff; font-size: 20px;
  padding: 4px 8px 4px 0; cursor: pointer; flex-shrink: 0; line-height: 1;
}
.header-title {
  flex: 1; font-size: 18px; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.header-actions { display: flex; gap: 8px; }

/* ── Main ────────────────────────────────────────────────────────────────────── */
.app-main {
  position: fixed;
  top: var(--hdr); bottom: var(--nav);
  left: 0; right: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.page-content {
  max-width: 640px; margin: 0 auto;
  padding: 16px 14px 100px;
}

/* ── Bottom nav ──────────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav);
  background: #fff;
  display: flex;
  border-top: 1px solid #e5e5e5;
  box-shadow: 0 -2px 16px rgba(0,0,0,.08);
  z-index: 200;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; background: none; border: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: #aaa; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.nav-btn i { font-size: 22px; }
.nav-btn.active { color: var(--black); }

/* ── Stats ───────────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 10px; margin-bottom: 24px;
}
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 16px 10px; text-align: center;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  transition: transform .1s;
}
.stat-card:active { transform: scale(.97); }
.stat-icon { font-size: 22px; color: var(--muted); margin-bottom: 4px; }
.stat-number { font-size: 22px; font-weight: 800; line-height: 1.1; }
.stat-label  { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-top: 3px; }
.stat-danger .stat-number { color: var(--owed); }
.stat-ok     .stat-number { color: var(--ok); }

/* ── Section header ──────────────────────────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.section-title { font-size: 15px; font-weight: 700; }

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; color: var(--muted); padding: 32px 0; margin: 0;
}

/* ── Student card ────────────────────────────────────────────────────────────── */
.student-card {
  background: #fff; border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; gap: 14px;
  margin-bottom: 8px; cursor: pointer;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
  transition: transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.student-card:active { transform: scale(.98); }

.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--black); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; flex-shrink: 0;
}
.avatar-lg { width: 72px; height: 72px; font-size: 30px; }

.student-info { flex: 1; min-width: 0; }
.student-name { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.student-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }

.balance-chip { font-weight: 700; font-size: 15px; flex-shrink: 0; }
.balance-owed { color: var(--owed); }
.balance-ok   { color: var(--ok); }

/* ── Profile card ────────────────────────────────────────────────────────────── */
.profile-card {
  background: var(--black); color: #fff;
  border-radius: 20px; padding: 28px 24px 20px;
  text-align: center; margin-bottom: 14px;
}
.profile-name   { font-size: 24px; font-weight: 800; margin: 12px 0 6px; }
.profile-badges { margin-bottom: 10px; }
.profile-contact {
  display: block; color: rgba(255,255,255,.8); font-size: 14px;
  text-decoration: none; margin-top: 5px;
}
.profile-contact:hover { color: #fff; }
.profile-notes {
  font-size: 13px; color: rgba(255,255,255,.6); margin-top: 12px;
  padding-top: 12px; border-top: 1px solid rgba(255,255,255,.15);
}

/* ── Balance banner ──────────────────────────────────────────────────────────── */
.balance-banner {
  border-radius: var(--radius); padding: 20px;
  text-align: center; color: #fff; margin-bottom: 18px;
}
.balance-banner-owed { background: linear-gradient(135deg, #dc3545, #b02a37); }
.balance-banner-ok   { background: linear-gradient(135deg, #198754, #146c43); }
.bb-label  { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; opacity: .85; }
.bb-amount { font-size: 40px; font-weight: 800; line-height: 1.1; margin: 4px 0; }
.bb-sub    { font-size: 14px; opacity: .85; margin-bottom: 10px; }
.bb-meta   {
  display: flex; justify-content: center; gap: 16px;
  font-size: 12px; opacity: .7;
  border-top: 1px solid rgba(255,255,255,.2); padding-top: 8px;
}

/* ── Tabs ────────────────────────────────────────────────────────────────────── */
.nav-tabs { border-bottom: 2px solid #dee2e6; margin-bottom: 0; }
.nav-tabs .nav-link { color: var(--muted); font-weight: 600; border: none; padding: 10px 0; }
.nav-tabs .nav-link.active { color: var(--black); border-bottom: 2px solid var(--black); background: none; }
.tab-panel { padding-top: 10px; }

/* ── Lesson card ─────────────────────────────────────────────────────────────── */
.lesson-card {
  background: #fff; border-radius: var(--radius);
  padding: 13px 14px; display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px; border-left: 4px solid #dee2e6;
  box-shadow: 0 1px 6px rgba(0,0,0,.05);
}
.lesson-card.attended { border-left-color: var(--ok); background: #f4fbf4; }
.lesson-card.past     { opacity: .7; }

.lesson-body    { flex: 1; min-width: 0; }
.lesson-student { font-weight: 700; font-size: 15px; cursor: pointer; color: var(--black); }
.lesson-student:hover { text-decoration: underline; }
.lesson-time    { font-size: 13px; color: var(--muted); margin-top: 2px; }
.lesson-notes   { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.lesson-controls { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.attend-badge {
  font-size: 11px; font-weight: 700;
  padding: 4px 10px; border-radius: 20px;
  white-space: nowrap; flex-shrink: 0;
}
.attend-badge.attended { background: var(--ok);   color: #fff; }
.attend-badge.absent   { background: var(--owed); color: #fff; }
.attend-badge.upcoming { background: #e9ecef;     color: var(--muted); }

.attend-btn {
  background: none; border: none; padding: 2px; cursor: pointer;
  font-size: 28px; color: #ced4da; line-height: 1;
  transition: color .15s; -webkit-tap-highlight-color: transparent;
}
.attend-btn.on { color: var(--ok); }
.attend-btn:not(.on):hover { color: #adb5bd; }

.icon-del {
  background: none; border: none; color: #ced4da; cursor: pointer;
  padding: 4px; font-size: 14px; transition: color .15s; line-height: 1;
}
.icon-del:hover { color: var(--owed); }

/* ── Payment card ────────────────────────────────────────────────────────────── */
.payment-card {
  background: #fff; border-radius: var(--radius);
  padding: 13px 14px; display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px; box-shadow: 0 1px 6px rgba(0,0,0,.05);
}
.payment-body    { flex: 1; min-width: 0; }
.payment-student { font-weight: 700; font-size: 15px; }
.payment-meta    { font-size: 13px; color: var(--muted); margin-top: 3px; }
.payment-notes   { font-size: 12px; color: var(--muted); margin-top: 3px; }
.payment-right   { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; }
.payment-amount  { font-size: 20px; font-weight: 800; color: var(--ok); }

/* ── Search ──────────────────────────────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input { padding-left: 36px; border-radius: 12px; border-color: #e5e5e5; }
.search-input:focus { box-shadow: none; border-color: var(--black); }

/* ── Segment control ─────────────────────────────────────────────────────────── */
.seg-control {
  display: flex; background: #fff; border-radius: 12px;
  padding: 4px; box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.seg-btn {
  flex: 1; background: none; border: none; padding: 8px;
  border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s, color .15s; color: var(--muted);
}
.seg-btn.active { background: var(--black); color: #fff; }

/* ── FABs ────────────────────────────────────────────────────────────────────── */
.fab-group {
  position: fixed;
  bottom: calc(var(--nav) + 16px); right: 16px;
  display: flex; flex-direction: column-reverse; gap: 10px; z-index: 150;
}
.fab {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--black); color: #fff; border: none;
  font-size: 22px; cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,.28);
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
}
.fab:active { transform: scale(.92); box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.fab-sm { width: 46px; height: 46px; font-size: 18px; background: var(--gold); }

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.skill-badge-beginner     { background: #198754; color: #fff; }
.skill-badge-intermediate { background: #fd7e14; color: #fff; }
.skill-badge-advanced     { background: #dc3545; color: #fff; }
.method-cash      { background: #198754; color: #fff; }
.method-etransfer { background: #0d6efd; color: #fff; }

/* ── Modals ──────────────────────────────────────────────────────────────────── */
.modal-content  { border-radius: 20px; border: none; box-shadow: 0 12px 48px rgba(0,0,0,.18); }
.modal-header   { padding: 20px 24px 14px; border-bottom-color: #f0f0f0; }
.modal-footer   { padding: 14px 24px 20px; border-top-color: #f0f0f0; }
.modal-body     { padding: 16px 24px; }

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* ── Calendar ────────────────────────────────────────────────────────────────── */
.cal-page {
  display: flex; flex-direction: column;
  height: 100%; overflow: hidden;
}
.cal-nav {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; background: var(--ivory);
  border-bottom: 1px solid #e5e5e5; flex-shrink: 0;
}
.cal-week-label { flex: 1; text-align: center; font-size: 14px; font-weight: 600; }

.cal-scroll {
  flex: 1; overflow-y: auto; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.cal-grid {
  display: grid;
  grid-template-columns: 44px repeat(7, minmax(80px, 1fr));
  grid-template-rows: auto 1fr;
  min-width: 600px;
  background: white;
}

/* Header row */
.cal-time-gutter {
  background: white;
  border-bottom: 2px solid #e5e5e5;
  position: sticky; top: 0; z-index: 20;
}
.cal-day-head {
  text-align: center; padding: 8px 4px;
  border-bottom: 2px solid #e5e5e5;
  border-left: 1px solid #f0f0f0;
  font-size: 12px;
  position: sticky; top: 0; background: white; z-index: 20;
}
.cal-day-name { color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.cal-day-num  { font-size: 18px; font-weight: 700; line-height: 1.2; }
.cal-today-head .cal-day-name { color: var(--gold); }
.cal-today-num  { color: var(--gold); }

/* Time column */
.cal-time-col {
  grid-row: 2; grid-column: 1;
  padding-top: 0;
}
.cal-time-label {
  height: 88px; /* 2 slots */
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding-right: 6px; padding-top: 0;
  font-size: 10px; color: var(--muted);
  transform: translateY(-6px);
}

/* Day columns */
.cal-day-col {
  grid-row: 2;
  position: relative;
  height: calc(44px * 26); /* NUM_SLOTS slots: 9AM–10PM */
  border-left: 1px solid #f0f0f0;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px, transparent 43px,
    #f0f0f0 43px, #f0f0f0 44px
  );
}
.cal-today-col { background-color: rgba(201,162,39,.04); }

/* Lesson block */
.cal-lesson {
  position: absolute; left: 2px; right: 2px;
  border-radius: 6px;
  background: var(--black); color: white;
  padding: 3px 5px;
  font-size: 11px; overflow: hidden;
  cursor: pointer;
  border: 1.5px solid rgba(255,255,255,.15);
  transition: opacity .1s;
}
.cal-lesson:hover { opacity: .88; }
.cal-lesson.attended { background: var(--ok); }
.cal-lesson-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-lesson-time { opacity: .8; font-size: 10px; }

/* Drag selection */
.cal-sel {
  position: absolute; left: 2px; right: 2px;
  background: rgba(201,162,39,.25);
  border: 2px solid var(--gold);
  border-radius: 6px;
  pointer-events: none; z-index: 5;
}

/* Now indicator */
.cal-now-line {
  position: absolute;
  left: 0; right: 0; height: 2px;
  background: var(--owed);
  pointer-events: none; z-index: 10;
  grid-row: 2;
}
.cal-now-line::before {
  content: ''; position: absolute;
  left: -4px; top: -4px;
  width: 10px; height: 10px;
  border-radius: 50%; background: var(--owed);
}

/* ── Payment top row ─────────────────────────────────────────────────────────── */
.pay-top-row {
  display: flex; align-items: center; gap: 10px;
}
.pay-top-row .seg-control { flex-shrink: 0; }
.pay-student-filter {
  flex: 1; border-radius: 10px; border-color: #e5e5e5;
  font-size: 13px;
}
.pay-student-filter:focus { box-shadow: none; border-color: var(--black); }

/* ── Payment period nav ──────────────────────────────────────────────────────── */
.period-nav {
  display: flex; align-items: center; justify-content: space-between;
  background: white; border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.period-nav-btn {
  background: none; border: none; cursor: pointer;
  font-size: 18px; color: var(--text); padding: 2px 8px;
  border-radius: 8px; transition: background .15s;
}
.period-nav-btn:hover { background: #f0f0f0; }
.period-nav-center { display: flex; align-items: center; }
.period-label { font-size: 16px; font-weight: 700; }
.period-today { font-size: 12px; color: var(--muted); text-decoration: none; }
.period-today:hover { color: var(--text); }

/* ── Payment summary card ────────────────────────────────────────────────────── */
.payment-summary {
  background: var(--black); color: white;
  border-radius: var(--radius); padding: 20px;
  text-align: center;
}
.psum-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; opacity: .7; }
.psum-total { font-size: 38px; font-weight: 800; line-height: 1.1; margin: 4px 0 10px; }
.psum-breakdown {
  display: flex; justify-content: center; gap: 20px;
  font-size: 13px; opacity: .75;
  border-top: 1px solid rgba(255,255,255,.15); padding-top: 10px;
}

/* ── Yearly grid ─────────────────────────────────────────────────────────────── */
.ygrid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.ygrid-cell {
  background: white; border-radius: 10px; padding: 10px 6px;
  text-align: center; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: transform .1s;
  border-bottom: 3px solid transparent;
}
.ygrid-cell:active { transform: scale(.96); }
.ygrid-cell.has-data { border-bottom-color: var(--ok); }
.ygrid-month  { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.ygrid-amount { font-size: 12px; font-weight: 700; margin-top: 4px; color: var(--text); }
.ygrid-cell.has-data .ygrid-amount { color: var(--ok); }

/* ── Settings gear ───────────────────────────────────────────────────────────── */
.settings-btn {
  background: none; border: none;
  color: rgba(255,255,255,.65); font-size: 18px;
  padding: 4px 2px 4px 10px; cursor: pointer; flex-shrink: 0;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.settings-btn:hover { color: #fff; }

/* ── Settings view ───────────────────────────────────────────────────────────── */
.settings-section {
  background: #fff; border-radius: var(--radius);
  padding: 20px; margin-bottom: 14px;
  box-shadow: 0 1px 6px rgba(0,0,0,.06);
}
.settings-title {
  font-size: 15px; font-weight: 700;
  margin-bottom: 16px;
}
.sync-ts { font-size: 13px; color: var(--muted); margin-bottom: 5px; }

/* ── Desktop ─────────────────────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .page-content { padding-top: 24px; }
  .stats-grid { gap: 16px; }
}
