/* Same tokens and components as the iPostal dashboard (personal-data/ipostal/styles.css) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f9fafb; --surface: #ffffff; --border: #e5e7eb; --text: #111827; --muted: #6b7280;
  --primary: #2563eb; --ring: rgba(37,99,235,0.25); --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; min-height: 100vh; }

.page { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }
.header { margin-bottom: 20px; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.header h1 { font-size: 20px; font-weight: 600; }
.meta { color: var(--muted); font-size: 12px; margin-top: 4px; }
.meta.failed { color: #b91c1c; }

.refresh-btn {
  display: inline-flex; align-items: center; gap: 6px; font-size: 16px; min-height: 44px; padding: 0 14px;
  border-radius: 22px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
}
.refresh-btn:hover:not(:disabled) { background: #f3f4f6; }
.refresh-btn:disabled { opacity: .6; cursor: default; }
.refresh-icon { width: 16px; height: 16px; }
.refresh-btn.spinning .refresh-icon { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
#search {
  width: 100%; padding: 12px 14px 12px 42px; font-size: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); outline: none; color: var(--text);
}
#search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

/* View chips: each one is a saved filter with a count */
.views { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin-bottom: 8px; padding-bottom: 2px; }
.views::-webkit-scrollbar { display: none; }
.view {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; font-size: 13px; color: var(--text); cursor: pointer;
}
.view strong { font-variant-numeric: tabular-nums; }
.view.warn strong { color: #b45309; }
.view.bad strong { color: #b91c1c; }
.view.active { background: #eff6ff; border-color: var(--primary); }
.view-note { color: var(--muted); font-size: 12px; margin-bottom: 12px; min-height: 16px; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { background: #f8f9fb; padding: 10px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; text-align: left; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap; }
thead th:hover { color: var(--text); }
thead th.sorted-asc::after { content: ' ↑'; color: var(--primary); }
thead th.sorted-desc::after { content: ' ↓'; color: var(--primary); }
tbody tr.row { border-bottom: 1px solid var(--border); cursor: pointer; }
tbody tr.row:hover { background: #f0f6ff; }
tbody tr.row.open { background: #eff6ff; }
tbody td { padding: 10px; vertical-align: middle; }
.cell-name strong { font-weight: 500; display: block; }
.cell-name small { color: var(--muted); font-size: 11px; }
.cell-fob { font-family: monospace; font-size: 13px; font-weight: 600; color: var(--primary); white-space: nowrap; }
.cell-muted { color: var(--muted); }
.src { font-size: 10px; color: var(--muted); margin-left: 4px; text-transform: uppercase; letter-spacing: .03em; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.b-ok { background: #dcfce7; color: #166534; }
.b-warn { background: #fef3c7; color: #92400e; }
.b-bad { background: #fee2e2; color: #991b1b; }
.b-muted { background: #f3f4f6; color: #4b5563; }

/* Expanded detail row */
.detail td { background: #f8f9fb; border-bottom: 1px solid var(--border); padding: 12px 14px 14px; }
.detail dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; }
.detail dt { color: var(--muted); }
.detail dd { overflow-wrap: anywhere; }
.detail a { color: var(--primary); text-decoration: none; }
.detail .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.detail button {
  min-height: 44px; padding: 0 14px; font-size: 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
}
.detail button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }

@media (max-width: 700px) {
  .hide-mobile { display: none; }
  .detail dl { grid-template-columns: 96px 1fr; }
}

/* ── Sign in ── */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; display: flex; flex-direction: column; gap: 8px; }
.login-card h1 { font-size: 20px; font-weight: 600; }
.login-card .meta { margin: 0 0 8px; }
.login-card label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.login-card input { font-size: 16px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; outline: none; color: var(--text); }
.login-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.login-card button { margin-top: 8px; min-height: 44px; font-size: 16px; border: none; border-radius: 8px; background: var(--primary); color: #fff; cursor: pointer; }
.login-card button:disabled { opacity: .6; }
.login-error { color: #b91c1c; font-size: 13px; min-height: 18px; }
.signout { white-space: nowrap; background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; text-decoration: underline; min-height: 44px; padding: 0 4px; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── Weekends ── */
.wk-head strong { font-size: 13px; font-weight: 600; }
.wk-tabs { margin-bottom: 12px; }
.wk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.wk-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; }
.wk-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.wk-head span { color: var(--muted); font-size: 12px; }
.wk-day ul { list-style: none; }
.wk-day li { display: grid; grid-template-columns: 72px 1fr; gap: 0 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.wk-day li:first-child { border-top: none; }
.wk-time { font-variant-numeric: tabular-nums; color: var(--primary); font-weight: 600; font-size: 13px; }
.wk-name { font-weight: 500; }
.wk-meta { grid-column: 2; color: var(--muted); font-size: 11px; }
.wk-shared .wk-name, .wk-shared .wk-time { color: var(--muted); font-weight: 400; }
.wk-hit { background: #fef9c3; margin: 0 -6px; padding-left: 6px !important; padding-right: 6px !important; border-radius: 6px; }
.wk-more { margin: 16px auto 0; display: block; min-height: 44px; padding: 0 18px; font-size: 16px; border-radius: 22px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; }
/* Refresh sits beside the title, same as the iPostal dashboard */
.header-row { align-items: flex-start; }
.header-title { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.header .sources { color: var(--text); font-size: 13px; margin-top: 2px; }
.header .sources + .meta { margin-top: 2px; }
