/* ============ Service Handler — dark theme ============ */

:root {
  --bg: #0b0f14;
  --bg-soft: #0f151d;
  --panel: #121a24;
  --panel-2: #16202c;
  --border: #1f2b3a;
  --border-soft: #1a2433;
  --text: #dbe4ee;
  --text-dim: #8296ac;
  --text-faint: #5a6c80;
  --accent: #5aa9ff;
  --accent-soft: rgba(90, 169, 255, 0.12);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.13);
  --yellow: #fbbf24;
  --yellow-soft: rgba(251, 191, 36, 0.13);
  --radius: 14px;
  --radius-sm: 9px;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "Fira Code", Menlo, Consolas, monospace;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

/* ============ Service Handler — light theme ============ */

[data-theme="light"] {
  --bg: #f3f5f8;
  --bg-soft: #ffffff;
  --panel: #ffffff;
  --panel-2: #f6f8fa;
  --border: #d0d7de;
  --border-soft: #e1e4e8;
  --text: #1f2328;
  --text-dim: #59636e;
  --text-faint: #818b98;
  --accent: #0969da;
  --accent-soft: rgba(9, 105, 218, 0.1);
  --green: #1a7f37;
  --green-soft: rgba(26, 127, 55, 0.12);
  --red: #cf222e;
  --red-soft: rgba(207, 34, 46, 0.12);
  --yellow: #9a6700;
  --yellow-soft: rgba(154, 103, 0, 0.12);
  --shadow: 0 8px 24px rgba(31, 35, 40, 0.08);
}

[data-theme="light"] body {
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(9, 105, 218, 0.06), transparent 60%),
    radial-gradient(900px 420px at -10% 110%, rgba(26, 127, 55, 0.05), transparent 60%),
    var(--bg);
}

[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.88);
}

[data-theme="light"] .nav-screens {
  background: rgba(246, 248, 250, 0.94);
}

[data-theme="light"] .nav-tab.active {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: rgba(9, 105, 218, 0.4);
}

[data-theme="light"] .nav-tab.active .tab-badge {
  background: var(--accent);
  color: #ffffff;
}

[data-theme="light"] .screen-indicator-dots {
  background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .screen-dot {
  background: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .card {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .stats > div {
  background: #f6f8fa;
}

[data-theme="light"] .btn {
  background: #ffffff;
  color: var(--text);
  border-color: var(--border);
}

[data-theme="light"] .btn:hover {
  background: #f3f5f8;
  border-color: #abb4be;
}

[data-theme="light"] .btn.warn {
  color: #9a6700;
  border-color: rgba(154, 103, 0, 0.35);
  background: #fff8eb;
}

[data-theme="light"] .btn.warn:hover {
  background: #9a6700;
  color: #ffffff;
  border-color: #9a6700;
}

/* Wyraziste, czytelne przyciski przełączania worktree w trybie jasnym */
[data-theme="light"] .wt-table .btn[data-wt-switch]:not(.warn):not(:disabled) {
  background: #0969da;
  border-color: #0969da;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(9, 105, 218, 0.25);
}

[data-theme="light"] .wt-table .btn[data-wt-switch]:not(.warn):not(:disabled):hover {
  background: #0856b3;
  border-color: #0856b3;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(9, 105, 218, 0.35);
}

[data-theme="light"] .wt-table .btn.warn[data-wt-switch]:not(:disabled),
[data-theme="light"] .wt-active .btn.warn[data-wt-switch]:not(:disabled) {
  background: #9a6700;
  border-color: #9a6700;
  color: #ffffff !important;
  box-shadow: 0 2px 6px rgba(154, 103, 0, 0.25);
}

[data-theme="light"] .wt-table .btn.warn[data-wt-switch]:not(:disabled):hover,
[data-theme="light"] .wt-active .btn.warn[data-wt-switch]:not(:disabled):hover {
  background: #7d5300;
  border-color: #7d5300;
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(154, 103, 0, 0.35);
}

[data-theme="light"] .wt-table .btn[data-wt-switch]:disabled {
  background: #eef2f6;
  border-color: #d0d7de;
  color: #8c959f !important;
  box-shadow: none;
}

[data-theme="light"] .wt-chip {
  background: #eef5fc;
  color: #0969da;
  border-color: #bcd6f7;
}

[data-theme="light"] .wt-chip.warn {
  background: #fff8eb;
  color: #8a5c00;
  border-color: #f6d482;
}

[data-theme="light"] .wt-chip.main {
  background: #ebf9f0;
  color: #1a7f37;
  border-color: #a4e4b7;
}

[data-theme="light"] .wt-row-active {
  background: rgba(26, 127, 55, 0.08);
}

[data-theme="light"] .wt-row-active:hover {
  background: rgba(26, 127, 55, 0.13) !important;
}

[data-theme="light"] .wt-separator {
  background: linear-gradient(90deg, transparent, rgba(9, 105, 218, 0.25) 25%, rgba(26, 127, 55, 0.35) 50%, rgba(9, 105, 218, 0.25) 75%, transparent);
  opacity: 0.8;
}

[data-theme="light"] .drawer {
  background: #ffffff;
}

[data-theme="light"] .log-view {
  background: #0f141c;
  color: #e6edf3;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input, textarea {
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
  user-select: text;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(90, 169, 255, 0.07), transparent 60%),
    radial-gradient(900px 420px at -10% 110%, rgba(52, 211, 153, 0.05), transparent 60%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 19px; margin: 0; font-weight: 650; letter-spacing: 0.2px; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }

.sub { margin: 1px 0 0; font-size: 12.5px; color: var(--text-dim); }

/* ---------- top bar ---------- */

.topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(11, 15, 20, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  z-index: 40;
}

.brand { display: flex; align-items: center; gap: 12px; }

.logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(90, 169, 255, 0.25);
}

.top-actions { display: flex; align-items: center; gap: 12px; }

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.45); }
  50% { opacity: 0.55; box-shadow: 0 0 0 4px rgba(52, 211, 153, 0); }
}

