:root {
  --color-bg: #e7ebee;
  --color-header: #5f80ad;
  --color-sidebar: #2e74bc;
  --color-primary: #2e6fd6;
  --color-hover: #66cbfe;
  --color-text: #0f2744;
  --color-muted: #4b6584;
  --color-border: rgba(95, 128, 173, 0.22);
  --radius: 10px;
  --sidebar-w: 56px;
  --header-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: #1d4fa8; }

/* —— Header —— */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: var(--color-header);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.25rem;
  min-height: var(--header-h);
  box-shadow: 0 2px 8px rgba(15, 39, 68, 0.14);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
}
.brand:hover { color: #fff; }

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #fff;
  color: #0f2744;
  border-radius: 6px;
  padding: 0.2rem 0.55rem 0.2rem 0.3rem;
  box-shadow: 0 1px 2px rgba(15, 39, 68, 0.12);
}

.brand-badge img {
  height: 28px;
  width: auto;
  display: block;
  border-radius: 3px;
}

.brand-word {
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  font-weight: 800;
}

.brand-app {
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 0.95;
}

.topnav {
  display: flex;
  gap: 0.35rem;
  flex: 1;
  align-items: center;
}

.topnav a {
  color: #fff;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.topnav a:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.topnav a.active {
  background: var(--color-hover);
  color: var(--color-text);
}

.signout { margin-left: auto; }
.signout button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.65);
  color: #fff;
  border-radius: 8px;
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.signout button:hover {
  background: var(--color-hover);
  border-color: var(--color-hover);
  color: var(--color-text);
}

/* —— Sidebar —— */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.85rem 0;
  gap: 0.35rem;
  z-index: 900;
}

.sidebar-link {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.9);
  transition: background 0.15s ease;
}
.sidebar-link svg { width: 20px; height: 20px; }
.sidebar-link:hover,
.sidebar-link.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}
.sidebar-link-bottom { margin-top: auto; }

/* —— Main —— */
main {
  max-width: none;
  margin: 0;
  padding: 1.5rem 1.75rem 2.5rem;
  padding-top: calc(var(--header-h) + 1.5rem);
  width: 100%;
  min-width: 0;
}

main.with-sidebar {
  padding-left: calc(var(--sidebar-w) + 1.75rem);
  max-width: none;
}

.page-title {
  margin: 0 0 1rem;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text);
  text-transform: none;
}

/* —— Sync status page (v1 alignment) —— */
.sync-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.sync-page-head .page-title { margin: 0; }
.sync-page-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.sync-page-meta .last-updated {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-muted);
  margin-right: 0.25rem;
}

.sync-dash {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1.2fr;
  grid-template-areas:
    "health last volume recent"
    "queue  queue queue  recent";
  gap: 1rem;
  align-items: stretch;
}
.dash-health { grid-area: health; margin: 0; }
.dash-last { grid-area: last; margin: 0; }
.dash-volume { grid-area: volume; margin: 0; }
.dash-recent {
  grid-area: recent;
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.dash-queue { grid-area: queue; margin: 0; }

.dash-recent .history-wrap {
  flex: 1;
  overflow: auto;
  max-height: none;
  min-height: 12rem;
}
.history.compact th:last-child,
.history.compact td:last-child {
  text-align: right;
  white-space: nowrap;
  width: 5.5rem;
}

.volume-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}
.volume-head .kicker { margin: 0; }
.volume-head input[type="date"] {
  width: auto;
  padding: 0.25rem 0.4rem;
  font-size: 0.78rem;
}

.live-next {
  margin: 0.7rem 0 0;
  padding: 0.45rem 0.65rem;
  background: #f0f3f7;
  border-radius: 6px;
  font-size: 0.85rem;
}

.eta-line {
  margin: 0.5rem 0 0;
  font-size: 0.82rem;
}

.queue-search {
  position: relative;
  margin-bottom: 0.75rem;
}
.queue-search-icon {
  position: absolute;
  left: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-muted);
  font-size: 0.95rem;
  pointer-events: none;
}
.queue-search input {
  padding-left: 2rem;
  background: #f3f5f8;
  border-color: #e1e6ed;
}

.tl-line.on { background: var(--color-primary); }

h2, h3 { margin: 0 0 0.5rem; font-weight: 700; color: var(--color-text); }
.lede { font-size: 1.05rem; color: var(--color-muted); margin: 0; }
.muted { color: var(--color-muted); font-size: 0.875rem; }

