:root {
  --bg: #eef6fb;
  --surface: #ffffff;
  --surface-soft: #f6fbff;
  --line: #d7e8f5;
  --text: #133c57;
  --muted: #4f7188;
  --primary: #0f7ea5;
  --primary-hover: #0b6887;
  --accent: #ff9b2f;
  --accent-hover: #ec8719;
  --danger: #d64d4d;
  --ok: #1ea769;
}

[data-theme="dark"] {
  --bg: #081521;
  --surface: #102236;
  --surface-soft: #132b42;
  --line: #274764;
  --text: #e3f3ff;
  --muted: #92b7d1;
  --primary: #3eb3d9;
  --primary-hover: #2f97b8;
  --accent: #ffb257;
  --accent-hover: #f39b33;
  --danger: #ff7e7e;
  --ok: #54d89a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(1400px 700px at -10% -20%, rgba(15, 126, 165, 0.2), transparent),
    radial-gradient(1000px 700px at 120% -30%, rgba(255, 155, 47, 0.16), transparent),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

/* ── App shell (sidebar + content) ── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.sidebar-brand-icon {
  width: 32px; height: 32px;
  color: var(--primary);
  flex-shrink: 0;
}

.sidebar-logo-img {
  width: 100%;
  max-width: 160px;
  border-radius: 8px;
}

.sidebar-brand-name {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--primary);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-separator {
  height: 1px;
  background: var(--line);
  margin: 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
}

.nav-item svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.nav-item.active {
  background: rgba(15, 126, 165, 0.12);
  color: var(--primary);
}

[data-theme="dark"] .nav-item.active {
  background: rgba(62, 179, 217, 0.14);
  color: var(--primary);
}

.sidebar-footer {
  padding: 10px 10px 16px;
  border-top: 1px solid var(--line);
}

.theme-btn { font-size: 0.82rem; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 199;
}

.sidebar-overlay.visible { display: block; }

.main-content {
  margin-left: 220px;
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 100;
}

.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
}

.hamburger:hover { background: var(--surface-soft); }

.mobile-title {
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
}

.page-container {
  width: min(1080px, 92%);
  margin: 32px auto 64px;
  flex: 1;
}

.page-container.deploy-page {
  margin-top: 20px;
  margin-bottom: 16px;
}

/* ── Page header (substitui .hero-main) ── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header-text h1 {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 1.7rem;
}

.page-header-text p {
  margin: 0;
  color: var(--muted);
}

.page-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 10px 28px rgba(12, 79, 109, 0.1);
}

.label {
  display: block;
  margin-bottom: 10px;
  font-weight: 600;
}

.input {
  width: 100%;
  margin-bottom: 20px;
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid #bfdced;
  border-radius: 10px;
  padding: 12px;
}

.targets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.targets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.target-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: linear-gradient(180deg, #f8fcff 0%, #f1f9ff 100%);
  border: 1px solid #cde3f3;
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: 150ms ease;
}

.target-card:hover {
  transform: translateY(-1px);
  border-color: #abd0e8;
  box-shadow: 0 8px 16px rgba(15, 126, 165, 0.08);
}

.target-card small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  text-decoration: none;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
}

.button-primary {
  background: var(--primary);
  color: white;
}

.button-primary:hover {
  background: var(--primary-hover);
}

.button-light {
  background: #edf6fc;
  color: var(--primary);
  border: 1px solid #bedcee;
}

.button-light:hover {
  background: #e2f1fa;
}

[data-theme="dark"] .button-light {
  background: #14314a;
  color: #bce8ff;
  border-color: #2f617f;
}

[data-theme="dark"] .button-light:hover {
  background: #1a3f5d;
}

.button-danger {
  background: var(--danger);
  color: white;
}

.alert {
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 18px;
}

.alert.error {
  background: rgba(214, 77, 77, 0.12);
  border: 1px solid #e9b0b0;
}

.alert.success {
  background: rgba(30, 167, 105, 0.14);
  border: 1px solid #9ddfc2;
}

.result-list {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

.success-hero {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #bfe5cb;
  background: linear-gradient(145deg, rgba(33, 181, 114, 0.11), rgba(15, 126, 165, 0.08));
}

.mascot {
  width: 110px;
  height: 110px;
  flex-shrink: 0;
}

.speech-bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  position: relative;
}

.speech-bubble p {
  margin: 4px 0 0;
  color: var(--text);
}

.speech-bubble::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 22px;
  width: 16px;
  height: 16px;
  background: var(--surface);
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}

.mascot-bounce {
  animation: mascot-pop 650ms ease-out, mascot-float 2.2s ease-in-out 650ms infinite;
}

@keyframes mascot-pop {
  0% {
    transform: scale(0.7) translateY(8px);
    opacity: 0;
  }
  70% {
    transform: scale(1.06) translateY(-4px);
    opacity: 1;
  }
  100% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes mascot-float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-6px);
  }
}

.result-item {
  border-radius: 10px;
  padding: 12px;
}

.result-item.ok {
  background: rgba(30, 167, 105, 0.1);
  border: 1px solid #9ddfc2;
}

.result-item.fail {
  background: rgba(214, 77, 77, 0.1);
  border: 1px solid #e9b0b0;
}

.history-table {
  display: grid;
  gap: 8px;
}

.history-table .row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 1fr 0.6fr 1.4fr 1.2fr 0.7fr;
  gap: 8px;
  align-items: center;
  background: #f8fcff;
  border: 1px solid #cde3f3;
  border-radius: 10px;
  padding: 10px;
}

.history-table .head {
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 700;
}

.status-ok {
  color: var(--ok);
  font-weight: 700;
}

.status-fail {
  color: var(--danger);
  font-weight: 700;
}

.log-block {
  background: #0f2533;
  color: #dcefff;
  border: 1px solid #25516c;
  border-radius: 10px;
  padding: 12px;
  max-height: 65vh;
  overflow: auto;
}

h2 {
  color: var(--primary);
  margin-top: 0;
}

a {
  color: var(--primary);
}

[data-theme="dark"] .target-card,
[data-theme="dark"] .history-table .row {
  background: linear-gradient(180deg, #132a40 0%, #11253a 100%);
  border-color: #2c516e;
}

[data-theme="dark"] .success-hero {
  border-color: #2d6a4e;
  background: linear-gradient(145deg, rgba(33, 181, 114, 0.14), rgba(62, 179, 217, 0.1));
}

[data-theme="dark"] .input {
  border-color: #2e5372;
}

[data-theme="dark"] .log-block {
  background: #08111a;
  border-color: #1f4158;
}

.log-details {
  margin-top: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 1rem;
}

.log-details summary {
  cursor: pointer;
  padding: 0.75rem 0;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.log-details summary::before {
  content: "▶";
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.log-details[open] summary::before {
  transform: rotate(90deg);
}

.log-details[open] {
  padding-bottom: 1rem;
}

[data-theme="dark"] .log-details {
  border-color: #2c516e;
}

.log-block-inline {
  margin-top: .75rem;
  max-height: 260px;
  overflow-y: auto;
  font-size: 0.78rem;
}

.deploy-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: .03em;
}

.badge-ok  { background: rgba(30,167,105,.18); color: #1ea769; border: 1px solid #9ddfc2; }
.badge-fail { background: rgba(214,77,77,.18); color: #c94444; border: 1px solid #e9b0b0; }

.required { color: #e53e3e; }

/* ── Drop zone ── */
.drop-zone {
  position: relative;
  border: 2px dashed var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
  margin-bottom: 20px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-zone-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(15, 126, 165, 0.06);
  box-shadow: 0 0 0 4px rgba(15, 126, 165, 0.1);
}

.drop-zone.drag-over {
  box-shadow: 0 0 0 4px rgba(15, 126, 165, 0.2);
}

.drop-zone.has-file {
  border-style: solid;
  border-color: var(--ok);
  background: rgba(30, 167, 105, 0.06);
  cursor: default;
}

.drop-zone-idle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 20px;
  color: var(--muted);
  pointer-events: none;
}

