:root {
  --bg-grad: linear-gradient(160deg, #c8ecd7 0%, #e3f1e2 48%, #cde5d1 100%);
  --screen-grad: linear-gradient(160deg, #dff5e8 0%, #cbe6d1 100%);
  --surface: #f1faf5;
  --surface-sunken: #d9ebde;
  --border: #b7dcbf;
  --text: #1e2e23;
  --text-muted: #52695a;
  --text-faint: #8ba792;
  --accent: #22a862;
  --accent-strong: #178a50;
  --accent-grad: linear-gradient(135deg, #5fe39a 0%, #1a9a5c 100%);
  --accent-tint: #c9f2db;
  --accent-contrast: #ffffff;
  --success: #5c8a3c;
  --success-tint: #e9f1de;
  --warning: #ab7c26;
  --warning-tint: #f7eed9;
  --critical: #af5138;
  --critical-tint: #f8e7e0;
  --heading-chip: #dbe7dd;
  --brand-grad: linear-gradient(135deg, #ffd166 0%, #f2994a 100%);
  --brand-text: #4a2b06;
  --shadow: 0 1px 2px rgba(30, 55, 40, 0.07), 0 14px 32px -14px rgba(30, 55, 40, 0.28);
  --display: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  --sans: -apple-system, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-grad: linear-gradient(160deg, #0b1712 0%, #132019 48%, #17221a 100%);
    --screen-grad: linear-gradient(160deg, #192819 0%, #131f17 100%);
    --surface: #1e2e24;
    --surface-sunken: #15211a;
    --border: #2b3d32;
    --text: #e6ece7;
    --text-muted: #92a89a;
    --text-faint: #55695c;
    --accent: #4fe19b;
    --accent-strong: #7ef0b8;
    --accent-grad: linear-gradient(135deg, #3fd48c 0%, #189258 100%);
    --accent-tint: #163b28;
    --accent-contrast: #07130d;
    --success: #9bc177;
    --success-tint: #223221;
    --warning: #e0ac54;
    --warning-tint: #332715;
    --critical: #e08767;
    --critical-tint: #372019;
    --heading-chip: #223129;
    --brand-grad: linear-gradient(135deg, #f0b559 0%, #d1852f 100%);
    --brand-text: #3a220a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 14px 32px -14px rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme="dark"] {
  --bg-grad: linear-gradient(160deg, #0b1712 0%, #132019 48%, #17221a 100%);
  --screen-grad: linear-gradient(160deg, #192819 0%, #131f17 100%);
  --surface: #1e2e24; --surface-sunken: #15211a; --border: #2b3d32;
  --text: #e6ece7; --text-muted: #92a89a; --text-faint: #55695c;
  --accent: #4fe19b; --accent-strong: #7ef0b8;
  --accent-grad: linear-gradient(135deg, #3fd48c 0%, #189258 100%);
  --accent-tint: #163b28; --accent-contrast: #07130d;
  --success: #9bc177; --success-tint: #223221; --warning: #e0ac54; --warning-tint: #332715;
  --critical: #e08767; --critical-tint: #372019; --heading-chip: #223129;
  --brand-grad: linear-gradient(135deg, #f0b559 0%, #d1852f 100%); --brand-text: #3a220a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 14px 32px -14px rgba(0, 0, 0, 0.55);
}
:root[data-theme="light"] {
  --bg-grad: linear-gradient(160deg, #c8ecd7 0%, #e3f1e2 48%, #cde5d1 100%);
  --screen-grad: linear-gradient(160deg, #dff5e8 0%, #cbe6d1 100%);
  --surface: #f1faf5; --surface-sunken: #d9ebde; --border: #b7dcbf;
  --text: #1e2e23; --text-muted: #52695a; --text-faint: #8ba792;
  --accent: #22a862; --accent-strong: #178a50;
  --accent-grad: linear-gradient(135deg, #5fe39a 0%, #1a9a5c 100%);
  --accent-tint: #c9f2db; --accent-contrast: #ffffff;
  --success: #5c8a3c; --success-tint: #e9f1de; --warning: #ab7c26; --warning-tint: #f7eed9;
  --critical: #af5138; --critical-tint: #f8e7e0; --heading-chip: #dbe7dd;
  --brand-grad: linear-gradient(135deg, #ffd166 0%, #f2994a 100%); --brand-text: #4a2b06;
  --shadow: 0 1px 2px rgba(30, 55, 40, 0.07), 0 14px 32px -14px rgba(30, 55, 40, 0.28);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-grad);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.page { max-width: 720px; margin: 0 auto; padding: 48px 24px 96px; position: relative; }

.screen {
  background: var(--screen-grad);
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 44px 40px;
  box-shadow: var(--shadow);
}

.kicker { font-family: var(--mono); font-size: 12px; letter-spacing: 0.06em; color: var(--accent-strong); margin: 0 0 12px; }

.heading-chip { display: inline-block; background: var(--heading-chip); border-radius: 14px; padding: 10px 22px; margin: 0 0 16px; }
.heading-chip.centered { display: block; width: fit-content; margin-left: auto; margin-right: auto; text-align: center; }
.heading-chip h1, .heading-chip h2 { margin: 0; }

.h-display { font-family: var(--display); font-weight: 700; font-size: 24px; text-wrap: balance; letter-spacing: -0.01em; }
.lede { color: var(--text-muted); font-size: 15px; max-width: 54ch; margin: 14px 0 28px; }

.btn { font-family: var(--sans); font-size: 14px; font-weight: 600; border-radius: 12px; padding: 11px 22px; border: 1px solid transparent; cursor: pointer; display: inline-block; text-decoration: none; }
.btn-primary { background: var(--accent-grad); color: var(--accent-contrast); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-critical { background: var(--critical); color: #fff; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.center-card { max-width: 320px; margin: 20px auto 0; text-align: center; }
.brand-badge { display: inline-flex; flex-direction: column; align-items: center; gap: 3px; background: var(--brand-grad); border-radius: 20px; padding: 18px 32px; margin: 0 auto 24px; box-shadow: 0 12px 28px -12px rgba(154, 100, 20, 0.5); }
.brand-name { font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: -0.02em; color: var(--brand-text); }
.brand-sub { font-family: var(--sans); font-weight: 700; font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brand-text); opacity: 0.72; }

.field { text-align: left; margin-bottom: 18px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field select { width: 100%; font-family: var(--sans); font-size: 14px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

.error-box { background: var(--critical-tint); color: var(--critical); border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 20px; }
.flash-box { background: var(--success-tint); color: var(--success); border-radius: 10px; padding: 12px 14px; font-size: 13px; margin-bottom: 20px; }

.connect-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 24px; }
.connect-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; background: var(--surface); flex-wrap: wrap; }
.connect-id { display: flex; align-items: center; gap: 12px; }
.provider-dot { width: 30px; height: 30px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-family: var(--display); font-size: 12px; font-weight: 700; color: var(--accent-contrast); background: var(--accent-grad); flex: 0 0 auto; }
.connect-meta .name { font-weight: 700; font-size: 14px; font-family: var(--display); }
.connect-meta .sub { font-size: 12px; color: var(--text-muted); font-family: var(--mono); word-break: break-all; }

.chip { font-family: var(--sans); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chip-success { background: var(--success-tint); color: var(--success); }
.chip-warning { background: var(--warning-tint); color: var(--warning); }
.chip-critical { background: var(--critical-tint); color: var(--critical); }
.chip-neutral { background: var(--surface-sunken); color: var(--text-muted); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.picker-panel { border: 1px solid var(--border); border-radius: 14px; background: var(--surface-sunken); padding: 18px; margin: 4px 0 20px; }
.provider-detail { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.steps-ol { margin: 0 0 16px; padding-left: 20px; font-size: 13px; color: var(--text-muted); display: flex; flex-direction: column; gap: 6px; }
.steps-ol li::marker { color: var(--accent-strong); font-weight: 700; }
.ics-note { display: flex; gap: 8px; font-size: 12.5px; color: var(--text-muted); background: var(--warning-tint); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; }

.lookback-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 26px; }
.lookback-option { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; background: var(--surface); }
.lookback-option:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.lookback-option input { accent-color: var(--accent-strong); width: 17px; height: 17px; }
.lookback-option .label { font-weight: 700; font-size: 14px; font-family: var(--display); }
.lookback-option .desc { font-size: 12px; color: var(--text-muted); }
.target-chips { display: flex; gap: 6px; margin-bottom: 22px; flex-wrap: wrap; }

.stat-row { display: flex; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.stat { flex: 1 1 150px; border: 1px solid var(--border); border-radius: 14px; padding: 16px; background: var(--surface); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--accent-grad); }
.stat.critical::before { background: linear-gradient(135deg, #e08767, var(--critical)); }
.stat .num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 600; }
.stat .lbl { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat.critical { background: var(--critical-tint); }
.stat.critical .num, .stat.critical .lbl { color: var(--critical); }

.detail-panel { border: 1px solid var(--border); border-radius: 14px; background: var(--surface-sunken); padding: 6px 4px; margin: 14px 0 22px; }
.detail-panel .detail-head { padding: 10px 14px 6px; font-size: 12px; color: var(--text-muted); }
.detail-head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.detail-head-row .detail-head { flex: 1 1 200px; }
.detail-actions { display: flex; gap: 10px; padding: 10px 14px 6px 0; flex: 0 0 auto; white-space: nowrap; }
.btn-link { background: none; border: none; padding: 0; font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--accent-strong); cursor: pointer; text-decoration: underline; }
.btn-link:hover { color: var(--accent); }
.detail-item { display: flex; align-items: flex-start; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--border); }
.detail-item:first-of-type { border-top: none; }
.detail-item input[type="checkbox"] { width: 17px; height: 17px; margin-top: 2px; accent-color: var(--accent-strong); flex: 0 0 auto; }
.detail-item .title { font-weight: 700; font-size: 13.5px; font-family: var(--display); }
.detail-item .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.detail-item.is-delete .title { color: var(--critical); }

.callout { display: flex; gap: 10px; border: 1px solid var(--border); background: var(--surface-sunken); border-radius: 12px; padding: 13px 15px; font-size: 13px; color: var(--text-muted); margin-bottom: 26px; }

.done-wrap { text-align: center; padding: 20px 0; }
.check { width: 56px; height: 56px; margin: 0 auto 20px; border-radius: 50%; background: var(--accent-tint); display: flex; align-items: center; justify-content: center; }

.dash-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; gap: 12px; flex-wrap: wrap; }
.duplicates-panel { border: 1px solid var(--border); background: var(--surface-sunken); border-radius: 12px; padding: 12px 14px; margin-top: 10px; max-width: 420px; text-align: left; }
.duplicate-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--border); }
.duplicate-item:first-of-type { border-top: none; padding-top: 0; }
.duplicate-item .title { font-weight: 700; font-size: 13.5px; font-family: var(--display); }
.duplicate-item .meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.duplicate-item form { display: inline; }
.duplicate-item .btn { padding: 6px 12px; font-size: 12.5px; }
.cal-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.cal-row { display: flex; align-items: center; gap: 14px; border: 1px solid var(--border); border-radius: 14px; padding: 13px 15px; background: var(--surface); flex-wrap: wrap; }
.cal-row .grow { flex: 1; min-width: 160px; }
.cal-row .name { font-weight: 700; font-size: 14px; font-family: var(--display); }
.cal-row .sub { font-size: 12px; color: var(--text-muted); font-family: var(--mono); word-break: break-all; }
.cal-row .meta-right { font-size: 12px; color: var(--text-muted); text-align: right; white-space: nowrap; }
.icon-btn { flex: 0 0 auto; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { background: var(--critical-tint); color: var(--critical); border-color: var(--critical); }

.remove-confirm { border: 1px solid var(--critical); background: var(--critical-tint); border-radius: 12px; padding: 13px 15px; margin-top: 8px; }
.remove-confirm p { margin: 0 0 12px; font-size: 13px; color: var(--text); }

.direction-form { border: 1px solid var(--border); background: var(--surface-sunken); border-radius: 12px; padding: 13px 15px; margin-top: 8px; font-size: 13px; }
.direction-form label { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; cursor: pointer; }
.direction-form label input[type="radio"] { accent-color: var(--accent-strong); width: 16px; height: 16px; flex: 0 0 auto; }
.direction-form select { width: 100%; margin: 0 0 4px 24px; max-width: calc(100% - 24px); font-family: var(--sans); font-size: 13px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); font-weight: 600; padding: 0 10px 10px; border-bottom: 1px solid var(--border); }
.log-table td { padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.log-table tr:last-child td { border-bottom: none; }
.log-time { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--text-muted); white-space: nowrap; }

.note { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.top-nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; font-size: 13px; }
.top-nav a { color: var(--text-muted); text-decoration: none; }
.top-nav a:hover { color: var(--accent-strong); }

.logo-badge {
  position: fixed; right: 22px; bottom: 22px; z-index: 50;
  width: 100px; height: 88px;
  background: var(--heading-chip);
  border-radius: 10px;
  box-shadow: var(--shadow); line-height: 0; overflow: hidden;
}
.logo-badge img { display: block; width: 100%; height: 100%; object-fit: contain; }

details.disclosure > summary { cursor: pointer; list-style: none; }
details.disclosure > summary::-webkit-details-marker { display: none; }
