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

:root {
  --primary: #fcd205;
  --primary-dark: #e6b800;
  --primary-light: rgba(252, 210, 5, 0.12);
  --bg: #f8f8f8;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #888;
  --border: #e8e8e8;
  --danger: #ff4444;
  --radius: 12px;
  --shadow: 0 1px 6px rgba(0,0,0,0.06);
  --nav-height: 64px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── Login ─────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
  width: min(380px, 90vw);
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.login-icon { font-size: 3rem; margin-bottom: 1rem; }
.login-card h1 { font-size: 1.6rem; margin-bottom: .5rem; color: var(--text); }
.login-card > p { color: var(--text-muted); margin-bottom: 1.5rem; font-size: .95rem; }

#login-form { display: flex; flex-direction: column; gap: .75rem; }

input[type="password"], input[type="text"] {
  height: 44px;
  padding: 0 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color .18s;
  width: 100%;
}
input:focus { border-color: var(--primary); }

/* Primary action button (Login, Add) */
.btn-primary {
  height: 44px;
  padding: 0 20px;
  background: var(--primary);
  color: var(--text);
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .18s, transform .1s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: scale(.97); }

#login-form .btn-primary { width: 100%; }

.error { color: var(--danger); font-size: .9rem; margin-top: .5rem; }

/* ─── App Layout ─────────────────────────────────────── */
#app-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: var(--nav-height);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

#logout-btn {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-muted);
  padding: .3rem .6rem;
  font-size: 1.1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .18s, color .18s;
}
#logout-btn:hover { color: var(--danger); border-color: var(--danger); }

/* ─── Bottom Nav ─────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 4px;
  transition: color .18s;
  position: relative;
}
.tab-icon { font-size: 1.4rem; line-height: 1; transition: transform .18s; }
.tab-label { text-transform: uppercase; letter-spacing: .04em; }

.tab.active { color: var(--text); }
.tab.active .tab-icon { transform: scale(1.1); }
.tab.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 25%; right: 25%;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
}

.tab-content { padding: 1rem; flex: 1; }

/* ─── Locations Tab ──────────────────────────────────── */
.add-location {
  display: flex;
  gap: .5rem;
  margin-bottom: 1.25rem;
}
.autocomplete-wrapper { position: relative; flex: 1; }
.autocomplete-wrapper input { width: 100%; }

.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  z-index: 200;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.autocomplete-list li {
  padding: .65rem 1rem;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.autocomplete-list li:last-child { border-bottom: none; }
.autocomplete-list li:hover { background: var(--bg); }

.locations-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }

.location-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .9rem 1rem;
  transition: border-color .18s;
}
.location-item:hover { border-color: var(--primary-dark); }

.location-name {
  cursor: pointer;
  font-weight: 500;
  flex: 1;
  display: flex;
  align-items: center;
  gap: .5rem;
  color: var(--text);
  transition: color .18s;
}
.location-name:hover { color: var(--text); }
.location-coords { font-size: .78rem; color: var(--text-muted); display: block; }

.delete-btn {
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s, color .18s;
}
.delete-btn:hover { background: rgba(255,68,68,.1); color: var(--danger); }

/* ─── Forecast Tab ───────────────────────────────────── */
.forecast-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: .75rem;
  color: var(--text);
}
.loading { color: var(--text-muted); padding: 2rem; text-align: center; }

/* 7-day horizontal strip */
.daily-forecast {
  display: flex;
  flex-direction: row;
  gap: .4rem;
  overflow-x: auto;
  padding-bottom: .4rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.day-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: .55rem .35rem;
  cursor: pointer;
  transition: border-color .18s, background .18s;
  min-width: 58px;
  flex: 1;
  text-align: center;
}
.day-card:hover { border-color: var(--primary-dark); }
.day-card.selected { border-color: var(--primary); background: var(--primary-light); }

.day-weekday { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.day-card.today .day-weekday { color: var(--text); font-weight: 800; }
.day-card.selected .day-weekday { color: var(--text); }

.day-date-num { font-size: .68rem; color: var(--text-muted); }
.day-icon { font-size: 1.4rem; line-height: 1; margin: 2px 0; }
.day-max { font-size: .85rem; font-weight: 700; color: #e85d04; }
.day-min { font-size: .75rem; color: #2563eb; }

/* ─── Inline Hourly Detail ───────────────────────────── */
.hourly-detail {
  margin-top: .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.hourly-detail-title {
  padding: .65rem 1rem;
  font-weight: 700;
  font-size: .9rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

#hourly-table-wrapper {
  overflow-x: auto;
  max-height: 55vh;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
th {
  text-align: left;
  padding: .45rem .75rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 2px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
}
td {
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

.td-weather { display: flex; align-items: center; gap: .4rem; }
.td-weather span { font-size: 1.1rem; }
