@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans+Thai:wght@400;500;600;700&display=swap');

:root {
  --primary: #6366F1;
  --teal: #14B8A6;
  --rose: #F43F5E;
  --panel: #FFFFFF;
  --bg: #F3F4F6;
  --line: #E5E7EB;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 6px 20px rgba(16,24,40,.08);
  --ink: #111827;
  --ink-2: #6B7280;
  --ink-3: #9CA3AF;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); }
body {
  font-family: "Inter", "IBM Plex Sans Thai", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select { font-family: inherit; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── Site Header ──────────────────────────────────────────── */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-logo {
  width: 44px; height: 44px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, #8B7DF7 0%, #6366F1 100%);
  display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(99,102,241,.30);
}
.header-title { font-size: 19px; font-weight: 700; letter-spacing: -0.2px; color: var(--ink); }
.header-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-3); margin-top: 2px;
}
.meta-sep { color: var(--line); }
.header-idle-status { display: inline-flex; align-items: center; gap: 5px; }
.idle-dot { width: 6px; height: 6px; border-radius: 50%; background: #10B981; flex-shrink: 0; }
.user-pill {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 6px 5px 5px;
  background: #F9FAFB; border: 1px solid var(--line); border-radius: 999px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, #34D399, #10B981);
  display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700;
  overflow: hidden;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { font-size: 12.5px; color: var(--ink); padding-left: 2px; }
.pill-sep { width: 1px; height: 18px; background: var(--line); margin-left: 2px; }
.logout-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 999px; border: none;
  background: transparent; color: #DC2626;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background .12s;
}
.logout-btn:hover { background: #FEE2E2; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content { max-width: 1920px; margin: 0 auto; padding: 20px 28px 32px; }

/* ── Grid Layout ──────────────────────────────────────────── */
.grid-layout {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
  align-items: stretch;
  margin-bottom: 18px;
}
.grid-layout > div {
  display: flex; flex-direction: column;
  max-height: calc(100vh - 130px);
  overflow: hidden;
}

/* ── Column Header ────────────────────────────────────────── */
.col-header {
  display: flex; align-items: center; gap: 7px;
  padding: 0 4px 10px 4px;
}
.col-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.col-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.8px;
  color: var(--ink); text-transform: uppercase;
}
.col-count {
  padding: 1px 7px; border-radius: 999px;
  background: #F3F4F6; color: var(--ink-2);
  font-size: 10.5px; font-weight: 700;
}
.col-run-all {
  margin-left: auto; width: 22px; height: 22px;
  border-radius: 6px; border: 1px solid var(--line); background: #fff;
  cursor: pointer; display: grid; place-items: center; padding: 0;
  color: var(--ink-2); font-size: 10px;
  transition: background .12s, border-color .12s;
}
.col-run-all:hover { background: #F3F4F6; border-color: #D1D5DB; }

/* ── Cards Column ─────────────────────────────────────────── */
.cards-col { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; overflow-y: auto; padding-right: 2px; }

/* ── Scenario Card ────────────────────────────────────────── */
.scenario-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 12px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.scenario-card:hover { box-shadow: 0 6px 20px rgba(16,24,40,.06); }

.scenario-top { display: flex; gap: 11px; align-items: flex-start; }
.scenario-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(99,102,241,.18);
}
.tone-indigo { background: linear-gradient(135deg, #8B7DF7, #6366F1); }
.tone-teal   { background: linear-gradient(135deg, #2DD4BF, #14B8A6); box-shadow: 0 4px 10px rgba(20,184,166,.18); }
.tone-rose   { background: linear-gradient(135deg, #FB7185, #F43F5E); box-shadow: 0 4px 10px rgba(244,63,94,.18); }

.scenario-info { flex: 1; min-width: 0; }
.scenario-project {
  font-size: 10px; font-weight: 700; letter-spacing: 0.6px;
  text-transform: uppercase;
  font-family: 'IBM Plex Mono', monospace;
  margin-bottom: 2px;
  background: none; /* override .tone-* gradient */
  box-shadow: none;
}
.scenario-project.tone-indigo { color: #6366F1; }
.scenario-project.tone-teal   { color: #14B8A6; }
.scenario-project.tone-rose   { color: #F43F5E; }
.scenario-title {
  font-size: 14px; font-weight: 700; color: var(--ink); letter-spacing: -0.1px;
  font-family: 'IBM Plex Mono', monospace;
}
.scenario-desc { font-size: 11.5px; color: var(--ink-2); margin-top: 3px; line-height: 1.4; }

/* ── Fields ───────────────────────────────────────────────── */
.scenario-fields { display: flex; flex-direction: column; gap: 8px; }
.field-label {
  font-size: 10.5px; font-weight: 600; color: var(--ink-2);
  text-transform: uppercase; letter-spacing: 0.4px;
  margin-bottom: 4px; display: flex; gap: 6px; align-items: baseline;
}
.field-hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink-3); font-size: 10.5px; }
.field-input, .field-select {
  width: 100%; padding: 7px 10px;
  border-radius: 7px; border: 1px solid var(--line);
  background: #fff; font-size: 12.5px; color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field-input:focus, .field-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}
.field-select-wrap { position: relative; }
.field-select { padding-right: 28px; appearance: none; }
.field-select-arrow {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--ink-3);
}

/* ── Status Row ───────────────────────────────────────────── */
.status-row {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 2px;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 6px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
}
.status-pill-icon {
  width: 14px; height: 14px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 9px; font-weight: 800; color: #fff; line-height: 1;
}
.status-pass   { background: #D1FAE5; color: #065F46; }
.status-pass   .status-pill-icon { background: #10B981; }
.status-fail   { background: #FEE2E2; color: #991B1B; }
.status-fail   .status-pill-icon { background: #DC2626; }
.status-warn   { background: #FEF3C7; color: #92400E; }
.status-warn   .status-pill-icon { background: #F59E0B; }
.status-idle   { background: #F3F4F6; color: #4B5563; }
.status-idle   .status-pill-icon { background: #9CA3AF; }
.status-running { background: #EEF0FF; color: #3730A3; }
.status-running .status-pill-icon { background: #6366F1; }

.runs-wrap { display: flex; align-items: center; gap: 7px; }
.runs-label { font-size: 10.5px; color: var(--ink-3); }
.runs-strip { display: flex; gap: 3px; align-items: center; }
.run-dot { width: 12px; height: 12px; border-radius: 3px; }

/* ── Run Button ───────────────────────────────────────────── */
.run-btn {
  width: 100%; padding: 9px 12px; border-radius: 8px; border: none;
  background: linear-gradient(180deg, #7C70F2 0%, #6457E6 100%);
  color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  box-shadow: 0 1px 0 rgba(255,255,255,.4) inset, 0 1px 2px rgba(99,102,241,.4);
  cursor: pointer; transition: filter .15s, transform .05s;
}
.run-btn:hover:not(:disabled) { filter: brightness(1.06); }
.run-btn:active:not(:disabled) { transform: translateY(1px); }
.run-btn:disabled { background: linear-gradient(180deg, #9CA3AF, #6B7280); cursor: wait; }
.run-btn .btn-spinner {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.duration-footer {
  font-size: 10.5px; color: var(--ink-3);
  font-family: 'IBM Plex Mono', monospace;
  text-align: center; margin-top: -4px;
}

/* ── Header right (bell + profile) ───────────────────────── */
.v3-header-right {
  /* top/bottom + flex centers vertically without `transform` — a transformed
     ancestor would become the containing block for the popover's
     `position:fixed` below, breaking its viewport-relative positioning and
     re-exposing it to .v3-header's `overflow:hidden` clip. */
  position: absolute !important; right: 28px; top: 0; bottom: 0;
  display: flex; align-items: center; gap: 10px;
}
.v3-header-right .v3-profile { position: static !important; transform: none !important; }

/* ── Sentry notification bell ────────────────────────────── */
.v3-bell-wrap { position: relative; }
.v3-bell-btn {
  position: relative; width: 38px; height: 38px; border-radius: 50%;
  background: #fff; border: 1px solid #E5E7EB; box-shadow: 0 1px 2px rgba(16,24,40,.04);
  display: flex; align-items: center; justify-content: center;
  color: #4B5563; cursor: pointer; padding: 0; transition: box-shadow .25s;
}
.v3-bell-btn:hover { box-shadow: 0 4px 14px rgba(16,24,40,.08); }
.v3-bell-badge {
  position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 999px; background: #DC2626; color: #fff; font-size: 10px; font-weight: 700;
  align-items: center; justify-content: center; line-height: 1;
  box-shadow: 0 0 0 2px #fff;
}
.v3-bell-popover {
  display: none; position: fixed; top: 0; left: 0; z-index: 999;
  width: 320px; max-width: calc(100vw - 40px);
  background: #fff; border: 1px solid #E5E7EB; border-radius: 14px;
  box-shadow: 0 16px 40px rgba(16,24,40,.16);
  overflow: hidden;
}
.v3-bell-popover.open { display: block; }
.v3-bell-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 12px; border-bottom: 1px solid #F1F2F4;
}
.v3-bell-title { font-size: 13.5px; font-weight: 700; color: #111827; }
.v3-bell-active-count {
  font-size: 11px; font-weight: 600; color: #6B7280; background: #F3F4F6;
  padding: 3px 9px; border-radius: 999px;
}
.v3-bell-list { max-height: 340px; overflow-y: auto; }
.v3-bell-item {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 11px 16px; border-bottom: 1px solid #F6F7F8; cursor: pointer;
  transition: background .12s;
}
.v3-bell-item:last-child { border-bottom: none; }
.v3-bell-item:hover { background: #FAFAFB; }
.v3-bell-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.v3-bell-item .body { flex: 1; min-width: 0; }
.v3-bell-item .key { font-size: 11px; font-weight: 700; font-family: 'IBM Plex Mono', monospace; }
.v3-bell-item .msg {
  font-size: 12.5px; color: #374151; margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.v3-bell-item .time { font-size: 10.5px; color: #9CA3AF; flex-shrink: 0; margin-top: 1px; }
.v3-bell-open-btn {
  display: block; text-align: center; padding: 11px; font-size: 12.5px; font-weight: 600;
  color: var(--primary); text-decoration: none; border-top: 1px solid #F1F2F4;
}
.v3-bell-open-btn:hover { background: #F9FAFB; }
.v3-bell-empty { text-align: center; padding: 28px 16px; font-size: 12.5px; color: #9CA3AF; }

/* ── Menu Link Settings (Google Sheets & Notion management) ─── */
.mls-menu { width: 240px; }
.mls-link-row { display: flex; align-items: center; gap: 9px; }
.mls-link-icon {
  width: 20px; height: 20px; border-radius: 5px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.mls-divider { height: 1px; background: #F0F1F3; margin: 6px 4px; }
.mls-manage-btn {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 10px; border-radius: 8px; border: none; background: transparent;
  color: var(--primary); font-size: 12.5px; font-weight: 600; cursor: pointer;
  text-align: left; font-family: inherit;
}
.mls-manage-btn:hover { background: #EEF0FF; }
.mls-manage-icon {
  width: 20px; height: 20px; border-radius: 5px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}

.refresh-chip:hover { background: #F3F4F6; }

/* Sentry issue cards */
.sentry-issues { display: flex; flex-direction: column; gap: 8px; }
.issue-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 12px 13px;
  display: flex; flex-direction: column; gap: 7px;
  cursor: pointer; transition: box-shadow .15s;
  border-left-width: 3px;
}
.issue-card:hover { box-shadow: var(--shadow-md); }
.issue-top { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.issue-short-id { font-size: 10.5px; font-weight: 700; color: var(--ink-2); letter-spacing: 0.4px; text-transform: uppercase; }
.issue-title {
  font-size: 12.5px; font-weight: 600; color: var(--ink); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.issue-badge {
  font-size: 9.5px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  letter-spacing: 0.4px; text-transform: uppercase; white-space: nowrap;
}
.badge-CRITICAL   { color: #B91C1C; background: #FEE2E2; }
.badge-REGRESSION { color: #92400E; background: #FEF3C7; }
.badge-NEW        { color: #5B21B6; background: #EDE9FE; }
.badge-RESOLVED   { color: #065F46; background: #D1FAE5; }
.badge-WARNING    { color: #92400E; background: #FEF3C7; }
.badge-ERROR      { color: #9A3412; background: #FFEDD5; }
.issue-stats { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--ink-2); }
.issue-stats strong { color: var(--ink); }
.mini-bars { display: flex; align-items: flex-end; gap: 1.5px; height: 24px; width: 100%; }
.mini-bar { flex: 1; border-radius: 1.5px; min-height: 2px; opacity: .85; }
.issue-footer { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-3); }
.issue-footer span { color: var(--ink-2); font-weight: 500; }

/* ── AI Explain button ────────────────────────────────────── */
.explain-row { display: flex; flex-direction: column; gap: 6px; margin-top: 1px; }
.explain-btn {
  align-self: flex-start;
  font-size: 10.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 5px;
  border: 1px solid #C7D2FE;
  background: #EEF2FF; color: #4338CA;
  cursor: pointer; transition: background .12s, box-shadow .12s;
  white-space: nowrap;
}
.explain-btn:hover:not(:disabled) { background: #E0E7FF; box-shadow: 0 1px 4px rgba(99,102,241,.18); }
.explain-btn:disabled { opacity: .6; cursor: default; }
.explain-result {
  background: #F8FAFC; border: 1px solid #E2E8F0;
  border-radius: 6px; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 6px;
}
.explain-text {
  font-size: 12px; line-height: 1.55; color: #1E293B;
  font-family: "IBM Plex Sans Thai", "Inter", sans-serif;
  white-space: pre-wrap;
}
.explain-copy-btn {
  align-self: flex-end;
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  border-radius: 4px; border: 1px solid #CBD5E1;
  background: #fff; color: var(--ink-2);
  cursor: pointer; transition: background .1s;
}
.explain-copy-btn:hover { background: #F1F5F9; }
.explain-error { font-size: 11px; color: #B91C1C; }

.sentry-state { text-align: center; font-size: 12px; color: var(--ink-3); padding: 24px; }
.sentry-state.error { color: #EF4444; }

/* ── Skeleton loading ─────────────────────────────────────── */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.issue-skeleton {
  background: #fff; border: 1px solid var(--line); border-left: 3px solid #E5E7EB;
  border-radius: 8px; padding: 12px 13px;
  display: flex; flex-direction: column; gap: 9px;
}
.skel-line {
  border-radius: 4px; height: 10px;
  background: linear-gradient(90deg, #F3F4F6 25%, #E9EAEC 50%, #F3F4F6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.mls-overlay {
  display: none; position: fixed; inset: 0; background: rgba(17,24,39,.35);
  align-items: center; justify-content: center; z-index: 2000; padding: 24px;
}
.mls-overlay.open { display: flex; }
.mls-modal {
  width: 460px; max-width: 92vw; max-height: 84vh; overflow-y: auto;
  background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(16,24,40,.25);
}
.mls-modal-head {
  padding: 16px 18px; border-bottom: 1px solid #F0F1F3;
  display: flex; align-items: center; gap: 10px;
}
.mls-modal-badge {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg,#8B7DF7,#6366F1);
  display: flex; align-items: center; justify-content: center;
}
.mls-modal-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.mls-modal-subtitle { font-size: 11.5px; color: var(--ink-3); margin-top: 1px; }
.mls-modal-close {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-3); cursor: pointer; flex-shrink: 0; font-size: 13px;
}
.mls-modal-close:hover { background: #F9FAFB; }
.mls-modal-body { padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.mls-empty { padding: 30px 0; text-align: center; color: var(--ink-3); font-size: 12.5px; }
.mls-group-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--ink-3); margin: 4px 2px 0;
}
.mls-group-label:first-child { margin-top: 0; }

.mls-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.mls-row-icon {
  width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.mls-row-info { min-width: 0; flex: 1; }
.mls-row-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.mls-row-url {
  font-size: 11px; color: var(--ink-3); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.mls-row-btn {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; text-decoration: none;
}
.mls-row-btn:hover { background: #F9FAFB; }
.mls-row-btn.danger { color: #DC2626; }

.mls-form {
  background: #F9FAFB; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.mls-form-row { display: flex; gap: 8px; }
.mls-form input, .mls-form select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  font-size: 13px; outline: none; font-family: inherit; background: #fff; color: var(--ink);
}
.mls-form-row input { flex: 1; min-width: 0; }
.mls-form-url { font-family: 'IBM Plex Mono', monospace; }
.mls-form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 2px; }
.mls-btn {
  padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.mls-btn:hover { background: #F9FAFB; }
.mls-btn-primary {
  border: none; background: linear-gradient(180deg,#7C70F2,#6457E6); color: #fff;
}
.mls-btn-primary:disabled { background: #D1D5DB; cursor: not-allowed; }
.mls-btn-primary:not(:disabled):hover { filter: brightness(1.05); background: linear-gradient(180deg,#7C70F2,#6457E6); }
.mls-add-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 0; border-radius: 10px; border: 1px dashed #C7D2FE;
  background: #EEF0FF; color: var(--primary); font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.mls-add-btn:hover { background: #E0E4FF; }

/* ── Log Section ──────────────────────────────────────────── */
.log-section {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.log-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid var(--line); background: #FAFAFB;
}
.log-header-left { display: flex; align-items: center; gap: 10px; }
.log-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #10B981; flex-shrink: 0;
}
.log-dot.busy { background: #F59E0B; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.35; } }
.log-label { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--ink); }
.log-badge {
  padding: 2px 8px; border-radius: 6px;
  background: #F3F4F6; color: var(--ink-2); font-size: 11px; font-weight: 600;
}
.log-badge.busy { background: #FEF3C7; color: #92400E; }
.log-lines { font-size: 11.5px; color: var(--ink-3); font-family: 'IBM Plex Mono', monospace; }
.log-action-btn {
  padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: #fff;
  font-size: 11.5px; color: #4B5563; font-weight: 500; cursor: pointer; transition: background .12s;
}
.log-action-btn:hover { background: #F3F4F6; }
.log-terminal {
  height: 280px; overflow-y: auto;
  background: #0F172A; color: #E2E8F0;
  padding: 14px 20px;
  font-family: 'IBM Plex Mono', ui-monospace, monospace;
  font-size: 12.5px; line-height: 1.7;
}
.log-prompt { color: #64748B; }
.log-line { display: block; word-break: break-all; }
.log-ts { color: #475569; }
.log-level { font-weight: 600; display: inline-block; min-width: 60px; }
.log-scope { color: #64748B; margin-right: 8px; }
.log-color-ok   { color: #86EFAC; }
.log-color-error { color: #FCA5A5; }
.log-color-warn  { color: #FCD34D; }
.log-color-info  { color: #CBD5E1; }

/* ── Login Page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh; background: #e8eaf2;
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff; width: 440px; border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 64px rgba(99,102,241,0.18), 0 4px 20px rgba(0,0,0,0.1);
  border: 1px solid rgba(99,102,241,0.2);
}
.login-chrome {
  background: #f5f5f7; border-bottom: 1px solid #e5e7eb;
  padding: 10px 16px; display: flex; align-items: center; gap: 10px;
}
.traffic-lights { display: flex; gap: 6px; }
.tl { width: 12px; height: 12px; border-radius: 50%; }
.tl-red { background: #ff5f57; } .tl-yellow { background: #ffbd2e; } .tl-green { background: #28ca41; }
.chrome-tab {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 3px 12px; font-size: 11px; font-weight: 600; color: #6b7280;
  font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.5px;
}
.login-body { padding: 24px; }
.login-app-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.login-app-icon {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, #7c6cf6, #a78bfa);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.login-app-name { font-size: 18px; font-weight: 700; color: #111827; }
.login-app-cmd { font-size: 12px; color: #9ca3af; font-family: 'IBM Plex Mono', monospace; margin-top: 3px; }
.login-terminal {
  background: #1a1d23; border-radius: 10px; padding: 14px 16px; margin-bottom: 16px;
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; line-height: 2;
}
.t-line { display: flex; gap: 10px; align-items: baseline; }
.t-time { color: #4a5568; flex-shrink: 0; }
.t-tag { font-weight: 700; flex-shrink: 0; min-width: 48px; }
.t-tag.ok { color: #48bb78; } .t-tag.info { color: #63b3ed; } .t-tag.stby { color: #f6e05e; }
.t-text { color: #a0aec0; }
.t-cursor {
  display: inline-block; width: 7px; height: 13px;
  background: #a0aec0; vertical-align: middle; margin-left: 1px;
  animation: blink 1s step-end infinite;
}
@keyframes blink { 0%,100% { opacity:1; } 50% { opacity:0; } }
.login-footer {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: #9ca3af; font-family: 'IBM Plex Mono', monospace;
}
.login-footer-status { display: flex; align-items: center; gap: 5px; }
.login-footer-dot { width: 7px; height: 7px; border-radius: 50%; background: #48bb78; }
.login-error {
  background: #fef2f2; border: 1px solid #fecaca; color: #dc2626;
  border-radius: 8px; padding: 10px 14px; font-size: 12px; margin-bottom: 12px; display: none;
}

/* ════════════════════════════════════════════
   V3 DASHBOARD STYLES
   ════════════════════════════════════════════ */

/* ── Keyframes ─── */
@keyframes v3pulse   { 0%,100%{opacity:1} 50%{opacity:.4} }
@keyframes v3spin    { to{transform:rotate(360deg)} }
@keyframes v3stripe  { from{background-position:0 0} to{background-position:24px 0} }
@keyframes v3blink   { 50%{opacity:0} }
@keyframes v3shine   { 0%{transform:translateX(-120%)} 60%,100%{transform:translateX(120%)} }
@keyframes v3check   { 0%{stroke-dashoffset:22} 25%,65%{stroke-dashoffset:0} 85%,100%{stroke-dashoffset:22} }
@keyframes v3titleShimmer { 0%,100%{background-position:200% 0} 50%{background-position:-50% 0} }
@keyframes v3ping    { 0%{transform:scale(.7);opacity:.7} 80%,100%{transform:scale(2);opacity:0} }
@keyframes v3pingSlow{ 0%{transform:scale(.7);opacity:.55} 80%,100%{transform:scale(2.2);opacity:0} }
@keyframes v3orb     { 0%,100%{transform:translate(0,0)} 50%{transform:translate(-30px,20px)} }
@keyframes v3orb2    { 0%,100%{transform:translate(0,0)} 50%{transform:translate(40px,12px)} }
@keyframes v3sweep   { 0%{background-position:-100% 0} 100%{background-position:100% 0} }
@keyframes v3avatarBreath {
  0%,100%{box-shadow:inset 0 1px 0 rgba(255,255,255,.3),0 0 0 0 rgba(16,185,129,.5)}
  50%    {box-shadow:inset 0 1px 0 rgba(255,255,255,.3),0 0 0 5px rgba(16,185,129,0)}
}
/* Village */
@keyframes vSunShimmer  { 0%,100%{box-shadow:0 0 16px rgba(252,211,77,.7)} 50%{box-shadow:0 0 22px rgba(252,211,77,1)} }
@keyframes vSmokeRise   { 0%{transform:translateY(8px) scale(.6);opacity:0} 30%{opacity:.65} 100%{transform:translateY(-30px) scale(1.6);opacity:0} }
@keyframes vFlame       { 0%{transform:scaleY(.85) scaleX(1.05) rotate(-3deg)} 100%{transform:scaleY(1.2) scaleX(.92) rotate(3deg)} }
@keyframes vBurnFlicker { 0%,100%{opacity:.9} 50%{opacity:.55} }
@keyframes vEmberFly    { 0%{transform:translate(0,0) scale(1);opacity:1} 80%{opacity:1} 100%{transform:translate(28px,-100px) scale(.3);opacity:0} }
@keyframes vHeat        { 0%,100%{transform:translateY(0);opacity:.5} 50%{transform:translateY(-1px);opacity:.8} }
@keyframes vBirdFly     { 0%{transform:translate(-50px,0)} 100%{transform:translate(540px,5px)} }
@keyframes vBatFly      { 0%{transform:translate(540px,0)} 100%{transform:translate(-50px,8px)} }
@keyframes vCharRun     { 0%{transform:translate(-20px,0)} 100%{transform:translate(500px,0)} }
@keyframes vCharBob     { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-1.5px)} }
@keyframes vLegL        { 0%,100%{transform:rotate(-22deg)} 50%{transform:rotate(22deg)} }
@keyframes vLegR        { 0%,100%{transform:rotate(22deg)} 50%{transform:rotate(-22deg)} }
@media (prefers-reduced-motion: reduce) { [class*="v3-"],[style*="animation"]{animation:none!important;transition:none!important} }

/* ── Pattern Background ─── */
.v3-pattern-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(circle, #d1d5db 1px, transparent 1px);
  background-size: 22px 22px; opacity: 0.4;
  mask-image: linear-gradient(180deg, transparent 0%, #000 200px, #000 calc(100% - 200px), transparent 100%);
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 200px, #000 calc(100% - 200px), transparent 100%);
}

/* ── v3 Header ─── */
.v3-header {
  position: sticky; top: 0; z-index: 10;
  background: linear-gradient(180deg, #BAE6FD 0%, #E0F2FE 40%, #FEF9EE 80%, #EEF6E8 100%);
  border-bottom: 1px solid #B9E0F9;
  overflow: hidden;
  height: 110px;
  transition: background .8s, border-color .8s;
}
.v3-header[data-state="cloudy"] {
  background: linear-gradient(180deg, #1F2937 0%, #374151 40%, #4B5563 80%, #6B7280 100%);
  border-bottom-color: #4B5563;
}
.v3-header[data-state="dusk"] {
  background: linear-gradient(180deg, #0F0521 0%, #44174A 35%, #C2410C 75%, #F59E0B 100%);
  border-bottom-color: #C2410C;
}
.v3-header[data-state="apocalypse"] {
  background: linear-gradient(180deg, #0D0005 0%, #4A0808 40%, #7C1D1D 75%, #C2410C 100%);
  border-bottom-color: #7C1D1D;
}
.v3-orb {
  position: absolute; border-radius: 50%; pointer-events: none;
}
.v3-orb-1 {
  width: 280px; height: 280px; top: -140px; right: 200px;
  background: radial-gradient(circle, rgba(99,102,241,.10), transparent 70%);
  animation: v3orb 14s ease-in-out infinite;
}
.v3-header[data-state="dusk"] .v3-orb-1,
.v3-header[data-state="apocalypse"] .v3-orb-1 {
  background: radial-gradient(circle, rgba(249,115,22,.16), transparent 70%);
}
.v3-orb-2 {
  width: 200px; height: 200px; top: -100px; left: 280px;
  background: radial-gradient(circle, rgba(244,63,94,.06), transparent 70%);
  animation: v3orb2 18s ease-in-out infinite;
}
.v3-sweep-line {
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg,transparent 0%,rgba(99,102,241,.5) 40%,rgba(139,125,247,.6) 50%,rgba(99,102,241,.5) 60%,transparent 100%);
  background-size: 200% 100%;
  animation: v3sweep 6s linear infinite;
  pointer-events: none;
  transition: background .8s;
}
.v3-header[data-state="cloudy"] .v3-sweep-line {
  background: linear-gradient(90deg,transparent 0%,rgba(156,163,175,.5) 40%,rgba(107,114,128,.6) 50%,rgba(156,163,175,.5) 60%,transparent 100%);
  background-size: 200% 100%;
}
.v3-header[data-state="dusk"] .v3-sweep-line,
.v3-header[data-state="apocalypse"] .v3-sweep-line {
  background: linear-gradient(90deg,transparent 0%,rgba(249,115,22,.6) 40%,rgba(220,38,38,.7) 50%,rgba(249,115,22,.6) 60%,transparent 100%);
  background-size: 200% 100%;
}
.v3-header-inner {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  padding: 0 28px;
  height: 100%;
}
.v3-logo-area {
  position: absolute; left: 28px; top: 50%; transform: translateY(-50%);
}
.v3-profile {
  position: absolute !important; right: 28px; top: 50%; transform: translateY(-50%);
}
.v3-logo-area { display: flex; align-items: center; gap: 14px; }
.v3-logo {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg,#8B7DF7 0%,#6366F1 100%);
  display: grid; place-items: center;
  box-shadow: 0 10px 24px rgba(99,102,241,.32), inset 0 1px 0 rgba(255,255,255,.25);
  position: relative; overflow: hidden; cursor: pointer;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s;
}
.v3-logo:hover {
  transform: translateY(-1px) rotate(-3deg) scale(1.05);
  box-shadow: 0 14px 32px rgba(99,102,241,.42), inset 0 1px 0 rgba(255,255,255,.3) !important;
}
.v3-shine {
  position: absolute; inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.35) 50%, transparent 70%);
  animation: v3shine 4.5s ease-in-out infinite;
  pointer-events: none;
}
.v3-check-path {
  stroke-dasharray: 22;
  animation: v3check 5s ease-in-out infinite;
}
.v3-title {
  font-size: 19px; font-weight: 700; letter-spacing: -0.2px;
  background-image: linear-gradient(90deg,#111827 0%,#111827 35%,#6366F1 50%,#111827 65%,#111827 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: v3titleShimmer 8s ease-in-out infinite;
  transition: background-image .8s;
}
.v3-header[data-state="cloudy"] .v3-title {
  background-image: linear-gradient(90deg,#E5E7EB 0%,#E5E7EB 35%,#9CA3AF 50%,#E5E7EB 65%,#E5E7EB 100%);
}
.v3-header[data-state="dusk"] .v3-title,
.v3-header[data-state="apocalypse"] .v3-title {
  background-image: linear-gradient(90deg,#FEF3C7 0%,#FEF3C7 35%,#F97316 50%,#FEF3C7 65%,#FEF3C7 100%);
}
.v3-subtitle {
  font-size: 11.5px; color: #9CA3AF;
  display: flex; gap: 8px; align-items: center; margin-top: 2px;
  transition: color .8s;
}
.v3-header[data-state="cloudy"] .v3-subtitle  { color: rgba(209,213,219,.7); }
.v3-header[data-state="dusk"] .v3-subtitle,
.v3-header[data-state="apocalypse"] .v3-subtitle { color: rgba(254,243,199,.6); }
.v3-meta-sep { color: #D1D5DB; }
.v3-status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  color: #10B981; font-weight: 600; position: relative;
  transition: color .8s;
}
.v3-ping-wrap {
  position: relative; display: inline-flex;
  width: 8px; height: 8px;
}
.v3-ping-ring {
  position: absolute; inset: -2px; border-radius: 50%;
  background: #10B981; opacity: .5;
  animation: v3pingSlow 2.4s ease-out infinite;
  transition: background .8s;
}
.v3-ping-dot {
  position: relative; width: 8px; height: 8px;
  border-radius: 50%; background: #10B981;
  transition: background .8s;
}

/* Profile pill */
.v3-profile {
  display: flex; align-items: center;
  padding: 5px 6px 5px 5px;
  background: #fff; border: 1px solid #E5E7EB; border-radius: 999px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
  transition: box-shadow .25s;
}
.v3-profile:hover { box-shadow: 0 4px 14px rgba(16,24,40,.08); }
.v3-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg,#34D399,#10B981);
  display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700; overflow: hidden;
  animation: v3avatarBreath 3.6s ease-in-out infinite;
}
.v3-avatar img { width:100%;height:100%;object-fit:cover;border-radius:50% }
.v3-profile-name { font-size:12.5px;color:#111827;padding:0 10px 0 9px;font-weight:500 }
.v3-pill-sep { width:1px;height:20px;background:#E5E7EB }
.v3-logout-btn {
  padding: 6px 12px; font-size: 12px; font-weight: 600;
  border-radius: 999px; border: none; background: transparent;
  color: #DC2626; display: inline-flex; align-items: center; gap: 5px;
  cursor: pointer; font-family: inherit; transition: background .12s, gap .15s;
}
.v3-logout-btn:hover { background: #FEE2E2; gap: 7px; }

/* Account pill (avatar + name + chevron) with a dropdown of admin actions —
   replaces the old plain profile pill so Navbar/Permissions management can
   live behind it, gated to admins only. */
.v3-account-wrap { position: relative; }
.v3-account-pill {
  display: flex; align-items: center;
  padding: 5px 10px 5px 5px; gap: 2px;
  background: #fff; border: 1px solid #E5E7EB; border-radius: 999px;
  box-shadow: 0 1px 2px rgba(16,24,40,.04);
  cursor: pointer; font-family: inherit; transition: box-shadow .25s, border-color .12s;
}
.v3-account-pill:hover, .v3-account-pill.open { border-color: var(--primary); box-shadow: 0 4px 14px rgba(16,24,40,.08); }
.v3-account-chev { color: var(--ink-3); margin-left: 4px; transition: transform .15s; flex-shrink: 0; }
.v3-account-chev.open { transform: rotate(180deg); }
.v3-account-menu {
  /* position:fixed (not absolute) + JS-computed top/left, same trick as
     .v3-bell-popover — .v3-header has overflow:hidden + a fixed height, so
     an absolutely-positioned dropdown gets clipped instead of hanging below it. */
  display: none; position: fixed; top: 0; left: 0; width: 220px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(16,24,40,.16); padding: 6px; z-index: 999;
}
.v3-account-menu.open { display: block; }
.v3-account-menu button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 11px; border: none; background: none; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
  text-align: left; font-family: inherit;
}
.v3-account-menu button:hover { background: #F9FAFB; }
.v3-account-menu .ic { width: 20px; height: 20px; display: grid; place-items: center; color: var(--ink-2); flex-shrink: 0; }
.v3-account-divider { height: 1px; background: #F0F1F3; margin: 5px 4px; }
.v3-account-menu .danger { color: #DC2626; }
.v3-account-menu .danger .ic { color: #DC2626; }

/* Navbar management modal: draggable rows + visibility toggle switch */
.nvm-list { display: flex; flex-direction: column; gap: 8px; }
.nvm-row { cursor: default; }
.nvm-row.dragging { opacity: .4; }
.nvm-drag { cursor: grab; color: var(--ink-3); display: grid; place-items: center; flex-shrink: 0; }
.nvm-drag:active { cursor: grabbing; }
.nvm-toggle {
  width: 36px; height: 20px; border-radius: 999px; background: #D1D5DB;
  position: relative; cursor: pointer; flex-shrink: 0; border: none;
}
.nvm-toggle.on { background: var(--primary); }
.nvm-knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.nvm-toggle.on .nvm-knob { left: 18px; }

/* Permissions modal: role legend + per-role menu access matrix */
.pm-legend { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px 4px; border-bottom: 1px solid #F0F1F3; }
.pm-role-card { display: flex; align-items: flex-start; gap: 10px; }
.pm-role-card p { font-size: 12px; color: var(--ink-2); line-height: 1.5; margin-top: 1px; }
.pm-role-tag { flex-shrink: 0; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; white-space: nowrap; width: 56px; text-align: center; }
.pm-role-tag.admin { color: #DC2626; background: #FEE2E2; }
.pm-role-tag.editor { color: #6366F1; background: #EEF0FF; }
.pm-role-tag.viewer { color: #6B7280; background: #F3F4F6; }
.pm-section { padding: 14px 18px; border-bottom: 1px solid #F0F1F3; }
.pm-section-title { font-size: 11px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 10px; }
.pm-table { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.pm-table-head { display: grid; grid-template-columns: 1fr repeat(3,60px); background: #F9FAFB; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.pm-table-head span { font-size: 11px; font-weight: 700; color: var(--ink-3); text-align: center; }
.pm-table-head span:first-child { text-align: left; }
.pm-table-row { display: grid; grid-template-columns: 1fr repeat(3,60px); align-items: center; padding: 9px 12px; }
.pm-table-row:not(:last-child) { border-bottom: 1px solid #F5F5F6; }
.pm-table-label { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.pm-table-cell { display: flex; justify-content: center; }
.pm-check { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }
.pm-check:disabled { cursor: not-allowed; opacity: .7; }
.pm-avatar-sm {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg,#34D399,#10B981);
  display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700;
}

/* ── v3 Navbar ─── */
.v3-navbar {
  position: sticky; z-index: 9;
  background: #fff; border-bottom: 1px solid var(--line);
}
.v3-navbar-inner {
  max-width: 1920px; margin: 0 auto;
  display: flex; align-items: center; gap: 4px;
  padding: 0 28px;
  overflow-x: auto;
}
.v3-nav-item {
  display: inline-flex; align-items: center; gap: 7px;
  flex-shrink: 0;
  padding: 13px 14px;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  text-decoration: none; border-bottom: 2px solid transparent;
  cursor: pointer; position: relative;
  transition: color .12s, border-color .12s;
}
.v3-nav-item svg { flex-shrink: 0; }
.v3-nav-item:hover:not(.disabled) { color: var(--ink); }
.v3-nav-item.active {
  color: var(--primary); border-bottom-color: var(--primary);
}
.v3-nav-item.disabled { color: var(--ink-3); cursor: not-allowed; }
.v3-nav-item.disabled:hover::after {
  content: attr(data-tooltip);
  position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: 4px; padding: 3px 8px; border-radius: 6px;
  background: #111827; color: #fff; font-size: 11px; font-weight: 500;
  white-space: nowrap; z-index: 1;
}
.v3-nav-item-right { margin-left: auto; }
.v3-nav-dropdown { position: relative; }
.v3-nav-caret { flex-shrink: 0; transition: transform .15s; }
.v3-nav-dropdown:hover .v3-nav-caret { transform: rotate(180deg); }
.v3-nav-dropdown-menu {
  display: none; position: fixed; top: 0; left: 0;
  min-width: 180px; margin-top: 2px; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(17, 24, 39, .12); z-index: 999;
}
.v3-nav-dropdown-menu.open { display: block; }
.v3-nav-dropdown-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 6px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  text-decoration: none; white-space: nowrap; cursor: pointer;
  position: relative;
}
.v3-nav-dropdown-item:hover:not(.disabled) { background: #F3F4F6; color: var(--ink); }
.v3-nav-dropdown-item.disabled { color: var(--ink-3); cursor: not-allowed; }
.v3-nav-subdropdown { position: relative; }
.v3-nav-subcaret { flex-shrink: 0; }
.v3-nav-submenu { z-index: 1000; }
.v3-nav-dropdown-item.disabled:hover::after {
  content: attr(data-tooltip);
  position: absolute; top: 50%; left: 100%; transform: translateY(-50%);
  margin-left: 8px; padding: 3px 8px; border-radius: 6px;
  background: #111827; color: #fff; font-size: 11px; font-weight: 500;
  white-space: nowrap; z-index: 1;
}
.v3-nav-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--primary); color: #fff;
  font-size: 10.5px; font-weight: 700; font-family: 'IBM Plex Mono', monospace;
}
/* ── v3 Col Header ─── */
.v3-col-header-inner {
  display: flex; align-items: center; gap: 7px;
  padding: 0 4px 10px 4px;
  flex-shrink: 0;
}
.v3-col-dot {
  width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0;
}
.v3-col-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.8px;
  color: #111827; text-transform: uppercase;
}
.v3-col-rate {
  font-size: 10.5px; color: #6B7280;
  font-family: 'IBM Plex Mono', monospace; font-weight: 600;
}

/* ── v3 Scenario Card ─── */
.v3-card {
  padding: 0; border: none;
  box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 0 0 1px rgba(16,24,40,.05);
  transition: box-shadow .2s;
  position: relative; overflow: hidden;
}
.v3-card-accent {
  height: 3px; width: 100%;
  position: relative; z-index: 1;
}
.v3-card-stripe {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  z-index: 2;
}
.v3-card-body { padding: 14px 16px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.v3-status-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  background: linear-gradient(180deg,#FAFAFB,#F4F5F8);
  border-radius: 8px; border: 1px solid #EEF0F4;
}
.v3-run-btn {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: none;
  color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 2px 8px rgba(99,102,241,.28), 0 1px 2px rgba(0,0,0,.05);
  cursor: pointer; font-family: inherit;
  transition: filter .15s, transform .05s;
  position: relative; overflow: hidden;
}
.v3-run-btn:hover:not(:disabled) { filter: brightness(1.08); }
.v3-run-btn:active:not(:disabled) { transform: translateY(1px); }
.v3-run-btn:disabled { background: linear-gradient(180deg,#9CA3AF,#6B7280)!important; cursor:wait; box-shadow:none; }

/* ── Health Tile ─── */
.v3-health-tile {
  background: linear-gradient(135deg,#FFFFFF,#F9FAFB);
  border-radius: 14px; padding: 16px;
  border: 1px dashed #D1D5DB;
  display: flex; flex-direction: column; gap: 14px;
}
.v3-health-header { display: flex; align-items: center; gap: 8px; }
.v3-health-title {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.6px;
  color: #374151; text-transform: uppercase;
}
.v3-health-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.v3-health-stat {
  background: #fff; border: 1px solid #EEF0F4;
  border-radius: 10px; padding: 10px 12px;
}
.v3-health-stat-label {
  font-size: 10px; color: #9CA3AF; font-weight: 600;
  letter-spacing: 0.4px; text-transform: uppercase; margin-bottom: 4px;
}
.v3-health-stat-value {
  font-size: 17px; font-weight: 700; color: #111827;
  font-family: 'IBM Plex Mono', monospace;
}
.v3-health-tip {
  padding: 8px 10px;
  background: rgba(20,184,166,.08); border: 1px solid rgba(20,184,166,.18);
  border-radius: 8px; font-size: 11.5px; color: #0F766E;
  display: flex; align-items: center; gap: 6px;
}

/* ── v3 Log ─── */
.v3-log-section {
  background: #0F172A; border-radius: 14px; overflow: hidden;
  box-shadow: 0 8px 24px rgba(15,23,42,.18), 0 0 0 1px rgba(15,23,42,.05);
}
.v3-log-chrome {
  display: flex; align-items: center;
  padding: 10px 16px;
  background: linear-gradient(180deg,#1E293B,#172033);
  border-bottom: 1px solid #0B1224; gap: 12px;
}
.v3-traffic-lights { display: flex; gap: 6px; flex-shrink: 0; }
.v3-tl {
  width: 11px; height: 11px; border-radius: 50%;
  box-shadow: inset 0 0 0 .5px rgba(0,0,0,.1);
}
.v3-tl-red    { background: #FF5F57; }
.v3-tl-yellow { background: #FEBC2E; }
.v3-tl-green  { background: #28C840; }
.v3-log-tab-area {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
}
.v3-run-indicator {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: #28C840; transition: background .3s;
}
.v3-run-indicator.busy { background: #F59E0B; animation: v3pulse 1.2s infinite; }
.v3-log-tab-title {
  font-size: 11.5px; font-weight: 600; color: #CBD5E1;
  font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.3px;
  white-space: nowrap;
}
.v3-log-sep { color: #475569; font-size: 11px; }
.v3-log-linecount { font-size: 10.5px; color: #64748B; font-family: 'IBM Plex Mono', monospace; }
.v3-log-chip {
  padding: 1px 7px; border-radius: 4px; font-size: 10px; font-weight: 700;
  font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.4px;
}
.v3-chip-ok   { background: rgba(134,239,172,.15); color: #86EFAC; }
.v3-chip-warn { background: rgba(252,211,77,.15);  color: #FCD34D; }
.v3-chip-err  { background: rgba(252,165,165,.15); color: #FCA5A5; }
.v3-log-btns { display: flex; gap: 6px; flex-shrink: 0; }
.v3-term-btn {
  padding: 3px 10px; border-radius: 5px;
  border: 1px solid #2A3548; background: #1E293B;
  color: #CBD5E1; font-size: 10.5px; font-weight: 600;
  font-family: 'IBM Plex Mono', monospace; cursor: pointer;
  transition: background .12s;
}
.v3-term-btn:hover { background: #2A3548; }
.v3-log-statusbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 16px;
  background: #0B1224; border-top: 1px solid #1E293B;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10.5px; color: #475569;
}

/* ── Responsive ─── */
@media (max-width: 1100px) {
  .grid-layout { grid-template-columns: 1fr 1fr; }
  /* Below the 3-col desktop layout, columns stack/wrap, so each one should
     flow with the page instead of being trapped in its own near-viewport-height
     scroll box — otherwise cards at the end of a column look cut off/covered. */
  .grid-layout > div { max-height: none; overflow: visible; }
  .cards-col { overflow: visible; }
}
@media (max-width: 600px) {
  .grid-layout { grid-template-columns: 1fr; }
  .v3-header-inner { flex-wrap: wrap; }
  #village-container { display: none; }
}

/* ── Shared modal shell (used by Service Agent + Shipment Automation modals) ─── */
.svc-overlay{display:none;position:fixed;inset:0;background:rgba(15,23,42,.45);z-index:60;align-items:center;justify-content:center}
.svc-overlay.open{display:flex}
.svc-modal{background:#fff;border-radius:14px;width:440px;max-width:92vw;max-height:88vh;overflow:hidden;display:flex;flex-direction:column;box-shadow:0 20px 50px rgba(15,23,42,.25)}
.svc-modal-head{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--line)}
.svc-modal-head h3{margin:0;font-size:15.5px;font-weight:700;color:var(--ink)}
.svc-modal-head button{border:none;background:#F3F4F6;width:28px;height:28px;border-radius:8px;font-size:14px;cursor:pointer;color:var(--ink-2)}
.svc-modal-head button:hover{background:#E5E7EB}
.svc-modal-body{padding:18px 20px;overflow-y:auto;display:flex;flex-direction:column;gap:12px}
.svc-field label{display:block;font-size:11.5px;font-weight:700;color:var(--ink-3);margin-bottom:5px}
.svc-field input,.svc-field select,.svc-field textarea{
  width:100%;padding:9px 11px;border-radius:8px;border:1px solid var(--line);
  font-size:13px;color:var(--ink);font-family:inherit;outline:none;box-sizing:border-box;
}
.svc-field textarea{resize:vertical;min-height:60px}
.svc-field input:focus,.svc-field select:focus,.svc-field textarea:focus{border-color:var(--primary)}
.svc-field-row{display:flex;gap:10px}
.svc-field-row .svc-field{flex:1}

/* ── Agent combobox (Create Test Shipment modal) — search-as-you-type ───── */
.ship-agent-combo{position:relative}
.ship-agent-combo-input{
  width:100%;padding:9px 11px;border-radius:8px;border:1px solid var(--line);
  font-size:13px;color:var(--ink);font-family:inherit;outline:none;box-sizing:border-box;
}
.ship-agent-combo-input:focus{border-color:var(--primary)}
.ship-agent-combo-list{
  position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:20;
  background:#fff;border:1px solid var(--line);border-radius:10px;
  box-shadow:0 12px 28px rgba(15,23,42,.16);max-height:240px;overflow-y:auto;padding:4px;
}
.ship-agent-combo-opt{padding:8px 10px;border-radius:7px;font-size:12.5px;color:var(--ink-2);cursor:pointer}
.ship-agent-combo-opt:hover{background:var(--bg)}
.ship-agent-combo-opt.active{background:#EEF2FF;color:var(--primary);font-weight:700}
.ship-agent-combo-code{color:var(--ink-3);font-weight:500}
.ship-agent-combo-empty{padding:10px;font-size:12px;color:var(--ink-3);text-align:center}
.svc-modal-hint{font-size:11.5px;color:var(--ink-3);margin:-4px 0 4px}
.svc-modal-hint code{font-family:'IBM Plex Mono',monospace;background:var(--bg);padding:1px 5px;border-radius:4px}
.svc-modal-foot{display:flex;justify-content:flex-end;gap:9px;padding:14px 20px;border-top:1px solid var(--line)}
.svc-btn{padding:8px 16px;border-radius:8px;border:1px solid var(--line);background:#fff;font-size:13px;font-weight:600;color:var(--ink-2);cursor:pointer;font-family:inherit}
.svc-btn-primary{background:var(--primary);border-color:var(--primary);color:#fff}
.svc-btn-primary:disabled{opacity:.5;cursor:not-allowed}
.svc-btn.danger{color:#DC2626;border-color:#FCA5A5}

/* ── Shipment Automation Settings modal ─── */
.ship-src-row{display:flex;align-items:center;gap:10px;padding:10px 0;border-bottom:1px solid var(--line)}
.ship-src-row:last-child{border-bottom:none}
.ship-src-label{width:110px;flex-shrink:0;font-size:13px;font-weight:700;color:var(--ink)}
.ship-src-row input{
  flex:1;padding:8px 10px;border-radius:8px;border:1px solid var(--line);
  font-size:12.5px;color:var(--ink);font-family:'IBM Plex Mono',monospace;outline:none;box-sizing:border-box;
}
.ship-src-row input:focus{border-color:var(--primary)}
.ship-src-row input:disabled{background:var(--bg);color:var(--ink-3)}
.ship-src-save{
  flex-shrink:0;width:32px;height:32px;border-radius:8px;border:none;background:var(--bg);color:var(--ink-2);
  display:grid;place-items:center;cursor:pointer;
}
.ship-src-save:hover{background:#E5E7EB;color:var(--primary)}
.ship-src-save:disabled{opacity:.4;cursor:not-allowed}

/* ── Create Test Shipment modal ─── */
.ship-agent-name{font-size:13.5px;font-weight:700;color:var(--ink);margin-bottom:2px}
.ship-agent-sub{font-size:11.5px;color:var(--ink-3);margin-bottom:14px}
.ship-source-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:6px}
.ship-source-btn{
  padding:12px 10px;border-radius:9px;border:1px solid var(--line);background:#fff;
  font-size:12.5px;font-weight:700;color:var(--ink-2);cursor:pointer;font-family:inherit;text-align:center;
  transition:all .12s;
}
.ship-source-btn:hover:not(:disabled){border-color:#C7D2FE}
.ship-source-btn.active{background:#EEF2FF;border-color:var(--primary);color:var(--primary)}
.ship-source-btn:disabled{opacity:.45;cursor:not-allowed;background:var(--bg)}
.ship-source-btn .sub{display:block;font-size:10px;font-weight:600;color:var(--ink-3);margin-top:3px}
.ship-term-grid,.ship-pkg-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:6px}
.ship-term-btn,.ship-pkg-btn{
  padding:9px 8px;border-radius:8px;border:1px solid var(--line);background:#fff;
  font-size:12.5px;font-weight:700;color:var(--ink-2);cursor:pointer;font-family:inherit;transition:all .12s;
}
.ship-term-btn:hover:not(:disabled),.ship-pkg-btn:hover:not(:disabled){border-color:#C7D2FE}
.ship-term-btn.active{background:#EDE9FE;border-color:#6D28D9;color:#6D28D9}
.ship-pkg-btn.active{background:#CCFBF1;border-color:#0F766E;color:#0F766E}
.ship-term-btn:disabled,.ship-pkg-btn:disabled{opacity:.45;cursor:not-allowed;background:var(--bg)}
.ship-run-list{display:flex;flex-direction:column;gap:6px;margin-top:12px}
.ship-run-item{
  display:flex;align-items:center;gap:9px;padding:9px 11px;border-radius:8px;
  background:var(--bg);font-size:12.5px;font-weight:600;color:var(--ink-2);
}
.ship-run-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0;background:#B9BDC9}
.ship-run-item.running .ship-run-dot{
  width:11px;height:11px;background:transparent;box-shadow:none;
  border:2px solid rgba(59,130,246,.25);border-top-color:#3B82F6;
  animation:ship-run-spin .7s linear infinite;
}
@keyframes ship-run-spin{to{transform:rotate(360deg)}}
.ship-run-item.success .ship-run-dot{background:#10B981}
.ship-run-item.failed .ship-run-dot{background:#EF4444}
.ship-run-item .ship-run-label{flex:1}
.ship-run-item .ship-run-log-btn{border:none;background:none;color:var(--primary);font-size:11.5px;font-weight:700;cursor:pointer;font-family:inherit}
.ship-run-log{
  white-space:pre-wrap;word-break:break-all;font-family:'IBM Plex Mono',monospace;font-size:10.5px;
  color:#D1D5DB;background:#111827;border-radius:8px;padding:10px;margin-top:6px;
  max-height:160px;overflow-y:auto;
}
.ship-summary{font-size:12.5px;font-weight:700;padding:9px 11px;border-radius:8px;margin-top:6px}
.ship-summary.ok{background:#D1FAE5;color:#065F46}
.ship-summary.partial{background:#FEF3C7;color:#92400E}
.ship-summary.bad{background:#FEE2E2;color:#991B1B}
.ship-run-number{
  font-family:'IBM Plex Mono',monospace;font-size:11px;font-weight:700;
  color:#4338CA;background:#EEF2FF;border-radius:6px;padding:2px 8px;white-space:nowrap;flex-shrink:0;
}
.ship-numbers{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:8px;padding-top:8px;border-top:1px solid var(--line)}
.ship-numbers-label{font-size:11px;font-weight:700;color:var(--ink-3);margin-right:2px}

/* ── Floating badge — job สร้าง Shipment ที่รันเบื้องหลังหลังปิด modal ────── */
.ship-floating-badge{
  position:fixed;right:20px;bottom:20px;z-index:9999;
  display:flex;align-items:center;gap:8px;padding:11px 16px;border-radius:999px;
  background:#fff;box-shadow:0 8px 24px rgba(15,23,42,.18);border:1px solid var(--line);
  font-size:12.5px;font-weight:700;color:var(--ink-2);cursor:pointer;
  transition:transform .12s,box-shadow .12s;
}
.ship-floating-badge:hover{transform:translateY(-2px);box-shadow:0 12px 28px rgba(15,23,42,.22)}
.ship-floating-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0;background:#3B82F6;box-shadow:0 0 0 3px rgba(59,130,246,.15);animation:ship-badge-pulse 1.4s ease-in-out infinite}
.ship-floating-badge.completed .ship-floating-dot,
.ship-floating-badge.partial .ship-floating-dot,
.ship-floating-badge.failed .ship-floating-dot{animation:none}
.ship-floating-badge.completed{border-color:#A7F3D0;color:#065F46}
.ship-floating-badge.completed .ship-floating-dot{background:#10B981;box-shadow:none}
.ship-floating-badge.partial{border-color:#FDE68A;color:#92400E}
.ship-floating-badge.partial .ship-floating-dot{background:#F59E0B;box-shadow:none}
.ship-floating-badge.failed{border-color:#FECACA;color:#991B1B}
.ship-floating-badge.failed .ship-floating-dot{background:#EF4444;box-shadow:none}
@keyframes ship-badge-pulse{0%,100%{opacity:1}50%{opacity:.4}}

/* ── index.html quick-action bar (Shipment automation entry points) ─── */
.v3-quick-actions{display:flex;gap:8px;margin-bottom:14px;flex-wrap:wrap}
.v3-quick-btn{
  display:flex;align-items:center;gap:6px;
  padding:7px 13px;border-radius:8px;border:none;
  font-size:12px;font-weight:700;cursor:pointer;font-family:inherit;
  transition:filter .12s;
}
.v3-quick-btn:hover{filter:brightness(1.07)}
.v3-quick-btn.primary{
  background:linear-gradient(135deg,#8B7DF7,#6366F1);color:#fff;
  box-shadow:0 3px 9px rgba(99,102,241,.28);
}
.v3-quick-btn.ghost{background:#fff;border:1px solid var(--line);color:var(--ink-2)}
.v3-quick-btn.ghost:hover{border-color:#C7D2FE;color:var(--primary)}
