:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --text: #17212b;
    --muted: #647080;
    --line: #dfe5ec;
    --primary: #0d6b4d;
    --primary-dark: #084d38;
    --danger: #a92d2d;
    --danger-bg: #fff0f0;
    --success: #12633e;
    --success-bg: #ecf9f1;
    --warning-bg: #fff8e5;
    --radius: 16px;
    --shadow: 0 14px 40px rgba(27, 39, 51, 0.09);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
a { color: var(--primary); }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.05; margin-bottom: 1rem; }
h2 { font-size: 1.45rem; }

.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 42px 0 64px; }
.auth-page .page-shell { display: grid; place-items: center; min-height: calc(100vh - 72px); }
.auth-card { width: min(480px, 100%); padding: clamp(24px, 5vw, 44px); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.auth-card--wide { width: min(980px, 100%); }
.eyebrow { margin-bottom: 10px; color: var(--primary); font-size: 0.76rem; font-weight: 800; letter-spacing: 0.14em; }
.lead { color: var(--muted); font-size: 1.05rem; line-height: 1.6; }

.stack-form { display: grid; gap: 20px; margin-top: 26px; }
.stack-form label { display: grid; gap: 8px; font-weight: 700; }
.stack-form small { color: var(--muted); font-weight: 500; line-height: 1.4; }
fieldset { margin: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); }
legend { padding: 0 10px; color: var(--primary-dark); font-weight: 800; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
input, select, textarea { width: 100%; min-height: 48px; padding: 10px 12px; color: var(--text); background: #fff; border: 1px solid #b8c3ce; border-radius: 10px; outline: none; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13, 107, 77, 0.14); }
input[type="checkbox"] { width: 20px; min-height: 20px; accent-color: var(--primary); }

.button { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; padding: 11px 20px; color: #fff; background: var(--primary); border: 0; border-radius: 11px; font-weight: 800; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--primary-dark); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.button--full { width: 100%; }
.button--small { min-height: 38px; padding: 7px 14px; }
.button--ghost { color: var(--text); background: #fff; border: 1px solid var(--line); }
.button--secondary { color: var(--primary-dark); background: #e8f4ef; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }

.alert { margin: 20px 0; padding: 14px 16px; border-radius: 12px; line-height: 1.5; }
.alert ul { margin-bottom: 0; padding-left: 20px; }
.alert--error { color: var(--danger); background: var(--danger-bg); border: 1px solid #f0baba; }
.alert--success { color: var(--success); background: var(--success-bg); border: 1px solid #a9ddbe; }
.alert--warning { background: var(--warning-bg); border: 1px solid #ead28a; }
.status-box { padding: 14px 16px; border-radius: 12px; }
.status-box--ok { color: var(--success); background: var(--success-bg); border: 1px solid #a9ddbe; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px max(18px, calc((100vw - 1180px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar__brand { display: grid; gap: 3px; }
.topbar span { color: var(--muted); font-size: .9rem; }
.topbar__user { display: flex; align-items: center; gap: 14px; }
.topbar form { margin: 0; }
.app-nav { display: flex; align-items: center; justify-content: center; gap: 6px; }
.app-nav a { padding: 9px 11px; color: var(--text); border-radius: 9px; font-size: .92rem; font-weight: 700; text-decoration: none; }
.app-nav a:hover { color: var(--primary); background: #edf7f3; }

.welcome-panel { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; margin-bottom: 26px; padding: clamp(24px, 4vw, 42px); color: #fff; background: linear-gradient(135deg, #0d6b4d, #073e31); border-radius: 24px; box-shadow: var(--shadow); }
.welcome-panel .eyebrow, .welcome-panel p { color: #d8f3e8; }
.welcome-panel h1 { margin-bottom: 10px; }
.version-badge { flex: 0 0 auto; padding: 8px 12px; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.26); border-radius: 99px; font-weight: 800; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 26px; }
.metric-card, .content-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(27, 39, 51, .05); }
.metric-card { display: grid; gap: 8px; min-height: 124px; padding: 22px; }
.metric-card span { color: var(--muted); font-size: .88rem; }
.metric-card strong { align-self: end; font-size: 1.15rem; overflow-wrap: anywhere; }
.content-card { margin-bottom: 22px; padding: clamp(22px, 4vw, 34px); }
.content-card--muted { background: var(--surface-muted); }
.section-heading { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.status-pill { padding: 7px 11px; color: var(--success); background: var(--success-bg); border-radius: 99px; font-size: .85rem; font-weight: 800; }
.check-list { display: grid; gap: 12px; padding: 0; list-style: none; }
.check-list li { position: relative; padding-left: 30px; }
.check-list li::before { position: absolute; left: 0; content: "✓"; color: var(--primary); font-weight: 900; }
.technical-note { margin: 24px 0 0; padding-top: 18px; color: var(--muted); border-top: 1px solid var(--line); font-size: .9rem; }
.debug-box { padding: 12px; overflow: auto; background: #111; color: #fff; border-radius: 8px; }
.site-footer { padding: 20px; color: var(--muted); text-align: center; font-size: .82rem; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-heading h1 { margin-bottom: 10px; }
.page-heading p:not(.eyebrow) { color: var(--muted); }
.filter-bar { display: grid; grid-template-columns: minmax(220px, 1fr) auto auto; gap: 10px; margin-bottom: 18px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.table-card { overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(27, 39, 51, .05); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--surface-muted); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.cell-note { display: block; margin-top: 4px; color: var(--muted); font-size: .82rem; }
.status-tag, .subtle-tag { display: inline-flex; align-items: center; padding: 6px 9px; border-radius: 99px; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.status-tag--active { color: var(--success); background: var(--success-bg); }
.status-tag--disabled, .status-tag--archived { color: var(--muted); background: #edf0f3; }
.status-tag--locked { color: #8b4b00; background: var(--warning-bg); }
.subtle-tag { color: #31506c; background: #eaf2f8; }
.text-link { color: var(--primary); font-weight: 800; text-decoration: none; white-space: nowrap; }
.empty-state { padding: 42px; color: var(--muted); text-align: center; }
.card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.admin-card { display: flex; min-height: 260px; flex-direction: column; align-items: flex-start; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(27, 39, 51, .05); }
.admin-card h2 { margin: 18px 0 7px; }
.admin-card code { color: var(--primary-dark); }
.admin-card p { color: var(--muted); line-height: 1.5; }
.admin-card__top { display: flex; width: 100%; justify-content: space-between; gap: 8px; }
.admin-card__meta { display: flex; width: 100%; gap: 14px; margin-top: auto; padding: 16px 0; color: var(--muted); border-top: 1px solid var(--line); font-size: .84rem; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice-card, .permission-item { display: flex !important; grid-template-columns: none !important; flex-direction: row; align-items: flex-start; gap: 10px !important; padding: 13px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.choice-card span, .permission-item span { display: grid; gap: 4px; }
.choice-card small, .permission-item small, .field-help { color: var(--muted); font-weight: 500; }
.permission-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.permission-item strong { font-size: .9rem; }
.toggle-line { display: flex !important; flex-direction: row; align-items: center; gap: 10px !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.admin-shortcuts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.shortcut-card { display: block; padding: 22px; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; }
.shortcut-card:hover { border-color: #91bdaa; box-shadow: 0 8px 24px rgba(27, 39, 51, .07); }
.shortcut-card span { display: block; margin-bottom: 8px; color: var(--primary); font-size: .78rem; font-weight: 800; letter-spacing: .1em; }
.compact-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.setting-tile { display: grid; gap: 7px; padding: 16px; color: var(--text); background: var(--surface-muted); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; }
.setting-tile:hover { border-color: #91bdaa; }
.setting-tile .status-tag { justify-self: start; }
.setting-tile small { color: var(--muted); }
.weekday-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.split-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, .75fr); gap: 20px; align-items: start; }
.side-stack { display: grid; gap: 18px; }
.side-stack .content-card { margin: 0; }
.inline-action { display: grid; min-width: 220px; gap: 8px; margin-top: 10px; padding: 12px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: 10px; }
details summary { cursor: pointer; }
.payment-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.payment-card { display: grid; gap: 18px; margin: 0; }
.payment-card label { display: grid; gap: 8px; font-weight: 700; }
.payment-card small { color: var(--muted); font-weight: 500; }
.switch-label { display: flex !important; flex-direction: row; align-items: center; gap: 8px !important; }
.switch-label input[type="checkbox"] { width: 20px; min-height: 20px; }

@media (max-width: 800px) {
    .form-grid, .form-grid--3, .metric-grid, .card-grid, .choice-grid, .permission-grid, .admin-shortcuts, .compact-grid, .payment-grid, .split-layout { grid-template-columns: 1fr; }
    .metric-card { min-height: 96px; }
    .topbar { flex-wrap: wrap; align-items: flex-start; }
    .app-nav { order: 3; width: 100%; justify-content: flex-start; overflow-x: auto; }
    .topbar__user > span { display: none; }
    .filter-bar { grid-template-columns: 1fr; }
    .weekday-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
    .page-shell { width: min(100% - 20px, 1180px); padding-top: 18px; }
    .auth-card { padding: 24px 18px; border-radius: 18px; }
    fieldset { padding: 16px 12px; }
    .welcome-panel { flex-direction: column; }
    .section-heading { flex-direction: column; }
    .page-heading { flex-direction: column; }
    th, td { padding: 12px; }
}
