:root {
    --ink: #28352f;
    --muted: #718078;
    --line: #e5e9e5;
    --paper: #fffdf9;
    --canvas: #f5f7f2;
    --forest: #315f4d;
    --forest-dark: #24493b;
    --sage: #dcebe1;
    --orange: #e28a49;
    --orange-soft: #f9e7d6;
    --blue-soft: #dce9ee;
    --danger: #b74f4f;
    --shadow: 0 18px 48px rgba(43, 65, 54, .08);
    font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
    color: var(--ink);
    background: var(--canvas);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, summary, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: .55rem; font-size: clamp(1.85rem, 4vw, 2.75rem); letter-spacing: -.04em; line-height: 1.18; }
h2 { margin-bottom: .75rem; font-size: 1.25rem; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.eyebrow { display: block; margin-bottom: .55rem; color: var(--orange); font-size: .72rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; display: flex; width: 264px; flex-direction: column; padding: 30px 20px 24px; border-right: 1px solid var(--line); background: var(--paper); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 34px; font-size: 1.05rem; font-weight: 800; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: .63rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.brand-mark { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 14px; background: var(--forest); color: white; font-weight: 800; box-shadow: 0 8px 18px rgba(49, 95, 77, .24); }
.navigation { display: grid; gap: 8px; }
.navigation a { display: flex; align-items: center; gap: 13px; padding: 13px 15px; border-radius: 13px; color: #617068; font-size: .94rem; font-weight: 700; transition: .2s ease; }
.navigation a span { width: 22px; font-size: 1.2rem; text-align: center; }
.navigation a:hover { color: var(--forest); background: #f0f5f0; }
.navigation a.active { color: white; background: var(--forest); box-shadow: 0 10px 22px rgba(49, 95, 77, .18); }
.sidebar-user { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-top: auto; padding: 15px 10px 0; border-top: 1px solid var(--line); }
.sidebar-user strong, .sidebar-user small { display: block; }
.sidebar-user strong { font-size: .87rem; }
.sidebar-user small { margin-top: 2px; color: var(--muted); font-size: .72rem; }
.avatar { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; background: var(--orange-soft); color: #a65f2d; font-weight: 800; }
.avatar.large { width: 48px; height: 48px; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 1.25rem; cursor: pointer; }
.main-content { min-height: 100vh; margin-left: 264px; padding: 52px clamp(28px, 5vw, 76px) 80px; }
.mobile-header { display: none; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 34px; }
.page-heading p { margin-bottom: 0; color: var(--muted); }
.button { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 10px 18px; border: 0; border-radius: 12px; font-weight: 800; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--forest); color: white; box-shadow: 0 9px 20px rgba(49, 95, 77, .18); }
.button.primary:hover { background: var(--forest-dark); }
.button.soft { background: var(--sage); color: var(--forest-dark); }
.button.wide { width: 100%; }
.card { border: 1px solid rgba(66, 91, 77, .09); border-radius: 20px; background: var(--paper); box-shadow: var(--shadow); }
.notice { margin-bottom: 24px; padding: 14px 18px; border-radius: 13px; font-size: .9rem; }
.notice.success { background: var(--sage); color: var(--forest-dark); }
.notice.error { background: #f9e3e3; color: #813a3a; }
.notice ul { margin-bottom: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.stat-card { min-height: 170px; padding: 24px; border-radius: 20px; }
.stat-card > span { color: #5d6e65; font-size: .85rem; font-weight: 700; }
.stat-card strong { display: block; margin: 19px 0 12px; font-size: 2.65rem; line-height: 1; }
.stat-card strong small { font-size: 1rem; font-weight: 700; }
.stat-card p { margin-bottom: 0; color: #607069; font-size: .8rem; }
.stat-card.warm { background: var(--orange-soft); }
.stat-card.green { background: var(--sage); }
.stat-card.blue { background: var(--blue-soft); }
.progress { display: block; width: 100%; height: 7px; margin-top: 20px; overflow: hidden; border: 0; border-radius: 99px; background: rgba(255,255,255,.65); }
.progress::-webkit-progress-bar { background: rgba(255,255,255,.65); }
.progress::-webkit-progress-value { border-radius: 99px; background: var(--orange); }
.progress::-moz-progress-bar { border-radius: 99px; background: var(--orange); }
.section-block { margin-top: 42px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.section-heading h2 { margin-bottom: 0; }
.section-heading a { color: var(--forest); font-size: .83rem; font-weight: 800; }
.review-list { overflow: hidden; padding: 8px 22px; }
.review-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 18px; padding: 18px 4px; border-bottom: 1px solid var(--line); }
.review-row:last-child { border-bottom: 0; }
.subject-dot { display: grid; width: 43px; height: 43px; flex: 0 0 auto; place-items: center; border-radius: 14px; color: #9c5b2d; background: var(--orange-soft); font-weight: 900; }
.subject-1 { color: var(--forest); background: var(--sage); }
.subject-2 { color: #426778; background: var(--blue-soft); }
.subject-3 { color: #78613e; background: #eee8d2; }
.review-main > div { display: flex; gap: 9px; align-items: center; }
.review-main span { color: var(--muted); font-size: .75rem; }
.review-main p { margin: 5px 0 0; color: #59675f; font-size: .89rem; }
.review-time { min-width: 62px; text-align: center; font-weight: 900; }
.review-time small { display: block; color: var(--muted); font-size: .65rem; font-weight: 600; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 99px; color: #8a663b; background: #f2ead8; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.status-pill.done { color: var(--forest-dark); background: var(--sage); }
.empty-state { padding: 55px 20px; text-align: center; }
.empty-state > span { display: block; margin-bottom: 12px; color: var(--orange); font-size: 2rem; }
.empty-state h3 { margin-bottom: 7px; }
.empty-state p { color: var(--muted); }

.date-toolbar { display: grid; grid-template-columns: auto 1fr auto; align-items: end; gap: 18px; margin-bottom: 35px; padding: 17px 20px; }
.date-toolbar form { display: flex; align-items: end; justify-content: center; gap: 12px; }
.date-arrow { display: grid; width: 44px; height: 44px; place-items: center; border-radius: 12px; background: #f0f4ef; color: var(--forest); font-size: 1.65rem; font-weight: 500; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr); align-items: start; gap: 28px; }
.review-cards, .member-list { display: grid; gap: 14px; }
.review-card { position: relative; padding: 22px; border: 1px solid var(--line); border-radius: 18px; background: var(--paper); box-shadow: 0 10px 30px rgba(43,65,54,.05); }
.review-card.completed { border-color: #c8ddd0; background: #fcfffc; }
.review-card-head { display: flex; align-items: start; justify-content: space-between; gap: 18px; }
.review-title { display: flex; align-items: center; gap: 13px; }
.review-title span:not(.subject-dot) { color: var(--muted); font-size: .75rem; font-weight: 700; }
.review-title h3 { margin: 3px 0 0; font-size: 1.02rem; }
.review-notes { margin: 16px 0 0 56px; padding: 12px 14px; border-radius: 11px; color: #59675f; background: #f3f6f2; font-size: .85rem; line-height: 1.65; }
.review-update { display: flex; align-items: end; gap: 12px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.review-update .grow { flex: 1; }
.form-card { padding: 25px; }
.form-card form { display: grid; gap: 16px; margin-top: 22px; }
.sticky-card { position: sticky; top: 30px; }
.field { display: grid; gap: 7px; }
.field > span { color: #526159; font-size: .78rem; font-weight: 800; }
.field input, .field select, .field textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #d8dfda; border-radius: 11px; outline: none; color: var(--ink); background: white; transition: border .15s, box-shadow .15s; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #79a18e; box-shadow: 0 0 0 3px rgba(80, 130, 106, .11); }
.field.compact { min-width: 165px; }
.count-badge, .role-pill { padding: 6px 10px; border-radius: 99px; background: var(--sage); color: var(--forest); font-size: .72rem; font-weight: 800; }
.delete-form { margin-top: 10px; text-align: right; }
.text-button { padding: 4px; border: 0; background: transparent; font-size: .75rem; font-weight: 800; cursor: pointer; }
.text-button.danger { color: var(--danger); }

.members-layout { grid-template-columns: minmax(0, 1.5fr) minmax(320px, .7fr); }
.member-card { overflow: hidden; }
.member-card summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 18px 20px; list-style: none; cursor: pointer; }
.member-card summary::-webkit-details-marker { display: none; }
.member-identity { display: flex; align-items: center; gap: 13px; }
.member-identity strong, .member-identity span { display: block; }
.member-identity strong small { color: var(--muted); font-size: .72rem; }
.member-identity span { margin-top: 3px; color: var(--muted); font-size: .78rem; }
.member-meta { display: flex; align-items: center; gap: 13px; }
.status-dot { color: var(--forest); font-size: .76rem; font-weight: 800; }
.status-dot::before { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: #5fa278; content: ""; }
.status-dot.off { color: var(--muted); }
.status-dot.off::before { background: #b1b8b3; }
.member-edit { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; padding: 20px; border-top: 1px solid var(--line); background: #fafbf8; }
.member-edit .form-actions { display: flex; align-items: end; }
.member-card .delete-form { margin: 0; padding: 0 20px 16px; background: #fafbf8; }
.subject-list { display: grid; gap: 12px; }
.subject-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px; }
.subject-card form { margin: 0; }
.subject-identity { display: flex; align-items: center; gap: 13px; }

.data-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; overflow: hidden; margin-bottom: 30px; border: 1px solid var(--line); border-radius: 18px; background: var(--line); }
.data-summary div { padding: 20px 24px; background: var(--paper); }
.data-summary span, .data-summary strong { display: block; }
.data-summary span { color: var(--muted); font-size: .76rem; font-weight: 700; }
.data-summary strong { margin-top: 7px; font-size: 1.35rem; }
.export-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.export-card { display: grid; grid-template-columns: auto 1fr; gap: 18px; padding: 26px; }
.export-card.featured { grid-column: 1 / -1; grid-template-columns: auto 1fr auto; align-items: center; background: #eef5f0; }
.export-card p { margin-bottom: 0; color: var(--muted); font-size: .85rem; line-height: 1.7; }
.export-card .button { grid-column: 1 / -1; }
.export-card.featured .button { grid-column: auto; }
.export-icon { display: grid; width: 52px; height: 52px; place-items: center; border-radius: 16px; color: var(--forest); background: var(--sage); font-size: 1.35rem; }
.backup-note { margin-top: 25px; padding: 20px 24px; border-left: 4px solid var(--orange); border-radius: 0 14px 14px 0; background: var(--orange-soft); }
.backup-note p { margin: 5px 0 0; color: #745a43; font-size: .83rem; line-height: 1.65; }

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 30px; background: #edf2ec; }
.login-card { display: grid; width: min(1040px, 100%); min-height: 650px; grid-template-columns: 1.08fr .92fr; overflow: hidden; border-radius: 28px; background: var(--paper); box-shadow: 0 35px 90px rgba(38, 66, 51, .16); }
.login-art { position: relative; display: flex; align-items: flex-end; overflow: hidden; padding: 58px; color: white; background: linear-gradient(145deg, rgba(39,82,64,.88), rgba(49,95,77,.97)), radial-gradient(circle at 20% 20%, #8eb49d, transparent 55%); }
.login-art::before, .login-art::after { position: absolute; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; content: ""; }
.login-art::before { width: 460px; height: 460px; top: -190px; right: -180px; }
.login-art::after { width: 300px; height: 300px; bottom: -170px; left: -120px; }
.login-art-content { position: relative; z-index: 2; max-width: 410px; }
.login-art .eyebrow { color: #efc59e; }
.login-art h1 { margin-bottom: 20px; font-size: clamp(2.15rem, 4vw, 3.2rem); line-height: 1.28; }
.login-art p { margin-bottom: 0; color: rgba(255,255,255,.75); line-height: 1.8; }
.house-art { position: absolute; top: 70px; right: 70px; display: grid; width: 130px; height: 130px; place-items: center; border: 1px solid rgba(255,255,255,.22); border-radius: 40px; background: rgba(255,255,255,.08); transform: rotate(8deg); }
.house-art span { font-size: 4rem; transform: rotate(-8deg); }
.login-form { display: flex; flex-direction: column; justify-content: center; gap: 22px; padding: clamp(38px, 6vw, 76px); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.login-form h2 { margin-bottom: 8px; font-size: 1.7rem; }
.checkbox { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .8rem; }
.checkbox input { accent-color: var(--forest); }
.login-footnote { margin: 0; color: #8a958f; font-size: .72rem; text-align: center; }

@media (max-width: 1050px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-card:first-child { grid-column: 1 / -1; }
    .content-grid, .members-layout { grid-template-columns: 1fr; }
    .sticky-card { position: static; }
}

@media (max-width: 860px) {
    .sidebar { transform: translateX(-105%); transition: transform .22s ease; box-shadow: 18px 0 50px rgba(30,50,40,.18); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 22px 18px 60px; }
    .mobile-header { display: flex; align-items: center; gap: 12px; margin: -8px 0 28px; }
    .page-heading { align-items: start; flex-direction: column; }
    .login-page { padding: 0; }
    .login-card { min-height: 100vh; grid-template-columns: 1fr; border-radius: 0; }
    .login-art { display: none; }
    .login-form { padding: 36px 25px; }
}

@media (max-width: 620px) {
    h1 { font-size: 1.8rem; }
    .stat-grid, .export-grid, .data-summary { grid-template-columns: 1fr; }
    .stat-card:first-child, .export-card.featured { grid-column: auto; }
    .export-card.featured { grid-template-columns: auto 1fr; }
    .export-card.featured .button { grid-column: 1 / -1; }
    .review-row { grid-template-columns: auto 1fr auto; gap: 12px; }
    .review-row .status-pill { grid-column: 2 / -1; justify-self: start; }
    .review-time { grid-row: 1; grid-column: 3; }
    .date-toolbar { grid-template-columns: auto 1fr auto; padding: 14px; }
    .date-toolbar form { align-items: stretch; flex-direction: column; }
    .field.compact { min-width: 0; }
    .review-card-head, .review-update { align-items: stretch; flex-direction: column; }
    .review-notes { margin-left: 0; }
    .member-card summary { align-items: start; }
    .member-meta { align-items: end; flex-direction: column; gap: 5px; }
    .member-edit { grid-template-columns: 1fr; }
    .data-summary { gap: 0; }
}
