:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #687386;
  --line: #dfe6ef;
  --primary: #3157d5;
  --primary-dark: #2245b4;
  --danger: #b42318;
  --ok: #17803d;
  --shadow: 0 18px 55px rgba(15, 23, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea,
select {
  font: inherit;
}

.console-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: #111827;
  color: #eef2ff;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #5b7cfa, #2dd4bf);
  color: white;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7b8aa8;
  font-weight: 700;
}

.sidebar .eyebrow {
  color: #9ca3af;
}

h1,
h2,
h3 {
  margin: 0;
}

.sidebar h1 {
  font-size: 18px;
}

.side-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  color: #cbd5e1;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 12px;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.10);
  color: white;
}

.machine-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
}

.machine-card small {
  display: block;
  color: #cbd5e1;
  margin-top: 3px;
}

.dot {
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
}

.sidebar-footer {
  display: flex;
}

.main-console {
  padding: 26px;
  min-width: 0;
}

.console-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.console-header h2 {
  font-size: 28px;
}

.route-pill,
.badge,
.status-pill {
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 12px;
}

.badge {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.16);
  color: #dbeafe;
}

.badge.ok {
  color: #bbf7d0;
}

.badge.danger {
  color: #fecaca;
}

.console-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.9fr) minmax(520px, 1.4fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h3 {
  font-size: 18px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 650;
  margin: 12px 0;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #8ea2ff;
  box-shadow: 0 0 0 4px rgba(49, 87, 213, 0.12);
}

button {
  border: 0;
  border-radius: 13px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 750;
}

button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.primary {
  background: var(--primary);
  color: white;
}

.primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.secondary {
  background: #eef2ff;
  color: #243b80;
}

.secondary.danger {
  background: #fee2e2;
  color: var(--danger);
}

.button-row,
.agent-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

.tabs,
.mode-selector {
  display: flex;
  gap: 8px;
  padding: 5px;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.tab,
.mode {
  background: transparent;
  color: var(--muted);
  padding: 8px 11px;
}

.tab.active,
.mode.selected,
.mode.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
}

.mode.experimental {
  color: #9a6700;
}

.mode-card {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.mode-card > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.state-box,
.plan-card,
.run-meta,
.result-card,
.status-stream,
.activity-log,
.file-list,
.intervention {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 16px;
  padding: 13px;
}

.state-box {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 180px;
}

.plan-card,
.result-card {
  min-height: 96px;
}

.empty {
  color: var(--muted);
}

.live-panel,
.event-panel {
  grid-row: span 2;
}

.screen-preview {
  height: 360px;
  border-radius: 20px;
  border: 1px dashed #aab6ca;
  background:
    linear-gradient(135deg, rgba(49, 87, 213, 0.10), rgba(45, 212, 191, 0.08)),
    #f8fafc;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.screen-empty {
  display: grid;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.screen-empty strong {
  color: var(--text);
  font-size: 18px;
}

.status-stream,
.activity-log {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
}

.event-item {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: white;
  border: 1px solid #eef2f7;
}

.event-time {
  color: var(--muted);
  font-size: 12px;
}

.event-text {
  font-size: 13px;
}

.intervention {
  border-color: #fbbf24;
  background: #fffbeb;
  margin-bottom: 12px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1100px) {
  .console-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .console-grid {
    grid-template-columns: 1fr;
  }

  .live-panel,
  .event-panel {
    grid-row: auto;
  }
}

@media (max-width: 720px) {
  .main-console {
    padding: 16px;
  }

  .console-header,
  .two-col {
    grid-template-columns: 1fr;
    display: grid;
  }

  .screen-preview {
    height: 240px;
  }
}


/* Email Pipeline V1 */
.email-panel{grid-column:1/-1}.email-grid,.email-columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.email-card,.mini-row{border:1px solid #e5e7eb;border-radius:14px;background:#fff;padding:12px}.mini-list{display:grid;gap:8px;max-height:360px;overflow:auto;margin-top:10px}.mini-row{display:grid;gap:6px}.mini-row small{color:var(--muted)}.button-row.tight{gap:6px;margin-top:4px}@media(max-width:900px){.email-grid,.email-columns{grid-template-columns:1fr}}


/* EMAIL_UI_V1_STYLE_MARKER */
.email-view .console-grid {
  grid-template-columns: 1fr;
}
.email-view .console-grid > .panel:not(#emailPanel):not(#authPanel) {
  display: none;
}
#emailPanel.hidden { display: none; }
.email-panel {
  grid-column: 1 / -1;
  min-height: 70vh;
}
.email-shell { display: grid; gap: 16px; }
.email-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.email-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.email-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  overflow-x: auto;
}
.email-tab {
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}
.email-tab.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.08);
}
.email-badge,
.email-chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 5px 9px;
  font-size: 12px;
  color: var(--muted);
  background: white;
}
.email-badge.ok,
.email-chip.ok { color: var(--ok); background: #ecfdf3; border-color: #bbf7d0; }
.email-badge.warn,
.email-chip.warn { color: #9a6700; background: #fffbeb; border-color: #fde68a; }
.email-badge.danger,
.email-chip.danger { color: var(--danger); background: #fee2e2; border-color: #fecaca; }
.email-message {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: var(--panel-soft);
  color: var(--text);
}
.email-message.error { border-color: #fecaca; background: #fef2f2; color: var(--danger); }
.email-message.warn { border-color: #fde68a; background: #fffbeb; color: #9a6700; }
.email-card-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
}
.email-card {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 16px;
  padding: 13px;
  display: grid;
  gap: 6px;
}
.email-card small { color: var(--muted); font-weight: 700; }
.email-card strong { font-size: 22px; }
.email-card.wide strong { font-size: 14px; }
.email-workspace {
  display: grid;
  gap: 12px;
}
.email-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.email-info-box,
.email-detail,
.email-empty {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  border-radius: 16px;
  padding: 14px;
}
.email-info-box h4 { margin: 0 0 8px; }
.email-table-toolbar { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.email-table-wrap {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: auto;
  background: white;
}
.email-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
.email-table th,
.email-table td {
  text-align: left;
  border-bottom: 1px solid #eef2f7;
  padding: 10px 12px;
  font-size: 13px;
  vertical-align: top;
}
.email-table th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.email-table tr[data-email-select] { cursor: pointer; }
.email-table tr[data-email-select]:hover { background: #f8fafc; }
.email-detail {
  position: sticky;
  bottom: 18px;
  max-height: 520px;
  overflow: auto;
}
.email-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}
.email-detail-head h4 { margin: 0; }
.email-json {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 260px;
  background: white;
  border: 1px solid #eef2f7;
  border-radius: 12px;
  padding: 10px;
  font-size: 12px;
}
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
@media (max-width: 1100px) {
  .email-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .email-info-grid { grid-template-columns: 1fr; }
}




/* EMAIL_UI_PRODUCTION_V3_STYLE */
.mini-button{border:1px solid var(--line);border-radius:999px;background:white;color:var(--muted);font-size:11px;padding:4px 8px;margin-left:6px;cursor:pointer}.email-view .console-grid{grid-template-columns:1fr}.email-view .console-grid>.panel:not(#emailPanel):not(#authPanel){display:none}#emailPanel.hidden{display:none}.email-panel{grid-column:1/-1;min-height:70vh}.email-shell{display:grid;gap:16px}.email-header-row{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}.email-actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}.email-tabs{display:flex;gap:8px;padding:6px;border:1px solid var(--line);border-radius:16px;background:var(--panel-soft);overflow-x:auto}.email-tab{background:transparent;color:var(--muted);white-space:nowrap}.email-tab.active{background:white;color:var(--primary);box-shadow:0 4px 18px rgba(15,23,42,.08)}.email-layout{display:grid;grid-template-columns:minmax(0,1fr) 430px;gap:14px;align-items:start}.email-badge,.email-chip{display:inline-flex;align-items:center;border-radius:999px;border:1px solid var(--line);padding:5px 9px;font-size:12px;color:var(--muted);background:white}.email-badge.ok,.email-chip.ok{color:var(--ok);background:#ecfdf3;border-color:#bbf7d0}.email-badge.warn,.email-chip.warn{color:#9a6700;background:#fffbeb;border-color:#fde68a}.email-badge.danger,.email-chip.danger{color:var(--danger);background:#fee2e2;border-color:#fecaca}.email-message{border:1px solid var(--line);border-radius:14px;padding:11px 12px;background:var(--panel-soft);color:var(--text)}.email-message.hidden{display:none}.email-message.error{border-color:#fecaca;background:#fef2f2;color:var(--danger)}.email-message.warn{border-color:#fde68a;background:#fffbeb;color:#9a6700}.email-card-grid{display:grid;grid-template-columns:repeat(6,minmax(120px,1fr));gap:12px}.email-card{border:1px solid var(--line);background:var(--panel-soft);border-radius:16px;padding:13px;display:grid;gap:6px}.email-card small{color:var(--muted);font-weight:700}.email-card strong{font-size:22px}.email-card.wide strong{font-size:14px}.email-workspace{display:grid;gap:12px}.email-info-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.email-info-box,.email-detail,.email-empty{border:1px solid var(--line);background:var(--panel-soft);border-radius:16px;padding:14px}.email-info-box h4{margin:0 0 8px}.email-table-toolbar{display:flex;justify-content:flex-end;margin-bottom:8px}.email-table-wrap{border:1px solid var(--line);border-radius:16px;overflow:auto;background:white}.email-table{width:100%;border-collapse:collapse;min-width:760px}.email-table th,.email-table td{text-align:left;border-bottom:1px solid #eef2f7;padding:10px 12px;font-size:13px;vertical-align:top}.email-table th{color:var(--muted);background:#f8fafc;font-size:12px;text-transform:uppercase;letter-spacing:.04em}.email-table tr[data-email-select]{cursor:pointer}.email-table tr[data-email-select]:hover{background:#f8fafc}.email-detail{position:sticky;top:18px;max-height:calc(100vh - 80px);overflow:auto}.email-detail.hidden{display:none}.email-detail-head{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:10px}.email-detail-head h4{margin:0}.email-detail textarea,.email-detail input{width:100%;box-sizing:border-box}.email-json{white-space:pre-wrap;overflow:auto;max-height:260px;background:white;border:1px solid #eef2f7;border-radius:12px;padding:10px;font-size:12px}.ghost{background:transparent;border:1px solid var(--line);color:var(--muted)}@media(max-width:1200px){.email-layout{grid-template-columns:1fr}.email-card-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.email-info-grid{grid-template-columns:1fr}}
