*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #ffffff; --bg2: #f6f5f0; --bg3: #edece7;
    --tx: #1a1a1a; --tx2: #6b6a65; --tx3: #9c9a92;
    --bd: rgba(0,0,0,0.1); --bd2: rgba(0,0,0,0.18);
    --green: #0F6E56; --greenL: #E1F5EE;
    --blue: #185FA5; --blueL: #E6F1FB;
    --purple: #534AB7; --purpleL: #EEEDFE;
    --coral: #993C1D; --coralL: #FAECE7;
    --amber: #854F0B; --amberL: #FAEEDA;
    --lime: #3B6D11; --limeL: #EAF3DE;
    --pink: #993556; --pinkL: #FBEAF0;
    --red: #A32D2D; --redL: #FCEBEB;
    --gray: #5F5E5A; --grayL: #F1EFE8;
    --navy: #042C53;
    --warn-bg: #fdf3e3; --warn-tx: #854F0B;
    --danger-bg: #FCEBEB; --danger-tx: #A32D2D;
    --r: 10px; --rl: 14px;
    --font: 'Instrument Sans', 'SF Pro Display', system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:not(.light) {
        --bg: #1a1a1a; --bg2: #252523; --bg3: #2e2e2b;
        --tx: #e8e6dc; --tx2: #9c9a92; --tx3: #6b6a65;
        --bd: rgba(255,255,255,0.1); --bd2: rgba(255,255,255,0.18);
        --greenL: #08352b; --blueL: #0a2e4a; --purpleL: #23204a;
        --coralL: #3a1a0d; --amberL: #3a2506; --limeL: #1a2d08;
        --pinkL: #3a152a; --redL: #3a1313; --grayL: #2a2a28;
        --warn-bg: #3a2506; --warn-tx: #FAC775;
        --danger-bg: #3a1313; --danger-tx: #F09595;
    }
}
:root.dark {
    --bg: #1a1a1a; --bg2: #252523; --bg3: #2e2e2b;
    --tx: #e8e6dc; --tx2: #9c9a92; --tx3: #6b6a65;
    --bd: rgba(255,255,255,0.1); --bd2: rgba(255,255,255,0.18);
    --greenL: #08352b; --blueL: #0a2e4a; --purpleL: #23204a;
    --coralL: #3a1a0d; --amberL: #3a2506; --limeL: #1a2d08;
    --pinkL: #3a152a; --redL: #3a1313; --grayL: #2a2a28;
    --warn-bg: #3a2506; --warn-tx: #FAC775;
    --danger-bg: #3a1313; --danger-tx: #F09595;
}

.theme-toggle { position: absolute; left: 0; top: 1.5rem; background: none; border: 1px solid var(--bd); border-radius: 8px; width: 32px; height: 32px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 16px; color: var(--tx2); transition: all .15s; }
.theme-toggle:hover { background: var(--bg2); }

body { font-family: var(--font); background: var(--bg3); color: var(--tx); line-height: 1.5; -webkit-font-smoothing: antialiased; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: var(--bg); border-radius: var(--rl); padding: 2rem; border: 0.5px solid var(--bd); }
.login-header { text-align: center; margin-bottom: 1.5rem; }
.login-brand { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--tx3); margin-bottom: 4px; }
.login-title { font-size: 26px; font-weight: 700; letter-spacing: -1px; }

