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

:root {
    --sky:    #0ea5e9;
    --sky-d:  #0284c7;
    --sky-l:  #e0f2fe;
    --bg:     #f0f9ff;
    --surface:#ffffff;
    --border: #bae6fd;
    --text:   #0c1a2e;
    --muted:  #64748b;
    --warn:   #f59e0b;
    --danger: #ef4444;
    --green:  #16a34a;
    --radius: 12px;
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); margin: 0; font-size: 16px; }

a { color: var(--sky-d); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: .7rem 1.5rem; display: flex; align-items: center; gap: 1.2rem; position: sticky; top: 0; z-index: 50; }
.site-header .logo { font-weight: 700; font-size: 1.1rem; color: var(--sky-d); text-decoration: none; flex: none; }
.site-header .logo:hover { text-decoration: none; }
.nav-links { display: flex; gap: .5rem; }
.nav-links a { padding: .35rem .75rem; border-radius: 6px; font-size: .88rem; color: var(--muted); }
.nav-links a:hover { background: var(--sky-l); color: var(--sky-d); text-decoration: none; }
.nav-links a.active { background: var(--sky-l); color: var(--sky-d); font-weight: 600; }
.nav-right { margin-left: auto; display: flex; gap: 1rem; align-items: center; font-size: .85rem; color: var(--muted); }
.nav-right a { color: var(--muted); }
.nav-right a:hover { color: var(--text); text-decoration: none; }

