/* Palette mirrors pa-webapp (ITPA): gray neutrals, indigo-500 accent, Inter,
   class-based dark mode, rounded-2xl cards. */
:root {
  --bg: #f9fafb;          /* gray-50  */
  --card: #ffffff;
  --text: #111827;        /* gray-900 */
  --muted: #6b7280;       /* gray-500 */
  --muted-2: #9ca3af;     /* gray-400 */
  --border: #e5e7eb;      /* gray-200 */
  --border-soft: #f3f4f6; /* gray-100 */
  --accent: #6366f1;      /* indigo-500 */
  --accent-hover: #4f46e5;/* indigo-600 */
  --accent-soft: #eef2ff; /* indigo-50 */
  --ok: #16a34a;          /* green-600 */
  --ok-bg: #f0fdf4;       /* green-50 */
  --ok-border: #bbf7d0;   /* green-200 */
  --err: #dc2626;         /* red-600 */
  --err-bg: #fef2f2;      /* red-50 */
  --err-border: #fecaca;  /* red-200 */
  --amber: #b45309;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --shadow: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.06);
}
:root.dark {
  --bg: #111827;          /* gray-900 */
  --card: #1f2937;        /* gray-800 */
  --text: #f3f4f6;        /* gray-100 */
  --muted: #9ca3af;       /* gray-400 */
  --muted-2: #6b7280;     /* gray-500 */
  --border: #374151;      /* gray-700 */
  --border-soft: #374151;
  --accent: #6366f1;
  --accent-hover: #818cf8;/* indigo-400 */
  --accent-soft: rgba(99,102,241,.15);
  --ok: #4ade80;          /* green-400 */
  --ok-bg: rgba(34,197,94,.10);
  --ok-border: rgba(34,197,94,.30);
  --err: #f87171;         /* red-400 */
  --err-bg: rgba(239,68,68,.10);
  --err-border: rgba(239,68,68,.30);
  --amber: #fbbf24;
  --amber-bg: rgba(245,158,11,.10);
  --amber-border: rgba(245,158,11,.30);
  --shadow: 0 10px 15px -3px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s, color .2s;
}

.wrap { max-width: 600px; margin: 0 auto; padding: 40px 20px 64px; }

/* Header */
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo-tile {
  width: 40px; height: 40px; border-radius: 12px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; flex: none;
  box-shadow: var(--shadow);
}
.eyebrow {
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent);
}
h1 { font-size: 24px; font-weight: 700; margin: 2px 0 0; letter-spacing: -.01em; }

.icon-btn {
  border: 1px solid var(--border); background: var(--card); color: var(--muted);
  width: 36px; height: 36px; border-radius: 10px; cursor: pointer; flex: none;
  display: flex; align-items: center; justify-content: center; transition: background .15s, color .15s;
}
.icon-btn:hover { color: var(--text); background: var(--border-soft); }
.icon-btn .sun { display: none; } .icon-btn .moon { display: block; }
:root.dark .icon-btn .sun { display: block; } :root.dark .icon-btn .moon { display: none; }

