:root {
  --navy: #172b3a;
  --navy-soft: #203847;
  --ink: #1d2b35;
  --muted: #7d898f;
  --line: #e7eaeb;
  --cream: #f8f7f3;
  --orange: #e57a45;
  --orange-soft: #fff0e7;
  --blue: #668da5;
  --green: #64a78d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #f5f6f3;
  font-family: "DM Sans", sans-serif;
  display: grid;
  grid-template-columns: 245px 1fr;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.sidebar {
  min-height: 100vh;
  background: var(--navy);
  color: white;
  padding: 30px 22px 22px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px;
  font-family: "Manrope", sans-serif;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #ed9568;
  display: grid;
  place-items: center;
}

svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark svg { width: 21px; }

.nav { margin-top: 44px; display: grid; gap: 7px; }
.nav-item {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #aec0ca;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 0 13px;
  text-align: left;
  font-weight: 600;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: white; }
.nav-item.active { background: #2a4454; color: white; }
.nav-item b { min-width: 23px; height: 23px; border-radius: 12px; background: #ed9568; color: white; display: grid; place-items: center; font-size: 12px; }

.sidebar-footer { margin-top: auto; }
.settings-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: #aec0ca;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 12px;
  font-weight: 600;
}
.settings-button:hover { color: white; }
.profile {
  border-top: 1px solid rgba(255,255,255,.09);
  margin-top: 8px;
  padding: 18px 6px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar { width: 38px; height: 38px; border-radius: 50%; background: #d9b69f; color: var(--navy); display: grid; place-items: center; font-size: 12px; font-weight: 800; }
.profile div:last-child { display: grid; }
.profile strong { font-size: 13px; }
.profile span { color: #91a5b0; font-size: 11px; margin-top: 2px; }

.main { padding: 42px 54px 60px; max-width: 1240px; width: 100%; margin: 0 auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.1px; }
h1, h2 { font-family: "Manrope", sans-serif; }
h1 { margin: 0; font-size: 34px; letter-spacing: -1.4px; }
.primary-button {
  border: 0;
  border-radius: 9px;
  background: var(--orange);
  color: white;
  height: 43px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  box-shadow: 0 7px 18px rgba(229,122,69,.18);
}
.primary-button:hover { background: #d66d3b; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-top: 34px; }
.stat-card {
  height: 92px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
}
.stat-overdue { border-left: 3px solid var(--orange); }
.stat-icon { width: 42px; height: 42px; border-radius: 50%; background: var(--orange-soft); color: var(--orange); display: grid; place-items: center; }
.stat-icon.blue { background: #edf3f6; color: var(--blue); }
.stat-icon.green { background: #edf5f1; color: var(--green); }
.stat-card div:last-child { display: grid; }
.stat-card strong { font-family: "Manrope", sans-serif; font-size: 22px; line-height: 1.1; }
.stat-card span { color: var(--muted); font-size: 12px; margin-top: 5px; }

.mail-section { margin-top: 36px; }
.section-heading { height: 38px; display: flex; align-items: center; justify-content: space-between; }
.section-heading h2 { margin: 0; font-size: 18px; letter-spacing: -.4px; }
.filter-button {
  height: 34px;
  border: 1px solid var(--line);
  background: white;
  color: #64737b;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 700;
}
.filter-button svg { width: 16px; }

.mail-list { margin-top: 10px; display: grid; gap: 9px; }
.mail-card {
  min-height: 82px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 11px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  padding: 12px 16px 12px 12px;
  transition: .18s ease;
}
.mail-card:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(35,49,55,.06); }
.sender-avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: white; font-family: "Manrope"; font-weight: 800; font-size: 13px; }
.mail-info { min-width: 0; }
.mail-info strong { display: block; font-size: 14px; margin-bottom: 4px; }
.mail-info p { margin: 0; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-meta { display: flex; align-items: center; gap: 16px; }
.due { min-width: 112px; display: grid; text-align: right; }
.due strong { color: var(--orange); font-size: 12px; }
.due span { color: var(--muted); font-size: 11px; margin-top: 3px; }
.card-actions { display: flex; gap: 6px; }
.icon-button, .action-button {
  border: 1px solid var(--line);
  background: white;
  color: #718089;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.action-button:hover { color: var(--navy); border-color: #bfc8cc; }
.action-button.done:hover { color: var(--green); }
.action-button svg { width: 16px; }
.empty-state { border: 1px dashed #d7ddde; border-radius: 12px; padding: 44px; text-align: center; color: var(--muted); background: rgba(255,255,255,.5); }
.empty-state strong { color: var(--ink); display: block; margin-bottom: 5px; }

dialog { width: min(520px, calc(100vw - 32px)); border: 0; border-radius: 14px; padding: 0; box-shadow: 0 24px 80px rgba(20,35,43,.22); }
dialog::backdrop { background: rgba(23,43,58,.45); backdrop-filter: blur(3px); }
dialog form { padding: 26px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.dialog-heading h2 { margin: 0; font-size: 22px; }
.dialog-heading .icon-button { border: 0; font-size: 24px; }
dialog label { display: grid; gap: 7px; color: #4d5a60; font-size: 12px; font-weight: 700; margin-bottom: 16px; }
dialog input, dialog select { height: 44px; border: 1px solid var(--line); border-radius: 8px; background: white; padding: 0 12px; color: var(--ink); outline: none; }
dialog input:focus, dialog select:focus { border-color: #93aab7; box-shadow: 0 0 0 3px #edf3f6; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.full { width: 100%; margin-top: 4px; }
.toggle-row { grid-template-columns: 1fr auto; align-items: center; padding: 10px 0; }
.toggle-row span { display: grid; }
.toggle-row small { color: var(--muted); font-weight: 400; margin-top: 4px; }
.toggle-row input { width: 38px; height: 21px; accent-color: var(--orange); }
.toast { position: fixed; right: 24px; bottom: 24px; background: var(--navy); color: white; border-radius: 9px; padding: 13px 17px; font-size: 13px; font-weight: 700; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; z-index: 20; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  body { grid-template-columns: 76px 1fr; }
  .sidebar { padding: 24px 12px 18px; }
  .brand { padding: 0 8px; }
  .brand span, .nav-item span, .nav-item b, .settings-button:not(svg), .profile div:last-child { display: none; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 0; }
  .settings-button { justify-content: center; }
  .profile { justify-content: center; padding-left: 0; padding-right: 0; }
  .main { padding: 36px 28px; }
}

@media (max-width: 650px) {
  body { display: block; }
  .sidebar { position: fixed; z-index: 10; bottom: 0; top: auto; width: 100%; height: 64px; min-height: 64px; padding: 7px 12px; flex-direction: row; }
  .brand, .sidebar-footer { display: none; }
  .nav { margin: 0; width: 100%; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .nav-item { height: 50px; }
  .main { padding: 28px 16px 86px; }
  .topbar h1 { font-size: 26px; }
  .primary-button { padding: 0 12px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-card:last-child { display: none; }
  .mail-card { grid-template-columns: 42px 1fr auto; padding-right: 8px; }
  .sender-avatar { width: 42px; height: 42px; }
  .due { display: none; }
  .card-actions { gap: 3px; }
  .form-row { grid-template-columns: 1fr; }
}

/* ---- additions for the live app ---- */
[hidden] { display: none !important; }
a.primary-button { text-decoration: none; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.filter-button.tall { height: 43px; padding: 0 14px; font-size: 13px; }
.filter-button.on { color: var(--orange); border-color: var(--orange); }
.filter-button:disabled { opacity: .6; cursor: wait; }
.banner {
  margin-top: 28px;
  background: var(--orange-soft);
  border: 1px solid #f6d3bd;
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.banner div { display: grid; gap: 4px; }
.banner span { color: #6b5547; font-size: 13px; }
.pill { font-style: normal; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; background: var(--orange-soft); color: var(--orange); border-radius: 5px; padding: 2px 6px; margin-left: 6px; vertical-align: 2px; }
.mail-info p b { color: var(--ink); font-weight: 600; }
.due.muted strong { color: var(--green); }
a.action-button { text-decoration: none; }
.footnote { color: var(--muted); font-size: 12px; margin-top: 14px; text-align: center; }
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { height: 52px; border: 1px solid var(--line); border-radius: 10px; background: white; font-weight: 700; color: var(--ink); }
.choice:hover { border-color: var(--orange); color: var(--orange); }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 12px; color: #4d5a60; }
.setting-row span { display: grid; }
.setting-row small { color: var(--muted); font-weight: 400; margin-top: 4px; }
.setting-row .filter-button { flex-shrink: 0; }
@media (max-width: 650px) {
  .banner { flex-direction: column; align-items: stretch; }
  .topbar { gap: 12px; }
  .filter-button.tall { display: none; }
  .choice-grid { grid-template-columns: 1fr; }
}

/* ---- multi-user: landing page, settings, mobile ---- */
body.signed-out { display: block; }
body.loading > * { visibility: hidden; }
.mobile-only { display: none !important; }
.landing { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: radial-gradient(circle at 20% 10%, #fff0e7 0, transparent 45%), #f5f6f3; }
.landing-card { width: min(560px, 100%); background: white; border: 1px solid var(--line); border-radius: 18px; padding: 40px; box-shadow: 0 24px 60px rgba(20,35,43,.08); }
.brand.dark { color: var(--navy); padding: 0; margin-bottom: 28px; }
.brand.dark .brand-mark { color: white; }
.landing h1 { font-size: 36px; line-height: 1.1; margin-bottom: 14px; }
.lead { color: #4d5a60; font-size: 16px; line-height: 1.55; margin: 0 0 18px; }
.features { list-style: none; padding: 0; margin: 0 0 26px; display: grid; gap: 10px; }
.features li { padding-left: 26px; position: relative; color: #4d5a60; font-size: 14px; line-height: 1.5; }
.features li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--green); font-weight: 800; }
.features b { color: var(--ink); }
.primary-button.big { height: 50px; width: 100%; font-size: 15px; }
.small { color: var(--muted); font-size: 12px; line-height: 1.5; }
.small a, .landing a:not(.primary-button) { color: var(--blue); }
dialog { max-height: calc(100vh - 32px); }
dialog h3 { font-family: "Manrope", sans-serif; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 22px 0 6px; }
dialog h3:first-of-type { margin-top: 0; }
dialog textarea { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; font-weight: 400; color: var(--ink); resize: vertical; outline: none; }
dialog textarea:focus { border-color: #93aab7; box-shadow: 0 0 0 3px #edf3f6; }
dialog code { font-size: 11px; background: #f1f3f3; padding: 1px 4px; border-radius: 4px; }
.filter-button.danger { color: #c0392b; }
.filter-button.danger:hover { border-color: #c0392b; }
.due-mobile { display: none; color: var(--orange); font-size: 12px; font-weight: 700; margin-top: 4px; }
.due-mobile.muted { color: var(--green); }
@media (max-width: 650px) {
  .mobile-only { display: grid !important; }
  .landing-card { padding: 28px 20px; }
  .landing h1 { font-size: 28px; }
  .due-mobile { display: block; }
  .mail-info p { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  #add-reminder span { display: none; }
  .mail-meta { gap: 0; }
}
.demo-link { display: block; text-align: center; margin-top: 14px; padding: 11px; border: 1px dashed #c9d3d7; border-radius: 9px; font-size: 13px; font-weight: 700; text-decoration: none; }

/* ---- watch list setup ---- */
.setup-card { margin-top: 28px; background: white; border: 1px solid var(--line); border-left: 3px solid var(--orange); border-radius: 12px; padding: 22px; }
.setup-head { display: flex; gap: 14px; align-items: flex-start; }
.setup-head .stat-icon { flex-shrink: 0; }
.setup-head h2 { margin: 0 0 6px; font-size: 18px; letter-spacing: -.3px; }
.setup-head p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.setup-grid label { display: grid; gap: 7px; color: #4d5a60; font-size: 12px; font-weight: 700; }
.setup-grid textarea { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; font-weight: 400; color: var(--ink); resize: vertical; outline: none; }
.setup-grid textarea:focus { border-color: #93aab7; box-shadow: 0 0 0 3px #edf3f6; }
.setup-actions { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.setup-actions .filter-button { height: 43px; padding: 0 14px; }
.watching { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }
.chip { background: #edf3f6; color: var(--navy); border-radius: 20px; padding: 3px 10px; font-size: 11px; font-weight: 700; }
@media (max-width: 650px) { .setup-grid { grid-template-columns: 1fr; } }

/* ---- install as app ---- */
.install-button { width: 100%; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: white; border-radius: 9px; display: flex; align-items: center; gap: 10px; padding: 11px 12px; font-weight: 700; margin-bottom: 4px; }
.install-button:hover { background: rgba(255,255,255,.12); }
.offline-note { background: var(--orange-soft); color: #8a4a26; border-radius: 9px; padding: 10px 12px; font-size: 13px; font-weight: 600; }
@media (display-mode: standalone) { .install-button, #install-row { display: none !important; } }
@media (max-width: 900px) { .install-button { justify-content: center; font-size: 0; gap: 0; } }

/* ---- admin dashboard ---- */
.admin-view { margin-top: 28px; }
.admin-stats { grid-template-columns: repeat(3, 1fr); margin-top: 0; }
.admin-tile { height: auto; min-height: 92px; }
.admin-tile div { display: grid; gap: 3px; }
.admin-tile span { color: var(--muted); font-size: 12px; font-weight: 700; margin: 0; }
.admin-tile strong { font-size: 26px; }
.admin-tile small { color: var(--muted); font-size: 12px; }
.admin-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 15px 0 30px; }
.chart-card { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 18px 18px 12px; min-width: 0; }
.chart-card h2 { margin: 0; font-size: 15px; }
.chart-sub { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.chart-total { margin: 12px 0 6px; color: #52514e; font-size: 12px; }
.chart-total strong { color: #0b0b0b; font-family: "Manrope", sans-serif; font-size: 20px; margin-right: 2px; }
.chart-box { position: relative; }
.chart-box svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-box .bar { fill: #2f7db8; }
.chart-box .hit { fill: transparent; cursor: default; }
.chart-box .hit.on { fill: rgba(47,125,184,.08); }
.chart-box .grid { stroke: #eceeee; stroke-width: 1; stroke-dasharray: 3 3; }
.chart-box .baseline { stroke: #c9cfd1; stroke-width: 1; }
.chart-box .axis { fill: #7d898f; font-size: 11px; font-family: "DM Sans", sans-serif; }
.chart-tip { position: absolute; top: -6px; transform: translate(-50%, -100%); background: var(--navy); color: white; font-size: 12px; font-weight: 700; padding: 6px 9px; border-radius: 7px; white-space: nowrap; pointer-events: none; }
.chart-table { margin-top: 6px; font-size: 12px; color: var(--muted); }
.chart-table summary { cursor: pointer; padding: 4px 0; }
.chart-table table { width: 100%; border-collapse: collapse; margin-top: 6px; max-height: 200px; }
.chart-table td, .chart-table th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; color: var(--ink); }
.admin-privacy { margin: 0 0 10px; }
.table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); border-radius: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 860px; }
.admin-table th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.admin-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; color: var(--ink); }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .num, .chart-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.status { font-size: 12px; font-weight: 700; }
.status.ok { color: #2e7d5b; }
.status.warn { color: #b26a00; }
.status.off { color: #7d898f; }
.muted-dash { color: #b9c0c3; }
.small-btn { height: 30px; font-size: 12px; }
.empty-row { text-align: center; color: var(--muted); padding: 28px !important; }
@media (max-width: 900px) { .admin-charts { grid-template-columns: 1fr; } .admin-stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 650px) { .admin-stats .stat-card:last-child { display: flex; } .admin-stats { grid-template-columns: 1fr 1fr; } }
/* keep wide content (admin table) scrolling inside its box instead of widening the page */
body { grid-template-columns: 245px minmax(0, 1fr); }
.main { min-width: 0; }
.admin-view, .chart-card, .table-wrap { min-width: 0; max-width: 100%; }
/* charts must not inherit the icon outline style */
.chart-box svg { fill: none; stroke: none; stroke-width: 0; }
.chart-box .grid, .chart-box .baseline { stroke-width: 1; }
.chart-box .axis { stroke: none; }
@media (max-width: 900px) { body { grid-template-columns: 76px minmax(0, 1fr); } }
@media (max-width: 650px) { body { grid-template-columns: none; } }