.alert { padding: 10px 14px; border-radius: var(--r); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: var(--danger-bg); color: var(--danger-tx); border-left: 3px solid var(--danger-tx); }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--bd); margin-bottom: 20px; }
.tab { flex: 1; padding: 10px 0; text-align: center; text-decoration: none; font-size: 14px; color: var(--tx3); font-weight: 400; border-bottom: 2px solid transparent; transition: all .15s; }
.tab.active { color: var(--tx); font-weight: 600; border-bottom-color: var(--tx); }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--tx2); margin-bottom: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="time"], input:not([type]), textarea, select {
    width: 100%; padding: 10px 12px; border-radius: var(--r); border: 1px solid var(--bd);
    background: var(--bg); color: var(--tx); font-size: 14px; font-family: var(--font);
    outline: none; transition: border .15s;
}
input[type="color"] { width: auto; padding: 0; border: none; background: none; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 56px; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 20px; border-radius: var(--r); font-size: 14px; font-weight: 600; font-family: var(--font); cursor: pointer; border: 1px solid var(--bd); transition: all .15s; text-decoration: none; }
.btn-primary { background: var(--tx); color: var(--bg); border-color: var(--tx); }
.btn-primary:hover { opacity: 0.9; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-ghost { background: transparent; color: var(--tx2); border: 1px solid var(--bd); }
.btn-ghost:hover { background: var(--bg2); }
.btn-danger { background: transparent; color: var(--danger-tx); border-color: var(--danger-tx); }

/* App layout */
.app { max-width: 520px; margin: 0 auto; padding: 0 16px; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
.app-header { text-align: center; padding: 1.5rem 0 1rem; position: relative; }
.app-header .logout { position: absolute; right: 0; top: 1.5rem; font-size: 12px; color: var(--tx3); text-decoration: none; cursor: pointer; background: none; border: none; font-family: var(--font); }
.app-header .logout:hover { color: var(--tx); }
.user-badge { font-size: 12px; color: var(--tx3); margin-top: 4px; }

/* Week nav */
.week-nav { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.week-btn { background: none; border: 1px solid var(--bd); border-radius: 8px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 18px; color: var(--tx2); font-family: var(--font); }
.week-days { display: flex; flex: 1; gap: 4px; }
.day-btn { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0; border: 1px solid transparent; border-radius: 10px; background: transparent; cursor: pointer; font-family: var(--font); transition: all .15s; }
.day-btn.selected { border-color: var(--tx); background: var(--bg2); }
.day-label { font-size: 10px; color: var(--tx3); font-weight: 500; }
.day-num { font-size: 15px; font-weight: 500; color: var(--tx2); width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.day-num.today { font-weight: 700; color: var(--tx); background: var(--bg2); }
.day-btn.selected .day-num.today { background: transparent; }
.day-dot { width: 18px; height: 3px; border-radius: 2px; background: var(--bd); }

/* Progress ring */
.progress-card { display: flex; align-items: center; gap: 20px; padding: 16px 20px; background: var(--bg2); border-radius: 16px; margin-bottom: 20px; }
.ring { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring-label { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; }

/* Supplement items */
.time-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.time-header .time { font-size: 15px; font-weight: 600; }
.time-header .period { font-size: 12px; color: var(--tx3); text-transform: uppercase; letter-spacing: 1px; }

.supp-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--bg); border: 1px solid var(--bd); border-radius: 12px; cursor: pointer; transition: all .2s; user-select: none; margin-bottom: 6px; }
.supp-item.done { opacity: 0.75; }
.supp-item.low-stock { border-color: var(--red); }

.supp-circle { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; transition: all .2s; }
.supp-name { font-size: 14px; font-weight: 600; }
.supp-name.done { text-decoration: line-through; color: var(--tx2); }
.supp-detail { font-size: 12px; color: var(--tx3); margin-top: 1px; }
.stock-badge { font-size: 10px; padding: 1px 6px; border-radius: 8px; background: var(--bg2); color: var(--tx3); }
.stock-badge.low { background: var(--danger-bg); color: var(--danger-tx); }
.tip-btn { background: none; border: none; cursor: pointer; padding: 4px; font-size: 16px; color: var(--tx3); line-height: 1; }
.tip-box { margin: 4px 0 0 40px; padding: 8px 12px; font-size: 12px; line-height: 1.6; color: var(--tx2); background: var(--bg2); border-radius: 8px; }

.color-picker { position: absolute; top: 48px; left: 14px; z-index: 10; display: flex; gap: 6px; padding: 8px 10px; background: var(--bg); border: 1px solid var(--bd2); border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.color-dot { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; box-sizing: border-box; }
.color-dot.active { border-color: var(--tx); border-width: 2.5px; }

/* Ratings */
.ratings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.rating-card { background: var(--bg2); border-radius: 12px; padding: 10px 14px; }
.rating-label { font-size: 12px; color: var(--tx2); margin-bottom: 6px; }
.rating-dots { display: flex; gap: 4px; }
.rating-dot { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; border: 1px solid var(--bd); background: var(--bg); color: var(--tx3); transition: all .15s; }
.rating-dot.active { color: #fff; border-color: transparent; }
.rating-dot.good { background: var(--green); }
.rating-dot.mid { background: var(--amber); }
.rating-dot.bad { background: var(--red); }

/* Drinks */
.drink-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.drink-btn { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--bg); border: 1px solid var(--bd); border-radius: 12px; cursor: pointer; font-family: var(--font); text-align: left; }
.drink-btn .icon { font-size: 20px; }
.drink-btn .label { font-size: 13px; font-weight: 600; color: var(--tx); }
.drink-btn .ml { font-size: 11px; color: var(--tx3); }

.drink-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg); border: 1px solid var(--bd); border-radius: 10px; margin-bottom: 6px; }
.drink-remove { background: none; border: none; cursor: pointer; font-size: 16px; color: var(--tx3); padding: 2px 6px; }

/* Water glass */
.water-card { padding: 20px; background: var(--bg2); border-radius: 16px; margin-bottom: 20px; }
.water-amount { font-size: 28px; font-weight: 700; }
.water-bar { height: 8px; border-radius: 4px; background: var(--bd); overflow: hidden; }
.water-fill { height: 100%; border-radius: 4px; transition: width .4s ease; }

/* Stats */
.stat-cards { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.stat-card { background: var(--bg2); border-radius: 12px; padding: 14px 12px; text-align: center; }
.stat-label { font-size: 11px; color: var(--tx3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.stat-value { font-size: 20px; font-weight: 700; }

.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding: 0 4px; margin-bottom: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bar-val { font-size: 11px; font-weight: 600; }
.bar-fill { width: 100%; max-width: 36px; border-radius: 6px; transition: height .3s ease; }
.bar-label { font-size: 10px; color: var(--tx3); }

/* Correlations */
.corr-pair { display: flex; gap: 8px; margin-bottom: 8px; }
.corr-box { flex: 1; border-radius: 8px; padding: 8px 10px; text-align: center; }
.corr-val { font-size: 18px; font-weight: 700; }
.corr-sub { font-size: 10px; }

.trend-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--bg); border: 1px solid var(--bd); border-radius: 10px; margin-bottom: 6px; }
.trend-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }

/* Settings */
.settings-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--bd); border-radius: 10px; margin-bottom: 6px; }
.supp-manage-row { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--bd); border-radius: 10px; margin-bottom: 6px; }
.arrow-btn { background: none; border: none; cursor: pointer; font-size: 10px; color: var(--tx3); padding: 0; line-height: 1; }
.edit-panel { margin: 6px 0 6px 32px; padding: 16px; background: var(--bg2); border-radius: 12px; display: flex; flex-direction: column; gap: 10px; border: 1px solid var(--bd); }
.edit-panel input, .edit-panel textarea { font-size: 13px; padding: 9px 12px; }
.edit-section-label { font-size: 11px; font-weight: 600; color: var(--tx3); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; padding-top: 10px; border-top: 1px solid var(--bd); }