.lede { color: var(--muted); font-size: 14px; margin: 18px 0 22px; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 999px; margin-left: 6px; vertical-align: middle;
}
.badge[hidden] { display: none; }
.badge-amber { color: var(--amber); background: var(--amber-bg); border: 1px solid var(--amber-border); }

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--border-soft); border-radius: 16px;
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 14px; }
.step-no {
  width: 28px; height: 28px; border-radius: 999px; flex: none;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.card-title { flex: 1; min-width: 0; }
.card-title h2 { font-size: 16px; font-weight: 600; margin: 0; }
.card-title p { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.card-title em { font-style: normal; color: var(--text); font-weight: 500; }

/* Buttons */
.btn {
  border: none; border-radius: 10px; padding: 10px 16px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer; flex: none; transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-accent { background: #111827; color: #fff; }
:root.dark .btn-accent { background: #f3f4f6; color: #111827; }
.btn-accent:hover:not(:disabled) { background: #374151; }
:root.dark .btn-accent:hover:not(:disabled) { background: #e5e7eb; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.busy { opacity: .6; cursor: progress; }

.gate-hint { font-size: 12px; color: var(--muted-2); margin: 10px 0 0; padding-left: 42px; }
.gate-hint[hidden] { display: none; }

/* Per-card options (subfolder input, dry-run toggle) */
.card-options { margin-top: 12px; padding-left: 42px; }
.card-options label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.card-options input[type="text"] {
  width: 100%; box-sizing: border-box; font-family: inherit; font-size: 13px;
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
.card-options input[type="text"]:focus { outline: none; border-color: var(--accent); }
.card-options input[type="text"]::placeholder { color: var(--muted-2); }
.card-options label.checkbox {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text);
  cursor: pointer; margin: 0;
}
.card-options label.checkbox input { accent-color: var(--accent); width: 15px; height: 15px; }

/* Panel */
.panel { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border-soft); }
.panel[hidden] { display: none; }

.current { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-height: 18px; margin-bottom: 12px; }
.current[hidden] { display: none; }
.spinner {
  width: 14px; height: 14px; border-radius: 999px; flex: none;
  border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checklist li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; }
.ck-icon { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.ck-body { min-width: 0; }
.ck-label { font-weight: 500; }
.ck-detail { font-size: 12px; color: var(--muted); word-break: break-word; }
.ck-pending .ck-label { color: var(--muted-2); }
.ck-pending .ck-icon { color: var(--border); }
.ck-active .ck-label { color: var(--text); }
.ck-done .ck-label { color: var(--text); }
.ck-done .ck-icon { color: var(--ok); }
.ck-error .ck-icon { color: var(--err); }
.ck-error .ck-label { color: var(--err); }

.dot { width: 14px; height: 14px; border: 2px solid currentColor; border-radius: 999px; display: inline-block; }

/* Progress */
.progress { margin-top: 14px; height: 8px; background: var(--border-soft); border-radius: 999px; overflow: hidden; }
.progress[hidden] { display: none; }
.progress-bar { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .3s ease; }
.progress-label { margin-top: 6px; font-size: 12px; color: var(--muted); }
.progress-label[hidden] { display: none; }

/* Notices */
.notice { margin-top: 14px; padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.notice[hidden] { display: none; }
.notice-ok { background: var(--ok-bg); border: 1px solid var(--ok-border); color: var(--ok); }
.notice-error { background: var(--err-bg); border: 1px solid var(--err-border); color: var(--err); }
.notice a { color: inherit; font-weight: 600; }
.report-links { margin-top: 8px; display: flex; gap: 14px; flex-wrap: wrap; }
.report-links a { font-size: 12px; }

#global-error { margin-bottom: 16px; }

.foot { margin-top: 26px; font-size: 12px; color: var(--muted-2); text-align: center; }

/* --- Production build: auth + dashboard --- */
.wrap-narrow { max-width: 440px; }
.muted { color: var(--muted); font-size: 13px; }
.user-box { display: flex; align-items: center; gap: 12px; }

.card-centered { text-align: center; padding: 28px 24px; }
.card-centered h2 { font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.card-centered p { margin: 0 0 18px; }

.btn-block { display: block; width: 100%; text-align: center; text-decoration: none; box-sizing: border-box; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
a.btn { text-decoration: none; }
.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 6px 12px; font-size: 13px;
}
.btn-ghost:hover:not(:disabled) { color: var(--text); background: var(--border-soft); }

.badge-ok { color: var(--ok); background: var(--ok-bg); border: 1px solid var(--ok-border); }

.conn-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.conn-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.conn-name { font-size: 14px; font-weight: 500; }
.conn-list .muted { flex-basis: 100%; }
.inline-form { margin: 0; display: inline; }

/* --- admin console ------------------------------------------------------ */
.wrap-wide { max-width: 1100px; }

/* Wide tables scroll inside their own box; the page never scrolls sideways. */
.table-scroll { margin-top: 14px; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
table.data th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted-2); font-weight: 600; white-space: nowrap;
}
table.data tr:last-child td { border-bottom: none; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.nowrap { white-space: nowrap; }
table.data td.detail {
  color: var(--muted); max-width: 340px; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px;
}
.cell-sub { font-size: 11px; color: var(--muted-2); margin-top: 2px; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: var(--border-soft); color: var(--muted);
}
.pill-done { color: var(--ok); background: var(--ok-bg); }
.pill-error { color: var(--err); background: var(--err-bg); }
.pill-running, .pill-verifying { color: var(--accent); background: var(--accent-soft); }
.pill-throttled, .pill-pending { color: var(--amber); background: var(--amber-bg); }

/* --- admin tabs --------------------------------------------------------- */
.tabs {
  display: flex; gap: 4px; flex-wrap: wrap; margin: 18px 0 -6px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.tabs .tab {
  appearance: none; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 10px 14px; border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs .tab:hover { color: var(--text); background: var(--border-soft); }
.tabs .tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }
.tabs .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
[hidden] { display: none !important; }

/* Two URLs in, one copy out. Stacked labels because a pasted Drive or Dropbox
   address is far too long to sit on an inline filter row. */
.url-form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.url-form .field { display: flex; flex-direction: column; gap: 5px; max-width: 640px; }
.url-form .field-label { font-size: 13px; font-weight: 600; }
.url-form .field-hint { font-size: 12px; color: var(--muted); }
.url-form input[type="text"] {
  padding: 9px 12px; border-radius: 8px; font: inherit; font-size: 13px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
}
.url-form input[type="text"]:focus { outline: none; border-color: var(--accent); }
.url-form button { align-self: flex-start; }

/* Tracker: counts first, then a row per person. Read from across a room during
   a migration weekend, so the numbers are large and the bars are thin. */
.tally { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.tally-item {
  flex: 1 1 120px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card);
}
.tally-n { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; }
.tally-label { font-size: 12px; color: var(--muted); }

.track-progress { min-width: 220px; }
/* The state cell carries a pill plus up to three sub-lines — a reassurance, a
   stall warning, a failure explained in a full sentence. Left to size itself it
   collapses to a ribbon and turns one stopped row into five lines, which is
   most of what made a stopped migration look worse than it is. Sized to the
   widest this table can go and still fit the 1100px page: past that it scrolls
   sideways and the Restart button is the column that falls off the edge. */
#tracker-table td:nth-child(4) { min-width: 185px; }
/* "Paused for today" and "Personal Dropbox" both wrap mid-phrase in a narrow
   column, which reads as two separate facts. */
.data .pill { white-space: nowrap; }
.track-source { white-space: nowrap; }
.minibar {
  height: 6px; border-radius: 999px; overflow: hidden;
  background: var(--border-soft); margin-bottom: 6px;
}
.minibar span { display: block; height: 100%; background: var(--accent); }
.cell-sub.warn { color: var(--amber); font-weight: 600; }

/* The run-book above the team-folder form. Numbered because the order is
   load-bearing: the Shared Drive has to exist before its address exists. */
.steps { margin: 16px 0 0; padding-left: 20px; display: grid; gap: 8px; }
.steps li { font-size: 13px; line-height: 1.55; }
.steps li .step-note { display: block; font-size: 12px; color: var(--muted); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.filters select, .filters input[type="text"] {
  padding: 6px 10px; border-radius: 8px; font: inherit; font-size: 13px;
  border: 1px solid var(--border); background: var(--card); color: var(--text);
}
.filters select:focus, .filters input[type="text"]:focus { outline: none; border-color: var(--accent); }

/* --- migration progress ------------------------------------------------- */
.badge-err { color: var(--err); background: var(--err-bg); border: 1px solid var(--err-border); }

/* Proof of life: the worker touches the row every few seconds, and this counts
   up from that timestamp. A frozen counter means a frozen migration. */
.heartbeat { margin-top: 6px; font-size: 12px; color: var(--muted-2); display: flex; align-items: center; gap: 6px; }
.heartbeat[hidden] { display: none; }
.heartbeat::before {
  content: ""; width: 6px; height: 6px; border-radius: 999px; flex: none;
  background: var(--ok); animation: pulse 2s ease-in-out infinite;
}
.heartbeat.stalled { color: var(--amber); }
.heartbeat.stalled::before { background: var(--amber); animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* The size pass has no denominator yet, so the bar sweeps instead of filling. */
.progress.indeterminate .progress-bar {
  width: 35% !important; animation: sweep 1.4s ease-in-out infinite;
}
@keyframes sweep { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }

@media (prefers-reduced-motion: reduce) {
  .spinner, .heartbeat::before, .progress.indeterminate .progress-bar { animation: none; }
}

/* Log tail: capped height so a long-running migration can't push the page
   into the weeds; it scrolls itself. */
.logtail {
  list-style: none; margin: 14px 0 0; padding: 10px 12px;
  max-height: 180px; overflow-y: auto;
  background: var(--border-soft); border-radius: 10px;
  font-size: 12px; line-height: 1.6; color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  word-break: break-word;
}
.logtail[hidden] { display: none; }
.logtail li + li { margin-top: 2px; }
.log-error, .log-critical, .log-fatal { color: var(--err); }
.log-warning { color: var(--amber); }
