/* Zonda CRM — Clinical Light + Ops Dark themes */

:root,
[data-theme="light"] {
  --bg: #f8fafc;
  --bg-deep: #f8fafc;
  --surface: #ffffff;
  --hover: #f1f5f9;
  --border: #e2e8f0;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --accent-contrast: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --terminal: #0f172a;
  --terminal-text: #e2e8f0;
  --ok: #10b981;
  --ok-soft: #ecfdf5;
  --ok-border: #a7f3d0;
  --ok-text: #047857;
  --warn: #f59e0b;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #b45309;
  --bad: #ef4444;
  --bad-soft: #fef2f2;
  --bad-border: #fecaca;
  --bad-text: #dc2626;
  --primary-btn: #0f172a;
  --primary-btn-hover: #000000;
  --primary-btn-text: #ffffff;

  /* legacy aliases */
  --bg-elevated: var(--surface);
  --panel: var(--surface);
  --panel-2: var(--hover);
  --line: var(--border);
  --line-strong: #cbd5e1;
  --faint: #94a3b8;
  --accent-2: var(--accent-hover);
  --ok-soft-legacy: var(--ok-soft);
  --bad-soft-legacy: var(--bad-soft);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --radius: 8px;
  --radius-sm: 6px;
  --font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.2);
  --header-h: 48px;
  --nav-w: 180px;
  color-scheme: light;
}