.mini-rec { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 24px; }
.mini-rec-item { background: var(--bg2); border-radius: 10px; padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; }
.mini-rec-item .label { font-size: 12px; color: var(--tx2); }
.mini-rec-item .val { font-size: 13px; font-weight: 700; }

/* Warning banners */
.banner { padding: 10px 14px; margin-bottom: 12px; border-radius: 10px; font-size: 13px; cursor: pointer; }
.banner-warn { background: var(--warn-bg); color: var(--warn-tx); border-left: 3px solid var(--warn-tx); }
.banner-danger { background: var(--danger-bg); color: var(--danger-tx); border-left: 3px solid var(--danger-tx); }

.section-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.section-subtitle { font-size: 12px; color: var(--tx2); margin-bottom: 12px; line-height: 1.5; }
.note-card { padding: 10px 14px; background: var(--bg2); border-radius: 10px; margin-bottom: 8px; font-size: 13px; }
.note-date { font-weight: 600; font-size: 12px; color: var(--tx3); margin-bottom: 4px; }
.note-text { color: var(--tx2); line-height: 1.5; }
.muted { font-size: 13px; color: var(--tx3); padding: 12px 0; text-align: center; }
.text-center { text-align: center; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-1 { flex: 1; }
.hidden { display: none; }

.add-btn { width: 100%; padding: 10px; border-radius: 10px; border: 1px dashed var(--bd2); background: transparent; color: var(--tx2); font-size: 13px; font-weight: 600; cursor: pointer; font-family: var(--font); margin-bottom: 24px; }

.spacer { height: 40px; }
