/* iPad 預約系統 —— 版面
   色票與字體來自 theme.css（柑園設計 token） */

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-sans, system-ui, sans-serif);
    background: var(--bg-alt, #F3F3F3);
    color: var(--fg1, #1A1A1A);
    -webkit-text-size-adjust: 100%;
}

a { color: inherit; }

/* ── 頂列 ──────────────────────────────────────────────── */
.topbar {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    background: var(--gy-black, #0B0B0B); color: #fff;
    padding: 10px 16px; position: sticky; top: 0; z-index: 20;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 18px; }
.topbar .brand img { height: 26px; width: auto; }
.topbar nav { margin-left: auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 14px; }
.topbar nav a { text-decoration: none; opacity: .85; }
.topbar nav a:hover { opacity: 1; text-decoration: underline; }
.topbar .who { opacity: .7; }
.topbar .who em { font-style: normal; opacity: .6; margin-left: 4px; font-size: 12px; }
.topbar .logout { border: 1px solid rgba(255,255,255,.3); padding: 3px 10px; border-radius: 99px; }

/* ── 容器 ──────────────────────────────────────────────── */
.wrap { max-width: 960px; margin: 0 auto; padding: 20px 16px 64px; }
.card {
    background: var(--surface, #fff); border: 1px solid var(--border, #E8E8E8);
    border-radius: 10px; padding: 18px; margin-bottom: 18px;
}
.card h2 { margin: 0 0 12px; font-size: 19px; font-weight: 900; }
.card h2 + p { margin-top: -6px; }
.hint { color: var(--fg3, #8A8A8A); font-size: 13px; line-height: 1.7; margin: 8px 0 0; }
.muted { color: var(--fg3, #8A8A8A); }

.notice {
    background: var(--gy-orange-50, #FDF2EB); border-left: 5px solid var(--accent, #DD561C);
    padding: 10px 14px; border-radius: 4px; margin-bottom: 18px; font-size: 14px;
}
.alert { background: #EEF6EE; border-left: 5px solid #3C8C4A; padding: 10px 14px;
    border-radius: 4px; margin-bottom: 18px; font-size: 14px; }
.alert.error { background: #FDECEA; border-color: #C0392B; color: #8E2A20; }

/* ── 按鈕 ──────────────────────────────────────────────── */
.btn {
    display: inline-block; border: 1px solid var(--border-strong, #B5B5B5);
    background: #fff; color: var(--fg1, #1A1A1A); border-radius: 6px;
    padding: 7px 14px; font-size: 14px; font-weight: 700; cursor: pointer;
    text-decoration: none; font-family: inherit; line-height: 1.4;
}
.btn:hover { border-color: var(--accent, #DD561C); color: var(--accent, #DD561C); }
.btn-primary { background: var(--accent, #DD561C); border-color: var(--accent, #DD561C); color: #fff; }
.btn-primary:hover { background: var(--gy-orange-600, #C24812); color: #fff; }
.btn-danger:hover { border-color: #C0392B; color: #C0392B; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-lg { padding: 13px 26px; font-size: 17px; }

input, select { font-family: inherit; font-size: 15px; padding: 7px 10px;
    border: 1px solid var(--border-strong, #B5B5B5); border-radius: 6px; background: #fff; color: inherit; }
input:focus, select:focus { outline: 2px solid var(--gy-orange-200, #F5C4A8); border-color: var(--accent, #DD561C); }
input:disabled, select:disabled { background: #F3F3F3; color: #B5B5B5; }

/* ── 登入頁 ────────────────────────────────────────────── */
.login-page { display: grid; place-items: center; min-height: 100vh; background: var(--gy-black, #0B0B0B); }
.login-card { background: #fff; border-radius: 14px; padding: 40px 32px; width: min(420px, 92vw); text-align: center; }
.login-logo { height: 56px; margin-bottom: 12px; }
.login-card h1 { margin: 0; font-size: 26px; font-weight: 900; }
.login-card .sub { margin: 4px 0 24px; color: var(--fg3, #8A8A8A); }
.login-card .btn-lg { width: 100%; }
.login-card .hint { margin-top: 18px; }
.dev-login { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--border, #E8E8E8);
    display: flex; gap: 6px; align-items: center; }
.dev-login label { font-size: 12px; color: #B5B5B5; }
.dev-login input { flex: 1; min-width: 0; }

/* ── 對課表 ────────────────────────────────────────────── */
.bind { border-color: var(--accent, #DD561C); }
.bind-form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.bind-form select { flex: 1; min-width: 180px; }

/* ── 日期條 ────────────────────────────────────────────── */
.datestrip {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 14px;
    scrollbar-width: thin;
}
.datestrip a {
    flex: 0 0 auto; background: #fff; border: 1px solid var(--border, #E8E8E8);
    border-radius: 99px; padding: 8px 16px; text-decoration: none; font-size: 14px;
    font-weight: 700; white-space: nowrap;
}
.datestrip a.on { background: var(--accent, #DD561C); border-color: var(--accent, #DD561C); color: #fff; }
.datestrip a.closed { color: #B5B5B5; }
.datestrip a.closed em { font-style: normal; font-size: 11px; margin-left: 4px; }

/* ── 節次列 ────────────────────────────────────────────── */
.day-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.day-head .lock { font-size: 13px; color: #C0392B; font-weight: 700; }

.prow {
    display: grid; align-items: center; gap: 10px;
    grid-template-columns: 96px 1fr auto auto;
    padding: 10px 8px; border-bottom: 1px solid var(--border, #E8E8E8);
}
.prow:last-child { border-bottom: none; }
.prow.has { background: var(--gy-orange-50, #FDF2EB); border-radius: 6px; }

.p-when strong { display: block; font-size: 15px; font-weight: 900; }
.p-when span { font-size: 11px; color: var(--fg3, #8A8A8A); font-variant-numeric: tabular-nums; }

.p-what { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.p-what .subj { font-weight: 700; }
.p-what .cls { font-variant-numeric: tabular-nums; color: var(--fg2, #575757);
    background: #F3F3F3; border-radius: 4px; padding: 1px 7px; font-size: 13px; }
.p-what input { font-size: 14px; padding: 5px 8px; }
.p-what .f-class { width: 5.5em; }
.p-what .f-subject { width: 8em; }
.p-what .f-note { flex: 1; min-width: 7em; }

.p-qty { display: flex; align-items: center; gap: 4px; }
.p-qty .step {
    width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border-strong, #B5B5B5);
    background: #fff; font-size: 18px; font-weight: 900; cursor: pointer; line-height: 1;
}
.p-qty .step:hover:not(:disabled) { border-color: var(--accent, #DD561C); color: var(--accent, #DD561C); }
.p-qty .step:disabled { opacity: .35; cursor: default; }
.p-qty .f-qty { width: 4em; text-align: center; font-weight: 900; font-size: 16px;
    font-variant-numeric: tabular-nums; }
.p-qty .unit { font-size: 13px; color: var(--fg3, #8A8A8A); }
.p-qty .fill-class {
    margin-left: 6px; padding: 4px 10px; border-radius: 999px; font-size: 13px; cursor: pointer;
    border: 1px solid var(--line, #E0E0E0); background: var(--bg, #fff); color: var(--fg2, #555);
}
.p-qty .fill-class b { font-weight: 900; }
.p-qty .fill-class:hover:not(:disabled) { border-color: var(--accent, #DD561C); color: var(--accent, #DD561C); }
.p-qty .fill-class:disabled { opacity: .35; cursor: default; }
.p-qty .fill-class[hidden] { display: none; }

.p-state { font-size: 12px; min-width: 4em; text-align: right; }
.p-state.ok   { color: #3C8C4A; }
.p-state.err  { color: #C0392B; }
.p-state.busy { color: #B5B5B5; }

.tag { font-style: normal; font-size: 11px; font-weight: 700; padding: 2px 6px;
    border-radius: 99px; background: #E8E8E8; color: #575757; }
.tag.now { background: var(--accent, #DD561C); color: #fff; }
.tag.late { background: #FDECEA; color: #C0392B; }

/* ── 表格 ──────────────────────────────────────────────── */
table.mine, table.adm { width: 100%; border-collapse: collapse; font-size: 14px; }
table.mine th, table.adm th { text-align: left; font-size: 12px; color: var(--fg3, #8A8A8A);
    border-bottom: 1px solid var(--border, #E8E8E8); padding: 6px 8px; font-weight: 700; }
table.mine td, table.adm td { padding: 7px 8px; border-bottom: 1px solid #F3F3F3; vertical-align: middle; }
table.mine .r, table.adm .r { text-align: right; font-variant-numeric: tabular-nums; }
table.adm form { margin: 0; }
table.mine .act { text-align: right; white-space: nowrap; }
table.mine .act .btn + .btn { margin-left: 4px; }
table.mine tr.cancelled td { color: #B5B5B5; text-decoration: line-through; }
table.mine tr.cancelled td:last-child { text-decoration: none; }
.sub-h { font-size: 14px; margin: 4px 0 6px; color: var(--fg2, #575757); }
.history { margin-top: 16px; }
.history summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--fg2, #575757); }
.prow { scroll-margin-top: 72px; }
.prow:target { outline: 2px solid var(--accent, #DD561C); outline-offset: 2px; border-radius: 6px; }
@media (max-width: 640px) {
    table.mine th:nth-child(4), table.mine td:nth-child(4) { display: none; }
}

/* ── 後台 ──────────────────────────────────────────────── */
.admin .inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.admin .wrapform label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--fg2, #575757); }
.admin .adm-day { margin-top: 18px; }
.admin .adm-day h3 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    font-size: 16px; margin: 0 0 6px; }
.admin .adm-day .sum { font-size: 13px; font-weight: 400; color: var(--fg3, #8A8A8A); margin-right: auto; }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.settings label { display: flex; flex-direction: column; gap: 4px; font-size: 13px;
    font-weight: 700; color: var(--fg2, #575757); }
.settings label.full { grid-column: 1 / -1; }
.settings em { font-style: normal; font-weight: 400; font-size: 11px; color: var(--fg3, #8A8A8A); }
.settings button { grid-column: 1 / -1; justify-self: start; }

/* ── 報表頁 ────────────────────────────────────────────── */
.report-page { background: #fff; }
.wrap.report { max-width: 900px; }

@media print {
    .noprint, .topbar { display: none !important; }
    body { background: #fff; }
    .wrap.report { max-width: none; padding: 0; }
    @page { size: A4 portrait; margin: 12mm; }
}

/* ── 手機 ──────────────────────────────────────────────── */
@media (max-width: 640px) {
    .prow { grid-template-columns: 72px 1fr; grid-template-areas: "when what" "when qty" "state state"; }
    .p-when  { grid-area: when; }
    .p-what  { grid-area: what; }
    .p-qty   { grid-area: qty; justify-content: flex-start; }
    .p-state { grid-area: state; text-align: left; }
    .p-what .f-note { width: 100%; flex-basis: 100%; }
    .wrap { padding: 14px 12px 48px; }
    .card { padding: 14px; }
}