/* ---------- screen switcher bar (tabs & dots) ---------- */

.nav-screens {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 24px;
  background: rgba(15, 21, 29, 0.94);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 30;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 680px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 550;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
  white-space: nowrap;
}

.nav-tab:hover {
  color: var(--text);
  border-color: var(--border);
  background: var(--panel-2);
}

.nav-tab.active {
  color: #fff;
  background: var(--accent-soft);
  border-color: rgba(90, 169, 255, 0.45);
  box-shadow: 0 0 14px rgba(90, 169, 255, 0.15);
}

.tab-icon {
  flex-shrink: 0;
  opacity: 0.75;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-tab.active .tab-icon {
  opacity: 1;
  color: var(--accent);
  transform: scale(1.08);
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: all 0.2s ease;
}

.nav-tab.active .tab-badge {
  background: var(--accent);
  color: #0b0f14;
  font-weight: 700;
}

/* dots indicator */
.screen-indicator-dots {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  cursor: pointer;
  user-select: none;
}

.screen-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transition: all 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  display: inline-block;
}

.screen-dot.active {
  width: 20px;
  border-radius: 4px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(90, 169, 255, 0.5);
}

/* ---------- swipe layout & book-like paging ---------- */

.swipe-viewport {
  flex: 1;
  width: 100%;
  overflow: hidden;
  position: relative;
  touch-action: pan-y pinch-zoom;
  display: flex;
  flex-direction: column;
}

.swipe-track {
  display: flex;
  width: 500%;
  height: 100%;
  will-change: transform;
  transform: translateX(0%);
}

.swipe-screen {
  width: 20%;
  flex: 0 0 20%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.screen-inner {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 12.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-dim);
  margin-bottom: 14px;
}

.section-head .section-title { margin-bottom: 0; }