/* Ops Dark — ai_studio_code (1).html */
[data-theme="dark"] {
  --bg: #0d1117;
  --bg-deep: #0a0d12;
  --surface: #161b22;
  --hover: #21262d;
  --border: #30363d;
  --accent: #2bb8a7;
  --accent-hover: #34d399;
  --accent-soft: rgba(43, 184, 167, 0.12);
  --accent-contrast: #0d1117;
  --text: #e6edf3;
  --muted: #8b949e;
  --terminal: #010409;
  --terminal-text: #e6edf3;
  --ok: #3fb950;
  --ok-soft: rgba(63, 185, 80, 0.12);
  --ok-border: rgba(63, 185, 80, 0.35);
  --ok-text: #3fb950;
  --warn: #d29922;
  --warn-soft: rgba(210, 153, 34, 0.12);
  --warn-border: rgba(210, 153, 34, 0.35);
  --warn-text: #d29922;
  --bad: #f85149;
  --bad-soft: rgba(248, 81, 73, 0.12);
  --bad-border: rgba(248, 81, 73, 0.35);
  --bad-text: #f85149;
  --primary-btn: #2bb8a7;
  --primary-btn-hover: #34d399;
  --primary-btn-text: #0d1117;

  --bg-elevated: var(--surface);
  --panel: var(--surface);
  --panel-2: var(--hover);
  --line: var(--border);
  --line-strong: #484f58;
  --faint: #6e7681;
  --accent-2: var(--accent-hover);
  --shadow: none;
  --focus: 0 0 0 3px rgba(43, 184, 167, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body.login-page { overflow: auto; }

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* Header: brand + user only */
.top {
  height: var(--header-h);
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

[data-theme="dark"] .top {
  box-shadow: none;
}

.shell-body {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.side-nav {
  width: var(--nav-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 0.55rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
}

.side-nav-sep {
  height: 1px;
  margin: 0.45rem 0.5rem;
  background: var(--border);
  flex-shrink: 0;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.top-right .btn.ghost,
.top-right .theme-toggle {
  height: 32px;
  padding: 0 0.65rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand p { display: none; }

.mark {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  background: var(--accent);
  color: transparent;
  font-size: 0;
  flex-shrink: 0;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 100%;
  min-height: 36px;
  height: auto;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border-bottom: 0;
  border-left: 2px solid transparent;
  text-align: left;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}

.tab:hover {
  color: var(--text);
  background: var(--hover);
}

.tab.active {
  color: var(--text);
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 600;
}

[data-theme="dark"] .tab.active {
  background: var(--hover);
}

.user-chip {
  font-size: 13px;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip::before {
  content: none;
}

.role-pill {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  background: var(--accent-soft);
  border-radius: 4px;
  padding: 0.15rem 0.5rem;
}

main {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  flex-direction: column;
  padding: 0;
}

.panel.active { display: flex; }

/* Non-apps panels get padding */
.panel:not(#tab-apps) {
  padding: 1.25rem 1.5rem;
  overflow: auto;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.panel-head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.panel-sub {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.count-chip {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  background: var(--surface);
}

.surface,
.form-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow);
}

.form-surface {
  max-width: none;
  width: 100%;
}

.panel-center {
  width: min(520px, 100%);
  margin: 0 auto;
}

.panel-center-wide {
  width: min(760px, 100%);
}

.panel-center .form-surface,
.panel-center > .surface {
  width: 100%;
}

.panel-center .panel-head {
  margin-bottom: 1.15rem;
}

.panel-center .cards {
  margin-top: 0.25rem;
}

/* inside form-grid, actions shouldn't double top border unless form-surface child */
.form-grid > .actions {
  margin-top: 0.35rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
}

.field.grow { flex: 1; width: 100%; }

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  line-height: 1.3;
}

/* Caption when label text is not wrapped in .field-label */
label.field {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

label.field:has(> .field-label) {
  font-size: inherit;
  font-weight: inherit;
  text-transform: none;
  letter-spacing: normal;
  color: inherit;
}

label.field input,
label.field select,
label.field textarea,
.field input,
.field select,
.field textarea,
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  height: 40px;
  padding: 0 0.85rem;
  width: 100%;
  transition: border-color 0.12s, box-shadow 0.12s;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.25L6 7.75L9.5 4.25' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 12px;
  cursor: pointer;
}

[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M2.5 4.25L6 7.75L9.5 4.25' stroke='%238b949e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

textarea,
.field textarea {
  height: auto;
  min-height: 120px;
  padding: 0.75rem 0.85rem;
  resize: vertical;
  line-height: 1.5;
  margin-bottom: 0.65rem;
}

#ssh-key-text {
  min-height: 120px;
}

/* Styled file picker — input is clipped, not a full overlay (Windows Chrome whites out the page otherwise) */
.file-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 40px;
  padding: 0.35rem 0.55rem 0.35rem 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 100%;
  cursor: pointer;
  font-size: inherit;
  font-weight: inherit;
  text-transform: none;
  letter-spacing: normal;
  color: inherit;
}

.file-picker:focus-within {
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.file-picker input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.file-picker-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 0.8rem;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow);
  user-select: none;
}

.file-picker:hover .file-picker-btn {
  border-color: var(--accent);
  color: var(--accent);
}

.file-picker-name {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-picker-name.has-file {
  color: var(--text);
}

.section-title {
  margin: 0 0 1rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.theme-toggle {
  min-width: 3.75rem;
  font-variant-numeric: tabular-nums;
}

input.mono,
.mono input,
input[name="androidPackage"],
#detail-package-input,
#deploy-package-input,
#obf-bundle-id,
#obf-server-url,
input[name="webhookSecret"],
input[name="webviewTargetUrl"],
input[name="keitaroUrl"] {
  font-family: var(--mono);
  font-size: 13px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

input[readonly] {
  color: var(--muted);
  cursor: default;
}

.field-hint {
  display: block;
  margin: 0.1rem 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}

.field-hint.warn { color: var(--warn-text); }

.row { display: flex; gap: 0.5rem; align-items: center; }
.row.tight { gap: 0.4rem; }
.row.between { justify-content: space-between; align-items: flex-start; }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  height: 40px;
  padding: 0 1rem;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

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

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn.primary {
  background: var(--primary-btn);
  border-color: var(--primary-btn);
  color: var(--primary-btn-text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
  font-weight: 600;
}

.btn.primary:hover {
  background: var(--primary-btn-hover);
  border-color: var(--primary-btn-hover);
  color: var(--primary-btn-text);
}

[data-theme="dark"] .btn.primary {
  box-shadow: none;
  font-weight: 700;
}

.btn.danger {
  color: var(--bad-text);
  border-color: var(--bad-border);
  background: var(--surface);
}

.btn.danger:hover {
  background: var(--bad-soft);
  border-color: var(--bad);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--muted);
}

.btn.ghost:hover {
  color: var(--accent);
  background: transparent;
  border-color: transparent;
  text-decoration: underline;
}

.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.85rem;
}

.form-surface > .actions {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
}

.card .actions,
.card .row {
  margin-top: 0.85rem;
}

.pill {
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  color: var(--muted);
  background: var(--surface);
}

.pill.ok { color: var(--ok-text); border-color: var(--ok-border); background: var(--ok-soft); }
.pill.bad { color: var(--bad-text); border-color: var(--bad-border); background: var(--bad-soft); }
.pill.muted { color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  color: var(--muted);
  background: var(--surface);
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
}

.badge.ok {
  color: var(--ok-text);
  border-color: var(--ok-border);
  background: var(--ok-soft);
}
.badge.ok::before { background: #059669; }

.badge.warn {
  color: var(--warn-text);
  border-color: var(--warn-border);
  background: var(--warn-soft);
}
.badge.warn::before { background: var(--warn); }

.badge.bad {
  color: var(--bad-text);
  border-color: var(--bad-border);
  background: var(--bad-soft);
}
.badge.bad::before { background: var(--bad); }

.badge.muted {
  color: var(--muted);
  border-color: var(--border);
  background: var(--surface);
}

/* Apps master-detail — full bleed under header */
.apps-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.apps-list-pane {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 0;
}

.apps-list-toolbar {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  flex-shrink: 0;
}

.apps-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--bg);
}

.app-search-picker {
  position: relative;
}

.app-search-picker input[type="search"] {
  width: 100%;
}

.app-search-dropdown {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.app-search-dropdown.hidden {
  display: none;
}

.app-search-option {
  appearance: none;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font: inherit;
}

.app-search-option:last-child {
  border-bottom: 0;
}

.app-search-option:hover,
.app-search-option.active {
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.app-search-option-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.app-search-option-name {
  font-size: 13px;
  color: var(--text);
  margin-top: 0.15rem;
}

.app-search-option-meta {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  margin-top: 0.1rem;
}

.app-search-selected {
  margin: 0.35rem 0 0;
  font-size: 12px;
  line-height: 1.35;
}

.app-search-empty {
  padding: 0.75rem;
  font-size: 13px;
  color: var(--muted);
}

.app-item {
  appearance: none;
  text-align: left;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  background: transparent;
  color: inherit;
  padding: 0.75rem;
  cursor: pointer;
  font: inherit;
  transition: background 0.12s;
}

.app-item:hover { background: var(--surface); }

.app-item.active {
  background: var(--surface);
  border-left-color: var(--accent);
  box-shadow: var(--shadow);
}

.app-item-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.4rem;
  margin-bottom: 0.2rem;
}

.app-item-top .mono {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.app-item.active .app-item-top .mono {
  color: var(--accent);
}

.app-item-name {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 0.2rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-item-domain {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.app-item-domain .type-tag {
  color: var(--text);
  font-weight: 500;
}

.app-detail-pane {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1.5rem;
  background: var(--bg-deep);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 280px;
  color: var(--muted);
  text-align: center;
}

.empty-state p { margin: 0 0 0.4rem; }

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.detail-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}

.detail-title-row h3 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font);
}

.detail-meta {
  margin: 0;
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  font-family: var(--mono);
}

.detail-toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.detail-grid .span2 { grid-column: span 2; }

.env-wrap {
  position: relative;
  grid-column: span 2;
}

.env-section { margin: 0; padding: 0; overflow: hidden; }

.env-section .env-head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.env-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.env-section .env-body {
  padding: 1rem;
}

.env-lock-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.75);
  backdrop-filter: blur(4px);
  border-radius: var(--radius);
  z-index: 2;
  padding: 1.25rem;
  text-align: center;
  border: 1px solid var(--border);
}

.env-lock-overlay.hidden { display: none !important; }

.env-wrap.is-locked .env-section {
  pointer-events: none;
  opacity: 0.5;
}

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12px; }
.hint {
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 0.75rem;
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
}

.sandbox-banner {
  margin: 0;
  padding: 0.65rem 1.25rem;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.sandbox-banner code {
  font-family: var(--mono);
  font-size: 12px;
}
.hidden { display: none !important; }
.status { margin-top: 0.65rem; color: var(--muted); font-size: 12px; }
.path-line {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin: 0.85rem 0 0.75rem;
  word-break: break-all;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.1rem 1.15rem;
  align-items: start;
}

.form-grid .span2,
.checks.span2 { grid-column: span 2; }

.form-grid .inner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.15rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

.checks {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  justify-content: center;
}

.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.check input {
  width: auto;
  height: auto;
  accent-color: var(--accent);
}

.field.check {
  flex-direction: row;
  align-items: center;
  text-transform: none;
  letter-spacing: normal;
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
}

.field.check input { width: auto; height: auto; }

.type-switch {
  display: inline-flex;
  gap: 0;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.type-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 0.4rem 0.85rem;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.type-btn:hover { color: var(--text); background: var(--hover); }

.type-btn.active {
  background: var(--text);
  color: #fff;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.85rem;
}

#servers-list.cards {
  grid-template-columns: 1fr;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 100%;
  min-width: 0;
}

.card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
}

.card .meta {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.card .row {
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card .btn {
  height: 34px;
  padding: 0 0.85rem;
}

.user-card,
.server-card {
  gap: 0.85rem;
}

.user-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.user-card-identity {
  min-width: 0;
  flex: 1 1 auto;
}

.user-card-identity h3 {
  margin: 0 0 0.25rem;
}

.user-card-email {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: normal;
}

.user-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

.server-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.server-card-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.server-card-host {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.server-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}

.server-meta-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
  padding: 0.65rem 0.85rem;
  border-top: 1px solid var(--border);
}

.server-meta-row:first-child {
  border-top: 0;
}

.server-meta-row .field-label {
  margin: 0;
  padding-top: 0.15rem;
}

.server-meta-row .mono {
  font-size: 12px;
  color: var(--text);
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: normal;
}

.user-card-meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.user-card-meta .field-label {
  margin: 0;
}

.user-card-meta .mono {
  font-size: 12px;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: normal;
}

.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: auto;
  padding-top: 0.15rem;
}

.user-card-spacer {
  display: none;
}

.user-cards {
  margin-top: 0.5rem;
}

.stack { display: grid; gap: 0.65rem; }

.deploy-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.deploy-item summary {
  cursor: pointer;
  padding: 0.75rem 0.85rem;
  list-style: none;
  font-size: 13px;
}

.deploy-item summary::-webkit-details-marker { display: none; }

.android-tz-section { margin: 0; padding: 0; overflow: hidden; }

.android-tz-section .tz-head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.tz-card-body {
  padding: 0.85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.tz-card-actions {
  flex-wrap: wrap;
}

.tz-preview {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.crm-modal-panel.crm-modal-wide {
  width: min(920px, 100%);
}

.md-doc-wrap {
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 55%, var(--surface)), var(--surface));
}

.md-doc {
  max-width: 760px;
  margin: 0 auto;
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
}

.md-doc .md-h1,
.md-doc .md-h2,
.md-doc .md-h3 {
  scroll-margin-top: 1rem;
  letter-spacing: -0.01em;
}

.md-doc .md-h1 {
  margin: 0 0 0.75rem;
  font-size: 1.55rem;
  line-height: 1.25;
}

.md-doc .md-h2 {
  margin: 1.6rem 0 0.65rem;
  padding-top: 0.35rem;
  font-size: 1.15rem;
  border-top: 1px solid var(--border);
}

.md-doc .md-h3 {
  margin: 1.1rem 0 0.45rem;
  font-size: 1rem;
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
}

.md-doc .md-p {
  margin: 0 0 0.85rem;
}

.md-doc .md-hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.md-doc .md-quote {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--muted);
}

.md-doc .md-quote p {
  margin: 0;
}

.md-doc .md-list,
.md-doc .md-checklist {
  margin: 0 0 1rem 1.1rem;
  padding: 0;
}

.md-doc .md-list li,
.md-doc .md-checklist li {
  margin: 0.25rem 0;
}

.md-doc .md-checklist {
  list-style: none;
  margin-left: 0;
}

.md-doc .md-checklist .md-check::before {
  content: '☐ ';
  color: var(--muted);
}

.md-doc .md-checklist .md-check.done::before {
  content: '☑ ';
  color: var(--ok);
}

.md-doc .md-inline {
  font-family: var(--mono);
  font-size: 0.92em;
  padding: 0.08rem 0.35rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg));
  color: var(--text);
}

.md-doc .md-pre {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--terminal);
  color: var(--terminal-text);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

.md-doc .md-table-wrap {
  overflow: auto;
  margin: 0 0 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.md-doc .md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.md-doc .md-table th,
.md-doc .md-table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.md-doc .md-table th {
  background: var(--bg);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.md-doc .md-table tr:last-child td {
  border-bottom: 0;
}

.tz-text {
  width: 100%;
  min-height: 180px;
  border: 0;
  border-radius: 0;
  padding: 1rem;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  background: var(--surface);
}

.log {
  margin-top: 0.75rem;
  max-height: 360px;
  overflow: auto;
  background: var(--terminal);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  color: var(--terminal-text);
}

.obf-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 1rem;
  align-content: start;
  flex: 1;
  min-height: 0;
}

#tab-obfuscator {
  overflow: hidden;
}

#tab-obfuscator .obf-grid {
  overflow: hidden;
  align-items: stretch;
}