.drop-zone-idle svg { color: var(--primary); opacity: 0.7; }

.drop-zone-text { font-size: 0.9rem; font-weight: 600; color: var(--text); }

.drop-zone-sub { font-size: 0.78rem; }

.drop-zone-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  width: 100%;
  pointer-events: none;
}

.drop-zone-file svg { color: var(--ok); flex-shrink: 0; }

.drop-zone-filename {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text);
  word-break: break-all;
}

.drop-zone-filesize {
  font-size: 0.76rem;
  color: var(--ok);
  font-weight: 600;
  margin-top: 2px;
}

.drop-zone-clear {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px 8px;
  pointer-events: all;
  z-index: 3;
  position: relative;
  transition: background 0.15s, color 0.15s;
}

.drop-zone-clear:hover {
  background: rgba(214, 77, 77, 0.1);
  color: var(--danger);
  border-color: var(--danger);
}

.drop-zone.has-file .drop-zone-input { pointer-events: none; }

[data-theme="dark"] .drop-zone { background: var(--surface); }
[data-theme="dark"] .drop-zone.has-file { background: rgba(30, 167, 105, 0.08); }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

/* ── App cards ── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.app-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 12px 8px 10px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s, background 0.18s;
  text-align: center;
  user-select: none;
}

.app-card input { display: none; }

.app-card:hover:not(.app-card-disabled) {
  border-color: var(--primary);
  box-shadow: 0 6px 20px rgba(15, 126, 165, 0.18);
  transform: translateY(-3px);
}

.app-card:has(input:checked) {
  border-color: var(--primary);
  background: linear-gradient(145deg, var(--primary), var(--primary-hover));
  box-shadow: 0 8px 24px rgba(15, 126, 165, 0.38);
  transform: translateY(-3px);
  color: white;
}

.app-card-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(15, 126, 165, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
}

.app-card-icon svg { width: 20px; height: 20px; color: var(--primary); transition: color 0.18s; }

.app-card:has(input:checked) .app-card-icon {
  background: rgba(255, 255, 255, 0.2);
}

.app-card:has(input:checked) .app-card-icon svg { color: white; }

.app-card-label {
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.2;
}

.app-card-sub {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.app-card:has(input:checked) .app-card-sub { color: rgba(255,255,255,0.7); }

.app-card-rocket {
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s, transform 0.2s;
}

.app-card-rocket svg { width: 16px; height: 16px; color: rgba(255,255,255,0.85); }

.app-card:has(input:checked) .app-card-rocket {
  opacity: 1;
  transform: translateY(0);
}

.app-card-check {
  position: absolute;
  top: 8px; right: 10px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: white;
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s, transform 0.2s;
}

.app-card:has(input:checked) .app-card-check {
  opacity: 1;
  transform: scale(1);
}

.app-card-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Client cards ── */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.client-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px 8px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.18s, background 0.18s;
  text-align: center;
  user-select: none;
}