/* ---------- service cards ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: border-color 0.2s ease, transform 0.15s ease;
}

.card:hover { border-color: #2b3d52; transform: translateY(-1px); }

.card-top { display: flex; align-items: flex-start; gap: 11px; }

.card-id { flex: 1; min-width: 0; }
.card-id h3 { font-size: 15.5px; font-weight: 620; margin: 0; }
.card-id p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--text-faint);
}

.card[data-state="running"] .status-dot { background: var(--green); box-shadow: 0 0 10px rgba(52, 211, 153, 0.5); }
.card[data-state="failed"] .status-dot,
.card[data-state="stopped"] .status-dot { background: var(--red); box-shadow: 0 0 10px rgba(248, 113, 113, 0.4); }
.card[data-state="transient"] .status-dot,
.card[data-state="unknown"] .status-dot { background: var(--yellow); }

.badge {
  flex: none;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.card[data-state="running"] .badge { background: var(--green-soft); border-color: rgba(52, 211, 153, 0.3); color: var(--green); }
.card[data-state="failed"] .badge,
.card[data-state="stopped"] .badge { background: var(--red-soft); border-color: rgba(248, 113, 113, 0.3); color: var(--red); }
.card[data-state="transient"] .badge,
.card[data-state="unknown"] .badge { background: var(--yellow-soft); border-color: rgba(251, 191, 36, 0.3); color: var(--yellow); }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0;
}

.stats > div {
  background: rgba(9, 13, 18, 0.5);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-width: 0;
}

.stats dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-faint);
  margin: 0;
}

.stats dd {
  margin: 3px 0 0;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats dd.ok { color: var(--green); }
.stats dd.bad { color: var(--red); }

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
}

.card-error {
  margin: 0;
  font-size: 12px;
  color: var(--red);
  word-break: break-word;
}

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 560;
  font-family: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { background: var(--panel-2); border-color: #2b3d52; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #08111c; }
.btn.primary:hover { background: #6fb4ff; }

.btn.ghost { background: transparent; }

.btn.warn { color: var(--yellow); border-color: rgba(251, 191, 36, 0.3); }
.btn.warn:hover { background: var(--yellow-soft); border-color: rgba(251, 191, 36, 0.5); }

.icon-btn {
  appearance: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--panel); }

/* ---------- pills / table ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.pill.ok { background: var(--green-soft); border-color: rgba(52, 211, 153, 0.3); color: var(--green); }
.pill.bad { background: var(--red-soft); border-color: rgba(248, 113, 113, 0.3); color: var(--red); }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}

.tunnels { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.tunnels th, .tunnels td { padding: 11px 16px; text-align: left; }
.tunnels thead th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  background: rgba(9, 13, 18, 0.4);
}
.tunnels tbody tr { border-bottom: 1px solid var(--border-soft); }
.tunnels tbody tr:last-child { border-bottom: none; }
.tunnels tbody tr:hover { background: rgba(90, 169, 255, 0.04); }
.tunnels td { font-variant-numeric: tabular-nums; }
.tunnels .t-name { font-weight: 620; }
.tunnels .t-sub { color: var(--accent); font-family: var(--mono); font-size: 12.5px; }
.tunnels .t-mono { font-family: var(--mono); font-size: 12.5px; color: var(--text-dim); }

.t-status { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.t-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.t-status.ok { color: var(--green); }
.t-status.ok::before { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.5); }
.t-status.bad { color: var(--red); }
.t-status.bad::before { background: var(--red); }
.t-status.warn { color: var(--yellow); }
.t-status.warn::before { background: var(--yellow); }

.t-err { margin-top: 3px; font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); max-width: 320px; }

.empty { padding: 22px 16px; color: var(--text-dim); font-size: 13.5px; }
.hint { margin: 10px 2px 0; font-size: 12px; color: var(--text-faint); }

/* ---------- worktree section ---------- */

.wt-active {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 0;
  font-size: 13.5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.wt-separator {
  height: 1px;
  width: 100%;
  margin: 26px 0 28px;
  background: linear-gradient(90deg, transparent, rgba(90, 169, 255, 0.35) 25%, rgba(52, 211, 153, 0.45) 50%, rgba(90, 169, 255, 0.35) 75%, transparent);
  border: none;
  opacity: 0.65;
}

.wt-active-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  font-weight: 600;
  margin-right: 2px;
}

.wt-path {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  font-weight: 550;
  word-break: break-all;
}

.wt-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  background: rgba(90, 169, 255, 0.12);
  color: var(--accent);
  border: 1px solid rgba(90, 169, 255, 0.25);
}

.wt-chip.mono {
  font-family: var(--mono);
}

.wt-chip.warn {
  background: var(--yellow-soft);
  color: var(--yellow);
  border-color: rgba(251, 191, 36, 0.3);
}

.wt-chip.main {
  background: rgba(52, 211, 153, 0.12);
  color: var(--green);
  border-color: rgba(52, 211, 153, 0.25);
}

.wt-row-active {
  background: rgba(52, 211, 153, 0.05);
}
.wt-row-active:hover {
  background: rgba(52, 211, 153, 0.09) !important;
}

.wt-table td {
  vertical-align: middle;
}

.wt-table .wt-td-action {
  text-align: right;
}