#tab-obfuscator .obf-grid > .stack {
  min-height: 0;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.15rem;
  scrollbar-gutter: stable;
}

#tab-obfuscator .obf-grid > .stack:last-child {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 0;
}

#tab-obfuscator .obf-grid > .stack:last-child > .surface:first-child {
  flex-shrink: 0;
}

#tab-obfuscator .jobs-surface {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.obf-app-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
  flex-shrink: 0;
  align-items: end;
}

.obf-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.85rem;
  padding: 0.65rem 0.85rem;
  flex-shrink: 0;
}

.obf-tools .hint {
  width: 100%;
  margin: 0.15rem 0 0;
}

#obf-protections {
  gap: 0.35rem 0.75rem;
}

#obf-protections .field.check {
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid transparent;
}

#obf-protections .field.check:hover {
  border-color: var(--border);
}

#tab-obfuscator .btn.wide-action {
  width: 100%;
  height: 36px;
}

#tab-obfuscator .actions {
  margin-top: 0.85rem;
}

.deploy-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.deploy-settings {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1rem 1.15rem;
  border-right: 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.deploy-log-pane {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: 0.65rem 0.85rem 0.75rem;
  max-height: 220px;
}

.deploy-log-pane .env-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.deploy-log-pane .log {
  flex: none;
  margin-top: 0.4rem;
  height: 160px;
  max-height: 160px;
  min-height: 120px;
  padding: 0.65rem 0.75rem;
  font-size: 12px;
  line-height: 1.45;
}

/* Login */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 2rem 1rem;
  background: var(--bg);
}