.client-card input { display: none; }

.client-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(255, 155, 47, 0.18);
  transform: translateY(-2px);
}

.client-card:has(input:checked) {
  border-color: var(--accent);
  background: linear-gradient(145deg, rgba(255,155,47,0.16), rgba(255,155,47,0.07));
  box-shadow: 0 4px 14px rgba(255, 155, 47, 0.24);
  transform: translateY(-2px);
}

.client-card-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(255,155,47,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.client-card-icon svg { width: 20px; height: 20px; color: var(--accent); }

.client-card:has(input:checked) .client-card-icon { background: rgba(255,155,47,0.22); }

.client-card-label {
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.2;
  color: var(--text);
}

.client-card-check {
  position: absolute;
  top: 6px; right: 8px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s, transform 0.2s;
}

.client-card:has(input:checked) .client-card-check {
  opacity: 1;
  transform: scale(1);
}

[data-theme="dark"] .app-card,
[data-theme="dark"] .client-card {
  background: var(--surface);
  border-color: var(--line);
}

[data-theme="dark"] .app-card-icon { background: rgba(62,179,217,0.12); }
[data-theme="dark"] .app-card-icon svg { color: var(--primary); }
[data-theme="dark"] .client-card-icon { background: rgba(255,178,87,0.12); }
[data-theme="dark"] .client-card-icon svg { color: var(--accent); }

/* ── Two-column deploy layout ── */
.deploy-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 28px;
  align-items: start;
}