/* Przyciski przełączania worktree o wysokim kontraście */
.wt-table .btn[data-wt-switch],
.wt-active .btn[data-wt-switch] {
  font-weight: 650;
  letter-spacing: 0.2px;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.wt-table .btn[data-wt-switch]:not(.warn):not(:disabled) {
  background: linear-gradient(135deg, rgba(90, 169, 255, 0.24), rgba(90, 169, 255, 0.14));
  border: 1px solid rgba(90, 169, 255, 0.6);
  color: #d8ecff;
  box-shadow: 0 2px 10px rgba(90, 169, 255, 0.16);
}

.wt-table .btn[data-wt-switch]:not(.warn):not(:disabled):hover {
  background: var(--accent);
  color: #060e18;
  border-color: var(--accent);
  box-shadow: 0 0 16px rgba(90, 169, 255, 0.45);
  transform: translateY(-1px);
}

.wt-table .btn[data-wt-switch]:not(.warn):not(:disabled):active {
  transform: translateY(1px);
}

.wt-table .btn.warn[data-wt-switch]:not(:disabled),
.wt-active .btn.warn[data-wt-switch]:not(:disabled) {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.24), rgba(251, 191, 36, 0.14));
  border: 1px solid rgba(251, 191, 36, 0.65);
  color: #fef3c7;
  box-shadow: 0 2px 10px rgba(251, 191, 36, 0.16);
}

.wt-table .btn.warn[data-wt-switch]:not(:disabled):hover,
.wt-active .btn.warn[data-wt-switch]:not(:disabled):hover {
  background: var(--yellow);
  color: #1a1200;
  border-color: var(--yellow);
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.45);
  transform: translateY(-1px);
}

/* ---------- settings screen ---------- */

.settings-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.settings-card-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.settings-icon-wrap {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(90, 169, 255, 0.25);
  flex-shrink: 0;
}

.settings-icon-wrap.accent {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(52, 211, 153, 0.25);
}

.settings-card-title {
  font-size: 15.5px;
  font-weight: 650;
  margin: 0;
  color: var(--text);
}

.settings-card-desc {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.theme-switch-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.theme-btn {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--panel);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
  text-align: left;
}

.theme-btn:hover {
  border-color: var(--accent);
  color: var(--text);
  background: var(--panel-2);
}

.theme-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
  box-shadow: 0 0 16px rgba(90, 169, 255, 0.2);
}

.theme-btn svg {
  flex-shrink: 0;
  opacity: 0.8;
  transition: transform 0.2s ease;
}

.theme-btn.active svg {
  opacity: 1;
  color: var(--accent);
  transform: scale(1.1);
}

.theme-btn-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.theme-btn-label {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
}

.theme-btn-sub {
  font-size: 11.5px;
  color: var(--text-dim);
}

.theme-check-icon {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s ease;
}

.theme-btn.active .theme-check-icon {
  opacity: 1;
  transform: scale(1);
}

.settings-info-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 0;
}

.settings-info-list > div {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.settings-info-list dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: var(--text-faint);
  margin: 0;
}

.settings-info-list dd {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* ---------- log drawer ---------- */

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(760px, 100vw);
  height: 100dvh;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transform: translateX(103%);
  transition: transform 0.22s ease;
  z-index: 60;
}

.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}

.drawer-tools { display: flex; align-items: center; gap: 10px; }

.log-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}

.log-toolbar input[type="search"] {
  flex: 1;
  min-width: 140px;
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.log-toolbar input[type="search"]:focus { border-color: var(--accent); }
.log-toolbar input[type="search"]::placeholder { color: var(--text-faint); }

.seg {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.seg button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 6px 11px;
  cursor: pointer;
  border-right: 1px solid var(--border-soft);
}
.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent-soft); color: var(--accent); }

.log-view {
  flex: 1;
  margin: 0;
  padding: 14px 18px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12.3px;
  line-height: 1.62;
  white-space: pre-wrap;
  word-break: break-word;
  color: #c3d0de;
  background: #0a0e13;
}