.login-bg { display: none; }

.login-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.login-brand { margin-bottom: 1.25rem; }
.login-brand .mark {
  width: 16px;
  height: 16px;
  color: transparent;
  font-size: 0;
}
.login-brand h1 { font-size: 16px; }

.login-form { display: grid; gap: 0.85rem; }

.toggle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 1rem 0 0;
  border-top: 1px solid var(--border);
}

.toggle-row > div {
  min-width: 0;
  flex: 1;
}

.toggle-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.3;
  margin: 0 0 0.2rem;
}

.form-surface .toggle-row .field-hint {
  margin-top: 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  align-self: center;
}

.switch input {
  position: absolute;
  inset: 0;
  z-index: 2;
  margin: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 999px;
  pointer-events: none;
  transition: background 0.15s, border-color 0.15s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 50%;
  left: 2px;
  transform: translateY(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.switch input:checked + .slider {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translate(20px, -50%);
  border-color: transparent;
  background: #fff;
}

.toolbar { display: flex; gap: 0.65rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.table-wrap { overflow: auto; }
.status-cell { min-width: 7rem; }
.cell-sub { font-size: 11px; color: var(--muted); }
.actions-cell { white-space: nowrap; }

@media (max-width: 900px) {
  body:not(.login-page) { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; overflow: visible; }
  .shell-body { flex-direction: column; }
  .side-nav {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 0.5rem;
    gap: 0.25rem;
  }
  .side-nav-sep { display: none; }
  .tab {
    width: auto;
    border-left: 0;
    border-bottom: 2px solid transparent;
    padding: 0.4rem 0.7rem;
  }
  .tab.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }
  main, .panel.active { overflow: visible; }
  .apps-layout { flex-direction: column; }
  .apps-list-pane { width: 100%; max-height: 280px; border-right: 0; border-bottom: 1px solid var(--border); }
  .deploy-log-pane { max-height: 180px; }
  .deploy-log-pane .log { height: 120px; max-height: 120px; }
  .obf-grid,
  .detail-grid,
  .form-grid,
  .form-grid .inner { grid-template-columns: 1fr; }
  #tab-obfuscator .obf-grid > .stack {
    max-height: none;
    overflow: visible;
  }
  .jobs-list {
    max-height: min(420px, 55vh);
  }
  .form-grid .span2,
  .checks.span2,
  .detail-grid .span2 { grid-column: span 1; }
}

/* Obfuscator jobs + detail modal */
.signing-banner {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.4;
}
.signing-banner.ok {
  border-color: color-mix(in srgb, #059669 35%, var(--border));
  background: color-mix(in srgb, #059669 10%, var(--surface));
  color: var(--text);
}
.signing-banner.muted {
  color: var(--muted);
  background: var(--hover);
}

.job-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.job-card-main {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.job-card-main strong {
  font-size: 14px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-card-meta {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-card-side {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.jobs-surface {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 0;
}
.jobs-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.jobs-head .section-title {
  margin: 0 0 0.2rem;
}
.jobs-summary {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.jobs-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.jobs-filter {
  height: 36px;
  width: auto !important;
  min-width: 8.5rem;
  max-width: 12rem;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  padding: 0 0.75rem;
  font: inherit;
  font-size: 13px;
}
.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
  min-height: 120px;
  max-height: min(520px, calc(100vh - 280px));
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.15rem;
  scrollbar-gutter: stable;
}
.jobs-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.15rem;
  border-top: 1px solid var(--border);
}
.jobs-pager.hidden {
  display: none;
}
.jobs-pager-meta {
  font-size: 12px;
  color: var(--muted);
}
.jobs-pager-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}
.jobs-pager-page {
  font-size: 12px;
  color: var(--muted);
  min-width: 5.5rem;
  text-align: center;
}
.jobs-page-size select {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  padding: 0 0.55rem;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.jobs-empty {
  padding: 1.25rem 0.25rem;
  color: var(--muted);
  font-size: 13px;
}
.job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
  min-width: 0;
}
.job-row:hover,
.job-row:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--hover);
  outline: none;
}
.job-row.tone-bad {
  border-left: 3px solid var(--warn);
}
.job-row.tone-ok {
  border-left: 3px solid #059669;
}
.job-row.tone-active {
  border-left: 3px solid var(--accent);
}
.job-row-main {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}
.job-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
}
.job-row-top strong {
  font-size: 14px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.job-row-meta {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}
.job-row-preview {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.job-row-preview.ok {
  color: #059669;
}
.job-row-bar {
  margin-top: 0.25rem;
  height: 4px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--border) 80%, transparent);
  overflow: hidden;
}
.job-row-bar > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}
.job-row .icon-btn {
  align-self: center;
}

.job-detail-status {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.job-detail-progress,
.job-detail-when {
  font-size: 12px;
  color: var(--muted);
}
.job-detail-grid .span2 {
  grid-column: span 2;
}
.job-detail-grid .mono {
  font-family: var(--mono);
  font-size: 12px;
}
.job-error-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.job-error-panel-head .section-title {
  margin: 0;
}
body.crm-modal-open {
  overflow: hidden;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.icon-btn:hover {
  background: var(--hover);
}
.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.crm-modal.hidden { display: none !important; }
.crm-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
}
.crm-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}
.crm-modal-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  height: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  animation: crm-drawer-in 180ms ease-out;
}
@keyframes crm-drawer-in {
  from { transform: translateX(12px); opacity: 0.6; }
  to { transform: translateX(0); opacity: 1; }
}
.crm-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--border);
}
.crm-modal-head h3 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}
.crm-modal-body {
  padding: 1.1rem 1.2rem 1.5rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.job-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 1rem;
  font-size: 13px;
}
.job-detail-grid dt {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.job-detail-grid dd {
  margin: 0.15rem 0 0;
  font-family: var(--mono);
  word-break: break-word;
}
.job-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.job-steps li {
  position: relative;
  padding: 0.45rem 0.65rem 0.45rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  background: var(--hover);
}
.job-steps li::before {
  content: "";
  position: absolute;
  left: 0.5rem;
  top: 0.75rem;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.job-log {
  margin: 0;
  max-height: 40vh;
  overflow: auto;
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
[data-theme="dark"] .job-log {
  background: #0b0f14;
}
.job-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
@media (max-width: 640px) {
  .crm-modal { justify-content: stretch; }
  .crm-modal-panel { width: 100%; }
  .job-detail-grid { grid-template-columns: 1fr; }
}
