:root {
    --ink: #172126;
    --muted: #68777e;
    --paper: #f3f5f2;
    --surface: #ffffff;
    --line: #dfe6e3;
    --deep: #123c4a;
    --deep-2: #0d2d37;
    --mint: #9fe5c2;
    --mint-soft: #e5f6ed;
    --blue-soft: #e6f0f5;
    --amber-soft: #fff2d8;
    --danger: #a33a3a;
    --shadow: 0 14px 40px rgba(22, 48, 54, .08);
    --radius: 20px;
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--paper); }
body { margin: 0; min-height: 100vh; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }

.topbar { height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 0 max(24px, calc((100vw - 1180px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand span:last-child, .user-copy { display: flex; flex-direction: column; }
.brand strong { font-size: 17px; }
.brand small, .user-copy small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: var(--deep); color: white; font-weight: 800; letter-spacing: -.04em; }
.brand-mark-large { width: 60px; height: 60px; border-radius: 20px; font-size: 21px; }
.user-menu { display: flex; align-items: center; gap: 18px; }
.user-copy { text-align: right; }

.nav { display: flex; align-items: center; gap: 8px; padding: 10px max(24px, calc((100vw - 1180px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.nav a { white-space: nowrap; text-decoration: none; color: #435158; padding: 9px 12px; border-radius: 10px; font-size: 14px; font-weight: 650; }
.nav a:hover { background: var(--paper); color: var(--deep); }
.main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 72px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 28px; margin-bottom: 30px; }
.page-head.compact { align-items: center; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(32px, 5vw, 54px); line-height: 1; letter-spacing: -.045em; }
h2 { margin-bottom: 8px; font-size: 25px; letter-spacing: -.025em; }
h3 { margin-bottom: 8px; }
.eyebrow { margin-bottom: 8px; color: #407466; font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.55; }

.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 12px; padding: 0 18px; font-weight: 750; text-decoration: none; transition: transform .15s ease, background .15s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.button-primary { background: var(--deep); color: white; }
.button-primary:hover { background: var(--deep-2); }
.button-secondary { background: var(--mint-soft); color: var(--deep); }
.button-ghost { background: transparent; color: var(--deep); border: 1px solid var(--line); }
.button-small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.button-wide { width: 100%; }

.alert { margin-bottom: 20px; padding: 14px 16px; border-radius: 12px; border: 1px solid; font-weight: 650; }
.alert-success { background: var(--mint-soft); color: #245d4b; border-color: #b5dfcc; }
.alert-error { background: #fff0ef; color: var(--danger); border-color: #efc9c6; }

.stat-grid { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: 14px; margin-bottom: 40px; }
.stat-card { min-height: 148px; display: flex; flex-direction: column; justify-content: space-between; padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.stat-card-accent { background: var(--deep); color: white; border-color: var(--deep); }
.stat-card span { font-size: 13px; color: var(--muted); }
.stat-card-accent span, .stat-card-accent small { color: #c9dadd; }
.stat-card strong { font-size: 30px; letter-spacing: -.04em; }
.stat-card small { color: var(--muted); }

.section-block { margin-top: 24px; padding: 26px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 4px 14px rgba(22, 48, 54, .03); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.section-head h2, .section-head p { margin-bottom: 0; }
.meter-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.meter-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; }
.meter-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; font-size: 20px; background: var(--amber-soft); }
.meter-cold_water { background: var(--blue-soft); }
.meter-hot_water { background: #fae9e4; }
.meter-copy p { margin-bottom: 3px; color: var(--muted); font-size: 12px; }
.meter-copy h3 { margin-bottom: 10px; font-size: 16px; }
.meter-copy strong { display: block; font-size: 21px; }
.meter-copy strong small { color: var(--muted); font-size: 13px; font-weight: 600; }
.meter-copy span { color: var(--muted); font-size: 12px; }
.meter-copy .no-reading { color: var(--muted); font-size: 15px; }
.meter-action { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--mint-soft); color: var(--deep); text-decoration: none; font-size: 21px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { padding: 11px 14px; color: var(--muted); font-size: 11px; letter-spacing: .08em; text-align: left; text-transform: uppercase; border-bottom: 1px solid var(--line); }
td { padding: 15px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
td small { display: block; margin-top: 3px; color: var(--muted); }
tfoot td { border-bottom: 0; font-weight: 800; font-size: 16px; }

.admin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-card { padding: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-card h2 { margin-bottom: 22px; }
.narrow-card { max-width: 720px; }
.wide-card { width: 100%; }
.form-stack { display: flex; flex-direction: column; gap: 18px; }
.form-stack label, fieldset { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 700; }
fieldset { margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 10px; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 46px; border: 1px solid #ccd7d3; border-radius: 11px; padding: 10px 12px; background: white; color: var(--ink); outline: none; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #5d9886; box-shadow: 0 0 0 3px rgba(93, 152, 134, .14); }
.optional { color: var(--muted); font-weight: 500; }
.form-grid-two, .form-grid-three { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid-three { grid-template-columns: repeat(3, 1fr); }
.input-with-action { position: relative; display: block; }
.input-with-action input { padding-right: 88px; }
.input-with-action button { position: absolute; right: 8px; top: 7px; height: 32px; border: 0; background: var(--paper); border-radius: 8px; color: var(--deep); font-size: 12px; }
.check-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.check-card { min-height: 62px; display: flex !important; flex-direction: row !important; align-items: center; gap: 10px !important; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.check-card input { width: 18px; min-height: 18px; }
.check-card span { display: flex; flex-direction: column; }
.check-card small { margin-top: 3px; color: var(--muted); font-weight: 500; }
.status { display: inline-flex; padding: 5px 8px; border-radius: 999px; background: #eee; color: var(--muted); font-size: 12px; }
.status-active { background: var(--mint-soft); color: #245d4b; }

.auth-shell { background: var(--deep); }
.auth-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 15%, #245d66 0, transparent 34%), radial-gradient(circle at 90% 85%, #1f5651 0, transparent 30%), var(--deep-2); }
.auth-card { width: min(470px, 100%); padding: 42px; border-radius: 28px; background: var(--surface); box-shadow: 0 24px 80px rgba(0, 0, 0, .25); }
.auth-brand { margin-bottom: 30px; }
.auth-card h1 { font-size: 37px; line-height: 1.05; }
.empty-state { min-height: 330px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 42px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.empty-state p { color: var(--muted); }
.empty-icon { width: 56px; height: 56px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 18px; background: var(--mint-soft); color: var(--deep); font-size: 25px; font-weight: 800; }
.empty-inline { padding: 28px; color: var(--muted); text-align: center; border: 1px dashed #cbd7d3; border-radius: 14px; }
.error-state { max-width: 680px; margin: 60px auto; }

@media (max-width: 920px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .admin-grid { grid-template-columns: 1fr; }
    .check-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .topbar { height: auto; padding: 14px 18px; }
    .brand small, .user-copy { display: none; }
    .nav { padding-left: 14px; padding-right: 14px; }
    .main { width: min(100% - 28px, 1180px); padding-top: 28px; }
    .page-head { align-items: stretch; flex-direction: column; gap: 18px; }
    .page-head .button { width: 100%; }
    h1 { font-size: 36px; }
    .stat-grid, .meter-grid, .form-grid-two, .form-grid-three, .check-grid { grid-template-columns: 1fr; }
    .stat-card { min-height: 128px; }
    .section-block, .form-card { padding: 18px; border-radius: 16px; }
    .auth-card { padding: 28px 22px; border-radius: 22px; }
    .auth-card h1 { font-size: 31px; }
}

