:root {
  --band-navy: #16324f;
  --band-navy-deep: #0d2238;
  --band-brass: #c4954f;
  --band-green: #367b67;
  --band-red: #b84c4c;
  --band-ink: #24313d;
  --band-muted: #6c7883;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--band-ink);
  background: #edf1f5;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
[hidden] { display: none !important; }

.loading-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  color: var(--band-navy);
  background: #f2f4f6;
}
.loading-screen i { margin-right: 10px; color: var(--band-brass); }

.login-page-native {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.15fr) minmax(420px, .85fr);
  background: #f1f4f7;
}
.login-hero {
  position: relative;
  display: flex;
  min-height: 100vh;
  align-items: flex-end;
  overflow: hidden;
  padding: clamp(40px, 7vw, 92px);
  color: #fff;
  background:
    radial-gradient(circle at 73% 22%, rgba(196,149,79,.3), transparent 18%),
    linear-gradient(150deg, #16324f 0%, #0b2135 72%);
}
.login-hero::before {
  position: absolute;
  top: 13%;
  right: -80px;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 50%;
  box-shadow: 0 0 0 50px rgba(255,255,255,.025), 0 0 0 100px rgba(255,255,255,.018);
  content: "";
}
.hero-copy { position: relative; z-index: 1; max-width: 660px; }
.hero-copy h1 { margin: 0 0 20px; font-size: clamp(38px, 6vw, 68px); font-weight: 800; letter-spacing: -.04em; line-height: 1.07; }
.hero-copy p { max-width: 560px; color: rgba(255,255,255,.67); font-size: 17px; line-height: 1.8; }
.music-staff { width: 145px; margin-bottom: 27px; }
.music-staff span { display: block; height: 1px; margin: 7px 0; background: rgba(196,149,79,.75); }
.kicker { margin-bottom: 4px; color: var(--band-brass); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.login-panel { display: grid; min-height: 100vh; place-items: center; padding: 38px; background: #fff; }
.login-card { width: min(420px, 100%); }
.login-card h2 { margin-bottom: 8px; color: var(--band-navy-deep); font-size: 28px; font-weight: 800; }
.login-card > p { margin-bottom: 28px; color: var(--band-muted); }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; color: var(--band-navy-deep); background: var(--band-brass); }

.app-shell { min-height: 100vh; }
.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1038;
  width: 250px;
  overflow-y: auto;
  color: #fff;
  background: linear-gradient(165deg, rgba(196,149,79,.1), transparent 38%), var(--band-navy-deep);
  box-shadow: 5px 0 24px rgba(12,31,50,.14);
  transition: transform 180ms ease;
}
.brand { display: flex; min-height: 72px; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .04em; }
.brand small { margin-top: 2px; color: rgba(255,255,255,.58); font-size: 11px; letter-spacing: .08em; }
.user-panel-native { margin: 16px 14px 10px; padding: 13px 12px; border-radius: 10px; color: #fff; background: rgba(255,255,255,.06); }
.user-panel-native .small { color: rgba(255,255,255,.56); }
.app-nav { padding: 8px 10px 24px; }
.nav-label { padding: 13px 12px 7px; color: rgba(255,255,255,.38); font-size: 11px; font-weight: 700; letter-spacing: .13em; }
.app-nav button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 12px;
  margin: 3px 0;
  padding: 11px 12px;
  border: 0;
  border-radius: 8px;
  color: rgba(255,255,255,.75);
  background: transparent;
  text-align: left;
}
.app-nav button i { width: 19px; color: rgba(255,255,255,.5); text-align: center; }
.app-nav button:hover, .app-nav button.active { color: #fff; background: rgba(255,255,255,.1); }
.app-nav button.active { box-shadow: inset 3px 0 0 var(--band-brass); }
.app-nav button.active i { color: var(--band-brass); }
.app-main { min-height: 100vh; margin-left: 250px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 1025;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  border-bottom: 1px solid #dfe5eb;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(12px);
}
.topbar h2 { margin: 0; font-size: 18px; font-weight: 700; }
.top-actions { display: flex; align-items: center; gap: 12px; color: var(--band-muted); font-size: 13px; }
.menu-toggle { display: none; border: 0; color: var(--band-navy); background: transparent; font-size: 20px; }
.content-area { width: 100%; max-width: 1540px; margin: 0 auto; padding: 26px; }
.page-heading { margin-bottom: 22px; }
.page-heading h1 { margin: 0; color: var(--band-navy-deep); font-size: clamp(24px,3vw,34px); font-weight: 800; }
.page-heading p { margin: 7px 0 0; color: var(--band-muted); }

.app-card { margin-bottom: 20px; border: 0; border-radius: 14px; background: #fff; box-shadow: 0 8px 25px rgba(27,51,75,.07); }
.app-card-header { display: flex; min-height: 60px; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid #edf0f3; }
.app-card-header h3 { margin: 0; color: var(--band-navy-deep); font-size: 16px; font-weight: 800; }
.app-card-body { padding: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 18px; margin-bottom: 20px; }
.stat-card { position: relative; min-height: 126px; overflow: hidden; padding: 21px; border-radius: 14px; background: #fff; box-shadow: 0 8px 25px rgba(27,51,75,.07); }
.stat-card::after { position: absolute; inset: auto 0 0; height: 4px; background: var(--accent,var(--band-brass)); content: ""; }
.stat-card strong { display: block; color: var(--band-navy-deep); font-size: 30px; }
.stat-card span { color: var(--band-muted); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.form-label { display: block; margin-bottom: 6px; color: #56616c; font-size: 12px; font-weight: 800; }
.form-control, .custom-select { min-height: 40px; border-color: #d8dee4; border-radius: 8px; }
.emergency-phone-heading { display: flex; min-height: 22px; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.same-phone-check { margin: 0; color: var(--band-muted); font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.same-phone-check input { margin-right: 4px; vertical-align: -1px; }
.form-control[readonly] { background: #f1f4f6; color: #53606b; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.student-search-field { flex: 1 1 300px; }
.student-search-field .form-control { width: 100%; }
.table-wrap { overflow-x: auto; }
.table { margin-bottom: 0; }
.table th { border-top: 0; color: #75808a; font-size: 12px; font-weight: 800; white-space: nowrap; }
.table td { vertical-align: middle; }
.empty { padding: 42px 20px; color: var(--band-muted); text-align: center; }
.empty i { display: block; margin-bottom: 11px; color: #bac3cb; font-size: 30px; }
.badge-soft { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge-soft.green { color: #28705a; background: #e6f4ef; }
.badge-soft.amber { color: #9a6824; background: #fbf0de; }
.badge-soft.red { color: #a63e3e; background: #f8e6e6; }
.badge-soft.blue { color: #315f85; background: #e7eff7; }
.badge-soft.gray { color: #65717d; background: #edf0f2; }
.secret-panel { padding: 18px; border: 1px solid #e9d4ad; border-radius: 12px; background: #fff8e9; }
.secret-panel code { word-break: break-all; }
.qr-image { width: 200px; height: 200px; padding: 8px; background: #fff; }
.scanner { overflow: hidden; margin-bottom: 14px; border-radius: 12px; background: #0f1d29; }
.scanner video { display: block; width: 100%; max-height: 340px; object-fit: cover; }
.app-toast { position: fixed; right: 22px; bottom: 22px; z-index: 2000; width: min(420px,calc(100vw - 44px)); padding: 15px 17px; border-radius: 11px; color: #fff; background: #142b40; box-shadow: 0 14px 38px rgba(0,0,0,.24); }
.sidebar-overlay { display: none; }

@media (max-width: 991px) {
  .login-page-native { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .menu-toggle { display: inline-block; }
  .sidebar-overlay { position: fixed; inset: 0; z-index: 1030; display: block; border: 0; background: rgba(8,23,36,.45); }
  .form-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .span-3 { grid-column: span 2; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 575px) {
  .login-panel { padding: 24px; }
  .topbar, .content-area { padding-right: 16px; padding-left: 16px; }
  #today-label { display: none; }
  .form-grid, .stats-grid { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
}
@media print {
  .app-sidebar, .topbar, .no-print, .page-heading { display: none !important; }
  .app-main { margin: 0; }
  .content-area { max-width: none; padding: 0; }
  .app-card, .stat-card { box-shadow: none; }
}
