:root {
  --coral: #ea7066;
  --coral-dark: #d65a50;
  --green: #b5d56a;
  --blue: #84bed6;
  --purple: #a597e7;
  --yellow: #f0c24b;
  --text: #212529;
  --muted: #6c757d;
  --bg: #f5f5f5;
  --line: #dee2e6;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: "Open Sans", sans-serif; color: var(--text); background: var(--bg); font-size: 15px; }
h1, h2, h3, legend, .btn, th { font-family: "Dosis", sans-serif; }
h1, h2 { font-weight: 700; letter-spacing: .5px; }
a { color: var(--coral); }
[hidden] { display: none !important; }

/* header */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: #fff; border-bottom: 4px solid var(--coral); }
.topbar img { height: 48px; }
.topbar .brand { font-family: "Dosis", sans-serif; font-weight: 700; font-size: 20px; color: var(--coral); text-transform: uppercase; }
.topbar .brand small { display: block; color: var(--muted); font-size: 12px; letter-spacing: 1px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--muted); font-size: 13px; }

main { max-width: 1150px; margin: 24px auto; padding: 0 16px; }

/* buttons + inputs */
.btn { display: inline-block; border: 0; border-radius: 30px; padding: 9px 22px; font-size: 15px; font-weight: 600; text-transform: uppercase; cursor: pointer; text-decoration: none; background: var(--coral); color: #fff; }
.btn:hover { background: var(--coral-dark); }
.btn.secondary { background: #fff; color: var(--coral); border: 2px solid var(--coral); }
.btn.small { padding: 4px 12px; font-size: 13px; }
.btn.danger { background: #c0392b; }
.btn:disabled { opacity: .6; cursor: wait; }

input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: var(--blue); }
input:disabled, select:disabled, textarea:disabled { background: #f8f9fa; color: var(--text); }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; }
.req { color: var(--coral); }

.msg { padding: 10px 14px; border-radius: 6px; margin: 12px 0; }
.msg.error { background: #fdecea; color: #a12d22; }
.msg.ok { background: #eef6dc; color: #4a6417; }

/* login */
.login { max-width: 380px; margin: 60px auto; background: #fff; padding: 32px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.08); text-align: center; border-top: 5px solid var(--coral); }
.login img { width: 140px; }
.login form { text-align: left; display: grid; gap: 14px; margin-top: 16px; }
.login .btn { width: 100%; }

/* dashboard */
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.head > div { display: flex; flex-wrap: wrap; gap: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin: 20px 0; }
.stat { background: #fff; border-radius: 10px; padding: 16px 20px; border-left: 6px solid var(--coral); }
.stat:nth-child(2) { border-color: var(--green); }
.stat:nth-child(3) { border-color: var(--blue); }
.stat:nth-child(4) { border-color: var(--purple); }
.stat b { display: block; font-family: "Dosis", sans-serif; font-size: 28px; }
.stat span { color: var(--muted); font-size: 13px; }

.filters { display: flex; gap: 10px; margin-bottom: 12px; }
.filters input { flex: 1; }
.filters select { width: 180px; }

.table-wrap { clear: both; overflow-x: auto; background: #fff; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--coral); color: #fff; font-weight: 600; letter-spacing: .5px; }
tr:hover td { background: #fff7f6; }
td.num { text-align: right; }
.badge { padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.active { background: #eef6dc; color: #4a6417; }
.badge.completed { background: #e3f1f7; color: #2d6a83; }
.badge.discontinued { background: #eee; color: #666; }

/* student form */
fieldset { min-width: 0; background: #fff; border: 0; border-radius: 10px; padding: 18px 20px; margin: 0 0 18px; border-top: 4px solid var(--blue); }
fieldset:nth-of-type(2) { border-color: var(--green); }
fieldset:nth-of-type(3) { border-color: var(--purple); }
fieldset:nth-of-type(4) { border-color: var(--yellow); }
fieldset:nth-of-type(5) { border-color: var(--coral); }
legend { float: left; width: 100%; font-size: 18px; font-weight: 700; color: var(--coral); margin-bottom: 12px; padding: 0; }
.grid { clear: both; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.grid .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-bottom: 40px; }

.docs { list-style: none; padding: 0; margin: 0 0 12px; clear: both; }
.docs li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.docs li span { flex: 1; }
.docs li em { color: var(--muted); font-size: 12px; font-style: normal; }
.upload-row { display: grid; grid-template-columns: 200px 1fr; gap: 10px; margin-bottom: 8px; }

@media (max-width: 600px) {
  .topbar { padding: 8px 12px; }
  .topbar .brand small, .topbar .who { display: none; }
  .filters { flex-direction: column; }
  .filters select { width: 100%; }
  .upload-row { grid-template-columns: 1fr; }
  h1 { font-size: 26px; margin: 8px 0; }
  input, select, textarea { font-size: 16px; }  /* < 16px makes iOS zoom on focus */
  .btn.small { padding: 7px 14px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat b { font-size: 22px; }

  /* tables become one card per row */
  table.cards thead { display: none; }
  table.cards tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.cards td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; white-space: normal; text-align: right; }
  table.cards td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; flex-shrink: 0; }
  table.cards td.title { font-family: "Dosis", sans-serif; font-size: 17px; font-weight: 700; }
  table.cards td.wrap { display: block; text-align: left; min-width: 0; }
  table.cards td.wrap::before { display: block; }
  table.cards td.row-actions { justify-content: flex-end; gap: 8px; padding-top: 8px; }
  table.cards td.row-actions:empty { display: none; }
  tr:hover td { background: none; }
}

/* payments + history */
.summary { clear: both; margin: 0 0 12px; font-size: 16px; }
.summary .over { color: #a12d22; }
.pay-form { margin-top: 16px; align-items: end; }
.history { list-style: none; padding: 0; margin: 0; clear: both; max-height: 420px; overflow-y: auto; }
.history li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.history em { color: var(--muted); font-size: 12px; font-style: normal; }
td.wrap { white-space: normal; min-width: 260px; }

/* users page */
.grid .end { display: flex; align-items: flex-end; }
.hint { clear: both; color: var(--muted); font-size: 13px; margin: 12px 0 0; }
td select { width: auto; padding: 4px 8px; }
td .name-input { width: 190px; padding: 4px 8px; }
tr.editing td { background: #fff7f6; }
