:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --shadow: 0 12px 32px rgba(15, 23, 42, .08);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, .18);
  --blue: #2563eb;
  --blue-2: #1d4ed8;
  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --green: #059669;
  --orange: #d97706;
  --red: #dc2626;
  --radius: 20px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(37,99,235,.08), transparent 30%),
    radial-gradient(circle at 95% 0%, rgba(124,58,237,.07), transparent 28%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---------------- LOGIN ---------------- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 36px 32px;
}
.login-brand h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -.02em; }
.login-brand p { margin: 0 0 24px; color: var(--muted); font-size: 14px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin: 14px 0 6px; }
.field-input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  font-size: 14px; outline: none; transition: .15s ease;
}
.field-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.primary-btn {
  width: 100%; margin-top: 20px; padding: 13px; border: 0; border-radius: 12px;
  background: var(--blue); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer;
  transition: .15s ease;
}
.primary-btn:hover { background: var(--blue-2); }
.primary-btn:disabled { opacity: .7; cursor: default; }
.login-error {
  margin-top: 14px; padding: 10px 12px; border-radius: 10px; background: #fef2f2; color: var(--red);
  font-size: 13px; font-weight: 600;
}

/* ---------------- SHELL ---------------- */
.shell { max-width: 1500px; margin: 0 auto; padding: 26px 24px 60px; }

.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.brand h1 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.brand p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.topbar-actions { display: flex; gap: 10px; }
.refresh, .logout-btn {
  border: 1px solid var(--line); background: rgba(255,255,255,.9); color: #374151;
  border-radius: 12px; padding: 10px 14px; cursor: pointer; box-shadow: 0 4px 14px rgba(15,23,42,.05);
  transition: .2s ease; font-weight: 600; font-size: 13px;
}
.refresh:hover, .logout-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.refresh:disabled { opacity: .6; cursor: default; transform: none; }
.logout-btn { color: var(--red); }

.mode-switch {
  display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px;
  background: #e9edf5; padding: 6px; border-radius: 16px; margin-bottom: 14px;
}
.mode-btn {
  border: 0; border-radius: 12px; padding: 15px 18px; background: transparent; color: #64748b;
  font-weight: 800; font-size: 14px; cursor: pointer; position: relative; overflow: hidden;
  transition: .22s ease;
}
.mode-btn.active { color: #0f172a; background: var(--surface); box-shadow: 0 5px 18px rgba(15,23,42,.09); }

.location-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 15px 18px; background: rgba(255,255,255,.92); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 5px 20px rgba(15,23,42,.05); margin-bottom: 18px;
}
.location-label { font-weight: 700; color: #374151; font-size: 14px; }
.location-select {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 14px; font-weight: 600;
  background: var(--surface-2);
}

.current-month-card {
  background: linear-gradient(135deg, var(--blue), var(--blue-2)); color: #fff; border-radius: var(--radius);
  padding: 24px 28px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.cm-value { font-size: 42px; font-weight: 800; letter-spacing: -.02em; }
.cm-meta { font-size: 13px; opacity: .85; margin-top: 4px; }
.cm-label { font-size: 12px; font-weight: 700; letter-spacing: .08em; opacity: .8; margin-top: 10px; text-transform: uppercase; }

.cards-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px;
}

.dash-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px;
  box-shadow: 0 4px 16px rgba(15,23,42,.04); transition: .2s ease; opacity: 0; transform: translateY(6px);
  animation: cardIn .35s ease forwards;
}
@keyframes cardIn { to { opacity: 1; transform: translateY(0); } }
.dash-card.highlight { background: var(--purple-bg); border-color: #ddd6fe; }
.dash-card.highlight .dash-card-total { color: var(--purple); }
.dash-card-title { font-size: 13px; font-weight: 700; color: #374151; margin-bottom: 6px; }
.dash-card-total { font-size: 30px; font-weight: 800; }
.dash-card-months { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.month-pill {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 5px 12px;
  font-size: 12px; font-weight: 600; cursor: pointer; transition: .15s ease;
}
.month-pill:hover { border-color: var(--blue); color: var(--blue-2); background: #eff6ff; }

.skeleton { background: linear-gradient(90deg, #eef1f6 25%, #f7f9fc 37%, #eef1f6 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 16px; height: 120px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.slow-notice, .error-notice {
  margin-top: 18px; padding: 14px 16px; border-radius: 12px; background: #fffbeb; color: #92400e;
  font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.error-notice { background: #fef2f2; color: var(--red); }
.slow-notice button, .error-notice button {
  border: 0; border-radius: 8px; padding: 6px 12px; background: #fff; cursor: pointer; font-weight: 700;
}

/* WCID overlay */
.wcid-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-end;
  justify-content: center; z-index: 50; animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.wcid-panel {
  width: 100%; max-width: 560px; max-height: 78vh; background: var(--surface); border-radius: 20px 20px 0 0;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slideUp .25s ease;
}
@media (min-width: 640px) {
  .wcid-overlay { align-items: center; }
  .wcid-panel { border-radius: 20px; }
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.wcid-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.wcid-panel-header h2 { margin: 0; font-size: 16px; }
.icon-btn { border: 0; background: var(--surface-2); border-radius: 10px; width: 32px; height: 32px; cursor: pointer; font-size: 14px; }
.wcid-panel-body { padding: 16px 20px; overflow-y: auto; }
.wcid-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--surface-2); font-size: 13px; }
.copy-btn { border: 1px solid var(--line); background: var(--surface-2); border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
.wcid-loading { text-align: center; color: var(--muted); padding: 30px 0; }

@media (max-width: 640px) {
  .shell { padding: 16px 14px 50px; }
  .cm-value { font-size: 32px; }
}