.deploy-col-left {
  position: sticky;
  top: 24px;
}

.deploy-col-left .label {
  margin-bottom: 7px;
}

.deploy-col-left .input {
  margin-bottom: 12px;
}

.deploy-col-left .toggle-row {
  margin-bottom: 12px;
}

.deploy-col-right {
  border-left: 1px solid var(--line);
  padding-left: 28px;
}

.client-grid-right {
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  padding: 4px 2px 2px;
}

.client-count-badge {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 20px;
  background: rgba(255,155,47,0.18);
  color: var(--accent);
  border: 1px solid rgba(255,155,47,0.35);
  vertical-align: middle;
}

/* ── Admin tables (clients, apps) ── */
.admin-table {
  display: grid;
  gap: 8px;
}

.admin-table .row {
  display: grid;
  gap: 8px;
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}

.admin-table .head {
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding-bottom: 4px;
}

.admin-table .row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

[data-theme="dark"] .admin-table .row {
  background: var(--surface);
  border-color: var(--line);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.steps-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.step-row {
  display: flex;
  gap: 6px;
  align-items: center;
  border-radius: 8px;
  transition: opacity 0.15s;
}

.step-row.dragging {
  opacity: 0.35;
}

.step-row.drag-over {
  outline: 2px dashed var(--primary);
  outline-offset: 2px;
}

.step-drag-handle {
  flex-shrink: 0;
  cursor: grab;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
  user-select: none;
  opacity: 0.6;
  transition: opacity 0.15s;
}

.step-drag-handle:active {
  cursor: grabbing;
}

.step-row:hover .step-drag-handle {
  opacity: 1;
}

.step-row .input {
  margin: 0;
  flex: 1;
  font-family: "Consolas", "Courier New", monospace;
  font-size: 0.85rem;
  transition: background 0.15s;
}

.step-row .input[readonly] {
  background: var(--surface-soft);
  cursor: default;
  color: var(--text);
}

.step-actions {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.step-btn {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: none;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.step-btn:hover {
  background: var(--surface-soft);
  color: var(--text);
}

.step-btn-remove:hover {
  background: rgba(214, 77, 77, 0.1);
  color: var(--danger);
  border-color: var(--danger);
}

.step-btn-edit:hover,
.step-btn-edit.active {
  background: rgba(15, 126, 165, 0.12);
  color: var(--primary);
  border-color: var(--primary);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state svg {
  width: 48px; height: 48px;
  opacity: 0.3;
  margin-bottom: 12px;
}

.empty-state p { margin: 4px 0 0; font-size: 0.9rem; }

.icon-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.icon-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  border: 2px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.icon-option input { display: none; }
.icon-option svg { width: 22px; height: 22px; color: var(--primary); }
.icon-option:has(input:checked) {
  border-color: var(--primary);
  background: rgba(15,126,165,0.08);
  color: var(--text);
  font-weight: 700;
}

/* ── Permission checkboxes (groups page) ── */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-bottom: 4px;
}

.perm-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--muted);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  user-select: none;
}

.perm-option input { display: none; }

.perm-check {
  width: 16px; height: 16px;
  border-radius: 4px;
  border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem;
  font-weight: 800;
  color: transparent;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.perm-option:has(input:checked) {
  border-color: var(--primary);
  background: rgba(15, 126, 165, 0.07);
  color: var(--text);
}

.perm-option:has(input:checked) .perm-check {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.perm-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.perm-badge-on {
  background: rgba(15, 126, 165, 0.12);
  color: var(--primary);
  border: 1px solid rgba(15, 126, 165, 0.3);
}

[data-theme="dark"] .perm-option:has(input:checked) {
  background: rgba(62, 179, 217, 0.1);
}

[data-theme="dark"] .perm-badge-on {
  background: rgba(62, 179, 217, 0.14);
  border-color: rgba(62, 179, 217, 0.3);
}

/* ── Login page ── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrap {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  padding: 36px 32px 28px;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.login-icon {
  width: 52px;
  height: 52px;
  color: var(--primary);
}

.login-logo {
  max-width: 160px;
  border-radius: 8px;
}

.login-brand-name {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0;
}

.login-subtitle {
  text-align: center;
  color: var(--muted);
  margin: 0 0 22px;
  font-size: 0.88rem;
}

.login-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -12px 0 16px;
}

.login-submit {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
}

.login-theme {
  margin-top: 18px;
  display: flex;
  justify-content: center;
}

/* ── Sidebar logged-in user ── */
.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  margin-bottom: 6px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.sidebar-username {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-logout {
  font-size: 0.73rem;
  color: var(--muted);
  text-decoration: none;
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.sidebar-logout:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(214, 77, 77, 0.08);
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .mobile-header {
    display: flex;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .deploy-layout {
    grid-template-columns: 1fr;
  }

  .deploy-col-left { position: static; }

  .deploy-col-right {
    border-left: none;
    border-top: 1px solid var(--line);
    padding-left: 0;
    padding-top: 20px;
  }

  .client-grid-right { max-height: none; }

  .app-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .client-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }

  .history-table .row {
    grid-template-columns: 1fr;
  }

  .admin-table .row {
    grid-template-columns: 1fr;
  }
}

/* Toggle switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 16px;
  cursor: pointer;
  user-select: none;
  transition: border-color 150ms;
}

.toggle-row:hover {
  border-color: var(--primary);
}

.toggle-row > span {
  font-size: .9rem;
  font-weight: 500;
  color: var(--text);
}

.toggle-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  display: inline-block;
  width: 42px;
  height: 24px;
  background: var(--line);
  border-radius: 12px;
  position: relative;
  transition: background 200ms;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 200ms;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle-input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle-input:checked + .toggle-slider::after {
  transform: translateX(18px);
}

/* ── Deploy page full-height layout ─────────────────── */
.deploy-card {
  height: calc(100vh - 200px);
  min-height: 420px;
  display: flex;
  flex-direction: column;
  padding: 18px 24px 16px;
  overflow: hidden;
}

.deploy-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 0;
}

.deploy-topbar {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.deploy-topbar .label {
  font-size: .83rem;
  margin-bottom: 7px;
}

.deploy-topbar .input {
  margin-bottom: 0;
}

.deploy-topbar-field {
  flex: 1;
  min-width: 120px;
}

.deploy-topbar-upload {
  flex: 2;
  min-width: 0;
}

.deploy-topbar-action {
  flex-shrink: 0;
  width: 180px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deploy-grids {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  flex: 1;
  min-height: 0;
  padding-top: 14px;
  overflow: hidden;
}

.deploy-apps-col,
.deploy-clients-col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.deploy-apps-col .label {
  flex-shrink: 0;
}

.deploy-apps-col .app-grid {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  margin-bottom: 0;
  padding: 2px 2px 4px;
}

.deploy-clients-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.deploy-clients-col .client-grid {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  margin-bottom: 0;
  padding: 2px 2px 4px;
}

/* Compact drop zone */
.drop-zone-sm {
  min-height: 44px;
  flex-direction: row;
  gap: 10px;
  padding: 10px 14px;
}

.drop-zone-sm .drop-zone-idle {
  flex-direction: row;
  gap: 8px;
  align-items: center;
  justify-content: flex-start;
}

.drop-zone-sm .drop-zone-text {
  font-size: .82rem;
}

/* Compact toggle for topbar */
.toggle-row-sm {
  padding: 8px 12px;
  margin-bottom: 0;
}

.toggle-row-sm > span {
  font-size: .82rem;
}

/* History table scroll */
.history-table-wrap {
  max-height: calc(100vh - 280px);
  overflow-y: auto;
}

@media (max-width: 700px) {
  .deploy-card {
    height: auto;
    min-height: unset;
  }
  .deploy-topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .deploy-topbar-action {
    width: 100%;
  }
  .deploy-grids {
    grid-template-columns: 1fr;
    overflow: visible;
  }
  .deploy-apps-col .app-grid,
  .deploy-clients-col .client-grid {
    overflow-y: visible;
    max-height: none;
  }
}