/* —— Cards / forms —— */
.card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin: 0 0 1.15rem;
  box-shadow: 0 1px 3px rgba(15, 39, 68, 0.05), 0 4px 12px rgba(15, 39, 68, 0.04);
  min-width: 0;
}

.auth-card { max-width: 420px; margin: 3rem auto; }

label {
  display: block;
  margin: 0.75rem 0 0.35rem;
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text);
}

input, select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(95, 128, 173, 0.35);
  border-radius: 8px;
  font: inherit;
  color: var(--color-text);
  background: #fff;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(46, 111, 214, 0.15);
}
input:disabled { background: #f3f5f8; color: var(--color-muted); }

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  cursor: pointer;
}
.check input { width: auto; margin: 0; }

button, .button {
  background: #fff;
  border: 1px solid rgba(95, 128, 173, 0.4);
  color: var(--color-text);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
button:hover, .button:hover {
  background: #eef3f9;
}

.primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.primary:hover {
  background: #2560c0;
  border-color: #2560c0;
  color: #fff;
}
.primary:disabled,
.primary:disabled:hover {
  opacity: 0.65;
  cursor: not-allowed;
  background: var(--color-primary);
  color: #fff;
}

.secondary {
  background: #f1f3f4;
  border-color: #dadce0;
  color: var(--color-text);
}
.secondary:hover { background: #e8eaed; }

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.banner {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin: 0 0 1.15rem;
  font-weight: 500;
}
.banner.ok { background: #e6f4ea; color: #137333; border: 1px solid #c2e7cb; }
.banner.error { background: #fce8e6; color: #c5221f; border: 1px solid #fad2cf; }

.kicker {
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-size: 0.72rem;
  color: var(--color-muted);
  margin: 0 0 0.55rem;
  font-weight: 700;
}

/* —— Control bar —— */
.control-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  margin-bottom: 1.15rem;
}
.control-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.control-label {
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
  white-space: nowrap;
  font-size: 0.9rem;
}
#dashboard-date { width: auto; padding: 0.4rem 0.65rem; }
.last-updated-group {
  flex: 1;
  justify-content: center;
  color: var(--color-muted);
}
.control-actions {
  display: flex;
  gap: 0.6rem;
  margin-left: auto;
}
.inline-form { margin: 0; }

/* —— Live activity —— */
.live-activity-card { margin-bottom: 1.15rem; }

.phase-bar {
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 36px;
  margin: 0.85rem 0 0;
  position: relative;
  padding-right: 7.5rem;
}

.phase-seg {
  position: relative;
  flex: 1;
  background: #e7ebf1;
  border-radius: 7px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.phase-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 7px;
  transition: width 0.4s ease;
}
.phase-extract .phase-fill { background: #2e6fd6; }
.phase-publish .phase-fill { background: #7fc98f; }
.phase-transcribe .phase-fill { background: #e0a83a; }

.phase-seg.indeterminate .phase-fill,
.phase-seg.current .phase-fill {
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 6px,
    rgba(255, 255, 255, 0.22) 6px,
    rgba(255, 255, 255, 0.22) 12px
  );
  background-size: 34px 34px;
  animation: phase-stripe-slide 1s linear infinite;
}

@keyframes phase-stripe-slide {
  from { background-position: 0 0; }
  to { background-position: 34px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .phase-seg.indeterminate .phase-fill,
  .phase-seg.current .phase-fill {
    animation: none;
  }
}

.phase-text {
  position: relative;
  z-index: 1;
  font-size: 0.78rem;
  font-weight: 700;
  color: #0f2744;
  padding: 0 0.45rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.phase-total-count {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
  white-space: nowrap;
}

/* —— Process review card —— */
.process-review-card {
  margin-top: 1rem;
  padding: 1.1rem;
}
.process-review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin: 0.6rem 0 0.9rem;
}
.process-review-col {
  min-width: 0;
}
.process-review-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  margin: 0 0 0.3rem;
}
.process-review-value {
  margin: 0 0 0.2rem;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.process-review-sub {
  margin: 0.1rem 0 0;
  font-size: 0.8rem;
}
.process-review-log-label {
  margin-top: 0.4rem;
}

.terminal-log {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  height: 11rem;
  overflow-y: auto;
  font-family: "Cascadia Code", "Consolas", ui-monospace, monospace;
}
.terminal-line {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #d4d4d4;
  white-space: pre-wrap;
  word-break: break-word;
}
.terminal-line:last-child {
  margin-bottom: 0;
}
.terminal-line::before {
  content: "> ";
  color: #6a9955;
}
.terminal-line-muted {
  color: #808080;
  font-style: italic;
}
.terminal-line-muted::before {
  content: "";
}

.process-review-recent {
  margin-top: 0.9rem;
}
.process-review-recent summary {
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-muted);
}
.process-review-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
  font-size: 0.82rem;
}
.process-review-table th,
.process-review-table td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--color-border);
}
.process-review-detail {
  max-width: 26rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .process-review-grid {
    grid-template-columns: 1fr;
  }
}

/* —— Status cards (shared) —— */
.sync-dash .card {
  min-height: 11rem;
  padding: 1.1rem;
  overflow: hidden;
}
.card-body-text {
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.7em;
}

.dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.dot.green { background: #2e9b4f; }
.dot.yellow { background: #d4a017; }
.dot.orange { background: #d9730d; }
.dot.red { background: #c0392b; }
.dot.gray { background: #5f6368; }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge.green { background: #e6f4ea; color: #137333; }
.status-badge.red { background: #fce8e6; color: #c5221f; }
.status-badge.yellow { background: #fef7e0; color: #b06000; }
.status-badge.orange { background: #fdecdc; color: #b5540b; }
.status-badge.gray { background: #f1f3f4; color: #5f6368; }

.status-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin: 0.4rem 0 0;
}

.health-card { text-align: center; }
.gauge-wrap {
  position: relative;
  width: 140px;
  height: 90px;
  margin: 0.35rem auto 0.15rem;
}
.gauge-value {
  position: absolute;
  left: 50%;
  bottom: 0.2rem;
  transform: translateX(-50%);
  font-size: 1.4rem;
  font-weight: 800;
}

.sync-timeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 0.6rem 0 0.2rem;
  padding: 0 0.35rem;
}
.tl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d5dbe3;
  flex-shrink: 0;
}
.tl-dot.on { background: var(--color-primary); }
.tl-line {
  flex: 1;
  height: 2px;
  background: #d5dbe3;
}
.sync-timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--color-muted);
  margin-bottom: 0.55rem;
  padding: 0 0.1rem;
}

.volume-mini {
  height: 90px;
  position: relative;
}

.pending-queue-list {
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.pending-queue-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
  border-bottom: 1px solid #eef1f6;
  padding-bottom: 0.35rem;
}
.pending-queue-list li:last-child { border-bottom: none; padding-bottom: 0; }
.pending-queue-list li span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attention-banner { margin: 0 0 1.15rem; }

/* —— Charts / tables —— */
.chart-container {
  position: relative;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}
.chart-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  color: var(--color-muted);
  font-style: italic;
  font-size: 0.9rem;
  text-align: center;
  pointer-events: none;
}
.chart-empty.static {
  position: static;
  min-height: 4rem;
}

.recent-link {
  margin: 0.75rem 0 0;
  font-weight: 600;
}

.history-wrap { width: 100%; overflow-x: auto; }

.history-table-card {
  margin: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  /* overflow must stay visible so sticky can use the viewport (not a nested scroller) */
  overflow: visible;
  --history-pager-h: 3.35rem;
}

.history-table-scroll {
  width: 100%;
  max-height: none;
  overflow: visible;
}

.history {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}
.history th, .history td {
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid #e8edf3;
  font-size: 0.875rem;
}
.history th {
  color: var(--color-muted);
  font-weight: 700;
  background: #f5f7fa;
  text-transform: none;
  font-size: 0.8rem;
}

/* Pagination sticks directly under the fixed topbar */
.history-pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1.15rem;
  min-height: var(--history-pager-h);
  box-sizing: border-box;
  background: #fff;
  border-bottom: 1px solid #e8edf3;
}
.history-pager-top {
  position: sticky;
  top: var(--header-h);
  z-index: 110;
  box-shadow: 0 1px 0 #e8edf3;
}

/* Column headers stick under topbar + pagination while rows scroll */
.history.history-sticky thead th {
  position: sticky;
  top: var(--header-h);
  z-index: 100;
  background: #f5f7fa;
  box-shadow: 0 1px 0 #e8edf3;
}
.history.history-sticky.has-top-pager thead th {
  top: calc(var(--header-h) + var(--history-pager-h));
}

.history tbody tr:nth-child(even) { background: #fafbfc; }

.pager-meta { margin: 0; }
.pager-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}
.pager-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  text-decoration: none;
  color: var(--color-text);
}
.pager-btn.disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
}
.pager-pages {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  margin: 0 0.25rem;
}
.pager-page {
  min-width: 1.85rem;
  height: 1.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}
.pager-page:hover { background: #eef3f9; }
.pager-page.current {
  background: var(--color-primary);
  color: #fff;
}
.pager-ellipsis {
  padding: 0 0.2rem;
  color: var(--color-muted);
}

.completed-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.check-ok {
  color: #2e9b4f;
  font-weight: 800;
}
.status-spinner {
  display: inline-flex;
  align-items: center;
}

/* —— Connections —— */
.conn-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.15rem;
}
.conn-tile { margin: 0; }
.conn-tile-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.conn-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.conn-brand h2 {
  margin: 0;
  font-size: 1.15rem;
}
.conn-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
}
.conn-icon.zoom { background: #2e6fd6; }
.conn-icon.sharepoint { background: #038387; }
.conn-icon.hubspot { background: #ff7a59; }

.conn-health-label {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-muted);
}
.health-track {
  height: 8px;
  background: #e7ebf1;
  border-radius: 999px;
  overflow: hidden;
}
.health-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
}
.health-fill.green { background: #2e9b4f; }
.health-fill.yellow { background: #d4a017; }
.health-fill.red { background: #c0392b; }
.health-fill.gray { background: #9aa3ad; }
.conn-meta { margin: 0.45rem 0 0.75rem; }

.conn-details summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}
.conn-details[open] summary { margin-bottom: 0.85rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}
.form-group { display: flex; flex-direction: column; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--color-muted);
}
.form-footer-options { margin-top: 1rem; }
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}
.summary-card { margin-top: 0; }

/* —— Schedule —— */
.schedule-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  align-items: start;
}
.schedule-calendar-card { margin: 0; }
.schedule-cal-note { margin: 0 0 0.85rem; }
.mini-cal-head,
.mini-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.mini-cal-head span {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-muted);
  padding: 0.25rem 0;
}
.mini-cal-cell {
  min-height: 58px;
  background: #f7f9fb;
  border: 1px solid #e4e9ef;
  border-radius: 6px;
  padding: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.day-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-muted);
}
.cal-chip {
  font-size: 0.62rem;
  font-weight: 700;
  border-radius: 3px;
  padding: 0.1rem 0.25rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-chip.day {
  background: #e8f5ec;
  color: #137333;
  border: 1px dashed #8fcea0;
}
.cal-chip.night {
  background: #2e9b4f;
  color: #fff;
}

.rules-card { margin: 0 0 1rem; }
.rule-block { margin-bottom: 1.1rem; }
.rule-block h3 {
  font-size: 0.95rem;
  margin: 0 0 0.55rem;
}
.rule-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.rule-list li {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  padding: 0.55rem 0.65rem;
  background: #f7f9fb;
  border: 1px solid #e4e9ef;
  border-radius: 8px;
  font-size: 0.88rem;
}
.rule-list li div {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.rule-check {
  color: #2e9b4f;
  font-weight: 800;
}
.tag-row { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tag {
  background: #e8f0fb;
  color: var(--color-primary);
  border: 1px solid #c5d7f2;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.schedule-form-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.form-section {
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: #f8fafc;
}
.form-section h3 {
  margin: 0 0 0.65rem;
  font-size: 1rem;
}

/* —— History —— */
.history-total-range {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
}
.history-total-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}
.history-total-tile {
  margin: 0;
  padding: 0.9rem 1.1rem;
  text-align: center;
}
.history-total-tile .kicker { margin: 0 0 0.4rem; }
.history-total-tile .history-total-figure {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--color-text);
  line-height: 1;
}
.history-total-tile-all {
  background: var(--color-primary);
  border-color: var(--color-primary);
}
.history-total-tile-all .kicker,
.history-total-tile-all .history-total-figure {
  color: #fff;
}

.history-chart-card {
  display: flex;
  flex-direction: column;
  height: 280px;
  padding: 1rem 1.25rem;
}
.chart-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.35rem;
}
.chart-card-head .kicker { margin: 0; }
.history-chart-card .chart-container {
  flex: 1;
  min-height: 0;
}