.log-line { display: block; padding: 0 6px; border-radius: 5px; }
.log-line + .log-line { margin-top: 1px; }
.log-line .lt { color: var(--text-faint); margin-right: 8px; }
.log-line.error { background: rgba(248, 113, 113, 0.09); }
.log-line.error .lm { color: #fca5a5; }
.log-line.warn { background: rgba(251, 191, 36, 0.07); }
.log-line.warn .lm { color: #fcd34d; }

.log-foot {
  padding: 8px 18px;
  border-top: 1px solid var(--border-soft);
  font-size: 12px;
  color: var(--text-dim);
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13.5px;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 80;
  max-width: min(560px, 90vw);
}

.toast.ok { border-color: rgba(52, 211, 153, 0.4); }
.toast.warn { border-color: rgba(251, 191, 36, 0.45); }
.toast.err { border-color: rgba(248, 113, 113, 0.45); }

/* ---------- login ---------- */

.login-body {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
}

.login-card {
  width: min(380px, 100%);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 38px 34px 32px;
  display: grid;
  gap: 10px;
  justify-items: center;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 17px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(90, 169, 255, 0.25);
  margin-bottom: 8px;
}

.pin-label {
  align-self: start;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-faint);
}

.login-card input {
  width: 100%;
  padding: 13px 14px;
  font-size: 22px;
  letter-spacing: 10px;
  text-align: center;
  font-family: var(--mono);
  color: var(--text);
  background: rgba(9, 13, 18, 0.55);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(90, 169, 255, 0.15); }

.login-error { margin: 0; font-size: 13px; color: var(--red); min-height: 18px; }
.login-card .btn.primary { width: 100%; padding: 11px; margin-top: 4px; font-size: 14px; }

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .nav-screens { padding: 6px 10px; gap: 8px; }
  .nav-tabs { max-width: 100%; width: 100%; }
  .nav-tab { flex: 0 0 auto; min-width: max-content; padding: 7px 13px; font-size: 13px; gap: 6px; }
  .screen-inner { padding: 16px 14px 70px; gap: 18px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .live-pill #refresh-time { display: none; }
  .card { padding: 15px 15px 14px; }
}

/* --- small phones: table -> cards, compressed chrome --- */
@media (max-width: 600px) {
  h1 { font-size: 16.5px; }
  .logo { width: 34px; height: 34px; border-radius: 9px; }
  .logo svg { width: 18px; height: 18px; }
  .btn { padding: 7px 10px; }
  .card-actions { flex-wrap: wrap; }
  .card-actions .btn { flex: 1 1 auto; }
  .section-head { flex-wrap: wrap; }
  .hint { display: none; }

  /* nav-tabs scroll horizontally on small screens */
  .screen-indicator-dots { display: none; }
  .nav-screens { padding: 6px 8px; }
  .nav-tabs { max-width: 100%; width: 100%; }
  .nav-tab { flex: 0 0 auto; min-width: max-content; padding: 7px 12px; font-size: 12.5px; gap: 5px; }
  .tab-icon { width: 14px; height: 14px; }
  .theme-switch-group { grid-template-columns: 1fr; }
  .settings-info-list { grid-template-columns: 1fr; }

  /* tables: table -> stacked cards */
  .table-wrap { border: none; border-radius: 0; background: transparent; overflow: visible; }
  .tunnels { min-width: 0; font-size: 13px; }
  .tunnels thead { display: none; }
  .tunnels tbody tr {
    display: flex;
    flex-direction: column;
    gap: 7px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 10px;
  }
  .tunnels tbody tr:hover { background: var(--panel-2); }
  .tunnels tbody tr:last-child { margin-bottom: 0; }
  .tunnels td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    border: none;
  }
  .tunnels td::before {
    content: attr(data-label);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-faint);
    flex-shrink: 0;
    margin-right: 8px;
  }
  .tunnels .t-sub, .tunnels .t-mono {
    text-align: right;
    word-break: break-all;
  }
  .t-err { max-width: none; text-align: right; }

  /* wt-table card adjustments */
  .wt-active {
    padding: 10px 12px;
    gap: 6px 10px;
  }
  .wt-active .btn {
    width: 100%;
    margin-top: 4px;
    justify-content: center;
  }
  .wt-table tbody tr.wt-row-active {
    border-color: rgba(52, 211, 153, 0.4);
    background: linear-gradient(180deg, rgba(52, 211, 153, 0.08), var(--panel));
  }
  .wt-table .wt-td-path {
    font-weight: 600;
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 6px;
    margin-bottom: 2px;
  }
  .wt-table .wt-td-action {
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border-soft);
    justify-content: stretch;
  }
  .wt-table .wt-td-action::before {
    display: none;
  }
  .wt-table .wt-td-action .btn {
    width: 100%;
    padding: 8px 12px;
    justify-content: center;
    font-size: 13.5px;
  }

  /* drawer: full screen, toolbar stacked */
  .drawer { width: 100vw; border-left: none; }
  .log-toolbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 14px; }
  .log-toolbar input[type="search"] { width: 100%; min-width: 0; }
  .seg { display: flex; }
  .seg button { flex: 1; }
  .log-view { padding: 12px 14px; font-size: 11.8px; }
  .log-foot { padding: 8px 14px; }
}