/* ── Layout ── */
.container { max-width: 1140px; margin: 0 auto; padding: 1.5rem 1.2rem; }
.page-title { margin: 0 0 1.5rem; font-size: 1.4rem; font-weight: 700; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem 1rem; border-radius: 7px; border: none; font-size: .88rem; cursor: pointer; font-weight: 500; text-decoration: none; transition: background .15s; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--sky); color: #fff; }
.btn-primary:hover { background: var(--sky-d); }
.btn-secondary { background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--sky-l); border-color: var(--sky); }
.btn-danger { background: #fee2e2; color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fca5a5; }
.btn-sm { padding: .28rem .65rem; font-size: .8rem; }
.btn-icon { padding: .3rem .5rem; background: none; border: none; cursor: pointer; color: var(--muted); font-size: 1rem; }
.btn-icon:hover { color: var(--text); }

/* ── Forms ── */
.form-row { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .3rem; }
.form-group label { font-size: .82rem; font-weight: 500; color: var(--muted); }
.form-group input, .form-group select { padding: .45rem .75rem; border: 1px solid var(--border); border-radius: 7px; font-size: .9rem; background: var(--surface); color: var(--text); }
.form-group input:focus, .form-group select:focus { outline: 2px solid var(--sky); outline-offset: -1px; }
.form-group input.wide { width: 100%; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card-header { padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .6rem; }
.card-body { padding: 1rem 1.1rem; }

/* ── Weather grid ── */
.location-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1.2rem; }

/* ── Location card ── */
.loc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.loc-card-head { background: linear-gradient(135deg, var(--sky-d), var(--sky)); color: #fff; padding: 1rem 1.2rem; display: flex; align-items: flex-start; justify-content: space-between; }
.loc-name { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.loc-sub { font-size: .78rem; opacity: .85; margin-top: .1rem; }
.loc-current { display: flex; align-items: center; gap: .6rem; margin-top: .6rem; }
.loc-temp { font-size: 2.8rem; font-weight: 300; line-height: 1; }
.loc-icon { font-size: 2.2rem; line-height: 1; }
.loc-desc { font-size: .82rem; opacity: .9; margin-top: .2rem; }

.loc-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem .8rem; padding: .9rem 1.2rem; border-bottom: 1px solid var(--border); }
.stat-item { display: flex; align-items: center; gap: .4rem; font-size: .83rem; }
.stat-icon { font-size: 1rem; flex: none; }
.stat-label { color: var(--muted); font-size: .75rem; }
.stat-value { font-weight: 600; color: var(--text); }

.forecast-strip { display: flex; overflow-x: auto; padding: .7rem 1.2rem; gap: .3rem; scrollbar-width: none; }
.forecast-strip::-webkit-scrollbar { display: none; }
.forecast-day { flex: 0 0 auto; text-align: center; padding: .4rem .5rem; border-radius: 8px; min-width: 52px; }
.forecast-day.today { background: var(--sky-l); }
.forecast-day .fd-day { font-size: .72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.forecast-day .fd-icon { font-size: 1.3rem; line-height: 1.4; }
.forecast-day .fd-temp { font-size: .78rem; color: var(--text); white-space: nowrap; }
.forecast-day .fd-rain { font-size: .7rem; color: #38bdf8; }

.loc-footer { padding: .6rem 1.2rem; display: flex; align-items: center; justify-content: space-between; font-size: .78rem; color: var(--muted); background: var(--bg); }
.alert-badge { display: inline-flex; align-items: center; gap: .25rem; background: var(--warn); color: #fff; font-size: .72rem; font-weight: 700; border-radius: 99px; padding: .15rem .55rem; }
.alert-badge.fired { background: var(--danger); }
.source-badge { font-size: .72rem; color: var(--muted); opacity: .8; }

/* ── Hourly table ── */
.hourly-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.hourly-table th { padding: .5rem .7rem; text-align: left; font-weight: 600; font-size: .75rem; color: var(--muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
.hourly-table td { padding: .5rem .7rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.hourly-table tr:last-child td { border-bottom: none; }
.hourly-table tr.hour-now td { background: var(--sky-l); }
.hourly-table tr.hour-night td { color: var(--muted); }
.hourly-table tr.hour-day-break td:first-child { border-top: 2px solid var(--border); font-weight: 700; }

/* ── Alerts page ── */
.alerts-list { display: flex; flex-direction: column; gap: .8rem; }
.alert-row { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .9rem 1.1rem; display: flex; align-items: center; gap: 1rem; }
.alert-row.disabled { opacity: .55; }
.alert-info { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; font-size: .95rem; }
.alert-rule { font-size: .82rem; color: var(--muted); margin-top: .15rem; }
.alert-loc { font-size: .78rem; color: var(--sky-d); margin-top: .1rem; }
.alert-actions { display: flex; gap: .4rem; flex-shrink: 0; }
.toggle-btn { padding: .28rem .65rem; font-size: .78rem; border-radius: 6px; border: 1px solid var(--border); cursor: pointer; background: var(--surface); }
.toggle-btn.on { background: #dcfce7; border-color: #86efac; color: var(--green); }
.toggle-btn.off { background: #f3f4f6; border-color: #d1d5db; color: var(--muted); }

/* ── Locations page ── */
.loc-list { display: flex; flex-direction: column; gap: .7rem; margin-bottom: 2rem; }
.loc-row { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .85rem 1.1rem; display: flex; align-items: center; gap: 1rem; }
.loc-row-info { flex: 1; min-width: 0; }
.loc-row-name { font-weight: 600; font-size: .95rem; }
.loc-row-meta { font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.loc-row-actions { display: flex; gap: .4rem; flex-shrink: 0; }

/* ── Add form box ── */
.add-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.4rem; margin-top: 2rem; }
.add-box h2 { margin: 0 0 1rem; font-size: 1rem; font-weight: 600; }

/* ── Messages ── */
.msg { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .88rem; }
.msg-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.msg-ok { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty-state .es-icon { font-size: 3rem; margin-bottom: .75rem; }

/* ── Login ── */
.login-wrap { max-width: 360px; margin: 5rem auto; padding: 0 1rem; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; }
.login-card h1 { margin: 0 0 1.5rem; font-size: 1.3rem; text-align: center; }
.login-card .form-group { margin-bottom: 1rem; }
.login-card input { width: 100%; }
.login-card .btn { width: 100%; justify-content: center; }

/* ── History ── */
.history-list { font-size: .83rem; }
.history-item { display: flex; gap: .8rem; padding: .45rem 0; border-bottom: 1px solid var(--border); align-items: center; }
.history-item:last-child { border-bottom: none; }
.history-label { flex: 1; }
.history-time { color: var(--muted); white-space: nowrap; }
.history-val { font-weight: 600; white-space: nowrap; }

/* ── Wind arrow ── */
.wind-arrow { display: inline-block; line-height: 1; }

/* ── No data placeholder ── */
.no-data { display: flex; align-items: center; justify-content: center; height: 120px; color: var(--muted); font-size: .88rem; }

/* ── Site footer ── */
.site-footer { text-align: center; padding: 1.5rem; font-size: .8rem; color: var(--muted); }
.site-footer a { color: var(--muted); }

/* ── Responsive ── */
@media (max-width: 640px) {
    .location-grid { grid-template-columns: 1fr; }
    .loc-stats { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; align-items: stretch; }
    .site-header { flex-wrap: wrap; gap: .4rem; padding: .5rem .9rem; }
    .nav-links { order: 3; width: 100%; gap: .25rem; }
    .nav-links a { font-size: .82rem; padding: .25rem .55rem; }
    .nav-right { margin-left: auto; }
    .hourly-table { font-size: .78rem; }
    .hourly-table th, .hourly-table td { padding: .4rem .4rem; }
}
