:root {
  --ink: #24303f;
  --muted: #667085;
  --line: #dde4ee;
  --paper: #ffffff;
  --wash: #f5f7fb;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --warm: #f59e0b;
  --danger: #c2410c;
  --shadow: 0 18px 50px rgba(31, 41, 55, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #eef7f5 0, #f8fafc 360px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration: none;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 56px;
}

.hero {
  min-height: 410px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: 28px;
  align-items: center;
  padding: 54px 0 28px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: 58px;
}

h2 {
  font-size: 30px;
}

h3 {
  font-size: 19px;
}

.hero-text {
  max-width: 680px;
  margin: 18px 0 26px;
  color: var(--muted);
  font-size: 18px;
}

.hero-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.button:hover {
  background: var(--accent-dark);
}

.button.ghost {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--line);
}

.button.compact {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 14px;
  white-space: nowrap;
}

.button.danger {
  background: var(--danger);
}

.button:disabled {
  cursor: not-allowed;
  background: #cbd5e1;
  color: #475569;
}

.hero-panel,
.card,
.login-box,
.admin-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  gap: 12px;
  padding: 24px;
}

.hero-panel span,
.hint,
.empty,
small {
  color: var(--muted);
}

.section,
.admin-section {
  padding: 30px 0;
}

.section-heading {
  margin-bottom: 18px;
}

.course-grid,
.teacher-grid {
  display: grid;
  gap: 18px;
}

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

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

.card {
  padding: 22px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.tag.tag-foreign { background: #eff6ff; color: #1d4ed8; }
.tag.tag-local   { background: #fdf4ff; color: #7e22ce; }

.tag,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 8px;
  background: #ecfdf5;
  color: var(--accent);
  font-size: 13px;
  font-weight: 750;
}

.status {
  background: #fff7ed;
  color: #9a3412;
  white-space: nowrap;
}

.details {
  display: grid;
  gap: 10px;
  margin: 0;
}

.details div {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
}

.goal {
  margin: 14px 0;
  color: var(--muted);
}

.slot-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

/* New slot card layout */
.slot-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.slot-head {
  display: grid;
  gap: 3px;
}

.slot-sub {
  color: var(--muted);
  font-size: 14px;
}

/* Enrollment status block */
.enroll-stat {
  padding: 10px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  display: grid;
  gap: 8px;
}

.enroll-bar {
  height: 7px;
  background: #d1fae5;
  border-radius: 999px;
  overflow: hidden;
}

.enroll-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.enroll-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
}

.enroll-gap {
  color: #b45309;
  font-weight: 750;
}

.enroll-ok {
  color: var(--accent);
  font-weight: 750;
}

/* Full-width toggle button */
.slot-toggle {
  width: 100%;
  min-height: 44px;
  font-size: 15px;
}

/* Inline form inside hidden div */
.slot-card .inline-form {
  margin-top: 2px;
}

/* Legacy slot-row kept for compatibility */
.slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px;
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.slot-row div {
  display: grid;
  gap: 2px;
}

.inline-form,
.stack-form,
.mini-form {
  display: grid;
  gap: 12px;
}

.inline-form {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
}

.fee-total {
  margin: 0;
  font-size: 0.95rem;
  color: #333;
}

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

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

textarea {
  resize: vertical;
}

.flash-wrap {
  width: min(1180px, calc(100% - 32px));
  margin: 18px auto 0;
}

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}

.flash.success {
  border-color: #99f6e4;
  background: #f0fdfa;
}

.flash.error {
  border-color: #fed7aa;
  background: #fff7ed;
}

.flash.info {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.login-box {
  width: min(440px, 100%);
  margin: 80px auto;
  padding: 26px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 34px 0 20px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

/* ── Tabs ── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--line);
  margin-bottom: 24px;
  overflow-x: auto;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn:hover:not(.active) {
  color: var(--ink);
  background: var(--wash);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.tab-btn.active .tab-count {
  background: #ccfbf1;
  color: var(--accent);
}

/* ── Panel layout ── */
.panel-head {
  margin-bottom: 12px;
}

/* ── Add form (details toggle) ── */
.add-details > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 750;
  user-select: none;
}

.add-details > summary::-webkit-details-marker { display: none; }

.add-details > summary:hover {
  background: var(--accent-dark);
}

.add-details[open] > summary {
  margin-bottom: 12px;
}

.add-details .add-form {
  display: grid;
  gap: 12px;
  padding: 18px;
}

/* ── Item list ── */
.item-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.item-details {
  border-bottom: 1px solid var(--line);
}

.item-details:last-child {
  border-bottom: 0;
}

.item-details > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.item-details > summary::-webkit-details-marker { display: none; }

.item-details > summary:hover {
  background: var(--wash);
}

.item-details[open] > summary {
  background: var(--wash);
  border-bottom: 1px solid var(--line);
}

.item-order {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  min-width: 28px;
}

.item-name {
  flex: 1;
  font-weight: 650;
  font-size: 15px;
}

.item-meta {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.item-caret {
  color: var(--muted);
  font-size: 12px;
  margin-left: 4px;
  white-space: nowrap;
}

.item-form {
  padding: 16px 18px;
  display: grid;
  gap: 12px;
}

.admin-card {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  padding: 18px;
}

.empty.pad {
  padding: 16px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 820px) {
  main {
    width: min(100% - 22px, 1180px);
  }

  h1 {
    font-size: 36px;
  }

  h2 {
    font-size: 24px;
  }

  h3 {
    font-size: 18px;
  }

  .hero,
  .course-grid,
  .teacher-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding-top: 36px;
  }

  .hero-text {
    font-size: 16px;
  }

  .slot-row,
  .admin-header {
    align-items: stretch;
    flex-direction: column;
  }

  .tab-bar {
    gap: 0;
  }

  .tab-btn {
    padding: 9px 12px;
    font-size: 13px;
  }

  .item-details > summary {
    flex-wrap: wrap;
  }

  .item-meta {
    display: none;
  }

  .button.compact {
    width: 100%;
  }

  .hero-actions .button,
  .admin-actions,
  .admin-actions .button {
    width: 100%;
  }

  .details div {
    grid-template-columns: 1fr;
  }

  .card,
  .admin-card {
    padding: 16px;
  }

  .login-box {
    margin: 36px auto;
  }

  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .admin-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 12px;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
    width: 100%;
  }

  .admin-table tr {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  .admin-table td {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid #eef2f7;
  }

  .admin-table td:last-child {
    border-bottom: 0;
  }

  .admin-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
  }
}

@media (max-width: 430px) {
  main,
  .flash-wrap {
    width: min(100% - 18px, 1180px);
  }

  h1 {
    font-size: 32px;
  }

  .hero {
    padding-top: 26px;
  }

  .slot-row {
    padding: 11px;
  }

  .admin-table td {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