/* --- very small phones --- */
@media (max-width: 390px) {
  .topbar { padding: 10px 12px; }
  .nav-screens { padding: 5px 6px; }
  .nav-tab { flex: 0 0 auto; min-width: max-content; padding: 6px 11px; font-size: 11.5px; gap: 4px; }
  .tab-badge { min-width: 16px; height: 16px; font-size: 9.5px; padding: 0 4px; }
  .screen-inner { padding: 12px 10px 60px; gap: 14px; }
  h1 { font-size: 15.5px; }
  .sub { font-size: 11.5px; }
  .card { gap: 11px; padding: 13px 12px 12px; }
  .card-id h3 { font-size: 14.5px; }
  .stats > div { padding: 7px 8px; }
  .stats dd { font-size: 12px; }
  .badge { font-size: 10.5px; padding: 2px 8px; }
  .icon-btn { width: 34px; height: 34px; }
  .toast { font-size: 12.5px; padding: 10px 14px; }
}

/* notch / safe areas */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .log-foot { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(22px + env(safe-area-inset-bottom)); }
}

/* ============ Git & Repo Screen Styles ============ */

.section-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hint-small {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-faint);
}

.section-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn.secondary.sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-soft);
  color: var(--text);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn.secondary.sm:hover {
  background: var(--panel-2);
  border-color: var(--accent);
  color: var(--accent);
}

.git-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.git-metric-card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.git-metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  color: var(--text-faint);
}

.git-metric-val {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.git-metric-val.mono {
  font-family: var(--mono);
}

.git-metric-val.mono-dim {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.git-metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.git-metric-card-interactive {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.git-metric-card-interactive.is-dirty {
  cursor: pointer;
}

.git-metric-card-interactive.is-dirty:hover {
  border-color: rgba(251, 191, 36, 0.4);
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.08);
}

.git-dirty-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--yellow-soft);
  color: var(--yellow);
  border: 1px solid rgba(251, 191, 36, 0.3);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1.4;
}

.git-dirty-toggle-btn:hover {
  background: rgba(251, 191, 36, 0.22);
  border-color: var(--yellow);
}

.git-dirty-chevron {
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.git-dirty-toggle-btn[aria-expanded="true"] .git-dirty-chevron {
  transform: rotate(180deg);
}

.git-dirty-dropdown {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  margin-top: 2px;
  animation: gitDropdownSlide 0.22s ease-out;
}

@keyframes gitDropdownSlide {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.git-dirty-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.git-dirty-dropdown-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 650;
  color: var(--yellow);
}

.git-dirty-table-wrap {
  max-height: 280px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}

.git-dirty-table {
  width: 100%;
  margin: 0;
}

.git-file-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.git-file-badge.modified {
  background: var(--yellow-soft);
  color: var(--yellow);
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.git-file-badge.untracked {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(90, 169, 255, 0.25);
}

.git-file-badge.added {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.git-file-badge.deleted {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(248, 113, 113, 0.25);
}

.git-file-badge.renamed {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.25);
}

.git-file-badge.conflict {
  background: var(--red);
  color: #fff;
  border: 1px solid #fff;
  font-weight: 700;
}

.git-file-path {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
}

.git-subcard {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

.git-subcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.git-subcard-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
}

.git-filter-group {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 3px;
}

.btn-filter {
  border: none;
  background: transparent;
  color: var(--text-dim);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-filter:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.btn-filter.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.badge-server-ok {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(52, 211, 153, 0.3);
  white-space: nowrap;
}

.badge-server-local {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--yellow-soft);
  color: var(--yellow);
  border: 1px solid rgba(251, 191, 36, 0.35);
  white-space: nowrap;
}

.badge-server-main {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(90, 169, 255, 0.35);
  white-space: nowrap;
}

.commit-hash-btn {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--accent);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
}

.commit-hash-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.commit-subject-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.commit-subject-text {
  font-size: 13px;
  font-weight: 550;
  color: var(--text);
  word-break: break-word;
}

.commit-decor-chip {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-dim);
  white-space: nowrap;
}

.commit-decor-chip.head {
  border-color: rgba(90, 169, 255, 0.45);
  color: var(--accent);
  background: var(--accent-soft);
}

.commit-decor-chip.remote {
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--green);
  background: var(--green-soft);
}

.git-author-cell {
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.git-date-cell {
  font-size: 12px;
  color: var(--text-faint);
  white-space: nowrap;
}