.filter-bar { padding: 1rem 1.25rem; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  align-items: end;
}
.filter-bar .form-group {
  margin: 0;
  min-width: 0;
}
.filter-bar .form-group label {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-muted);
}
.filter-bar select {
  width: 100%;
  min-height: 2.4rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
}

/* Status dropdown keeps chip-like colors for the closed control + options where supported */
.status-select.status-all {
  background: #f1f3f4;
  color: #5f6368;
  border-color: #dadce0;
}
.status-select.status-success {
  background: #e6f0ff;
  color: #1d4fa8;
  border-color: #9bb8e8;
  font-weight: 600;
}
.status-select.status-failure {
  background: #fce8e6;
  color: #c5221f;
  border-color: #f0b4ae;
  font-weight: 600;
}
.status-select.status-waiting {
  background: #fef7e0;
  color: #b06000;
  border-color: #e8d48a;
  font-weight: 600;
}
.status-select.status-recording_only {
  background: #fdecdc;
  color: #b5540b;
  border-color: #eec49a;
  font-weight: 600;
}
.status-select.status-no_recording {
  background: #eceff1;
  color: #37474f;
  border-color: #b0bec5;
  font-weight: 600;
}
.status-select option.opt-all { background: #f1f3f4; color: #5f6368; }
.status-select option.opt-success { background: #e6f0ff; color: #1d4fa8; }
.status-select option.opt-failure { background: #fce8e6; color: #c5221f; }
.status-select option.opt-waiting { background: #fef7e0; color: #b06000; }
.status-select option.opt-recording-only { background: #fdecdc; color: #b5540b; }
.status-select option.opt-no-recording { background: #eceff1; color: #37474f; }

.filter-note { margin: 0.75rem 0 0; }
.audit-next-line { margin: -0.5rem 0 1rem; }

/* —— Responsive —— */
/* —— Full Sync modal —— */
.full-sync-modal {
  width: min(640px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow: 0 12px 40px rgba(15, 39, 68, 0.22);
}
.full-sync-modal::backdrop {
  background: rgba(15, 39, 68, 0.45);
}
.full-sync-modal-close-form {
  display: flex;
  justify-content: flex-end;
  margin: -0.5rem -0.5rem 0 0;
}
.modal-close {
  border: none;
  background: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--color-muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
}
.modal-close:hover { color: var(--color-text); }
.modal-title { margin: 0 0 0.35rem; }
.modal-subtitle { margin: 0 0 1.1rem; font-size: 0.9rem; }

.full-sync-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.full-sync-sources {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 0.85rem 1rem 1rem;
  margin: 0 0 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}
.full-sync-sources legend {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-muted);
  font-weight: 700;
  padding: 0 0.3rem;
}

.full-sync-preview-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1rem;
}

.full-sync-preview-results { margin-bottom: 1.25rem; }
.full-sync-audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.full-sync-audit-table th,
.full-sync-audit-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--color-border);
}
.full-sync-audit-table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}
.full-sync-audit-table tfoot td {
  border-bottom: none;
  border-top: 2px solid var(--color-border);
}
.full-sync-estimate-note {
  font-size: 0.78rem;
  margin: 0.6rem 0 0;
}

.full-sync-submit-actions {
  margin-top: 0.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

@media (max-width: 1100px) {
  .sync-dash {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "health last"
      "volume volume"
      "recent recent"
      "queue queue";
  }
  .schedule-layout { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  main.with-sidebar {
    padding-left: 1rem;
    max-width: none;
  }
  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    min-height: auto;
  }
  .history-pager-top {
    top: 0;
  }
  .history.history-sticky thead th {
    top: 0;
  }
  .history.history-sticky.has-top-pager thead th {
    top: var(--history-pager-h);
  }
  .topnav { flex-direction: column; width: 100%; }
  .topnav a { text-align: center; }
  .signout { margin-left: 0; }
  .signout button { width: 100%; }
  main { padding: 1rem; }
  .conn-grid { grid-template-columns: 1fr; }
  .sync-dash {
    grid-template-columns: 1fr;
    grid-template-areas:
      "health"
      "last"
      "volume"
      "recent"
      "queue";
  }
  .sync-page-head { align-items: stretch; }
  .sync-page-meta {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .sync-page-meta .inline-form,
  .sync-page-meta button { width: 100%; }
  .filter-grid { grid-template-columns: 1fr; }
  .phase-bar {
    flex-direction: column;
    height: auto;
    padding-right: 0;
    gap: 6px;
  }
  .phase-seg { height: 32px; }
  .phase-total-count {
    position: static;
    transform: none;
    text-align: right;
    margin-top: 0.25rem;
  }
  .full-sync-form-grid { grid-template-columns: 1fr; }
}
