/* ── Stratus — Azure Red Team Framework ─────────────────────────────────────── */
:root {
  --bg-canvas:   #0d1117;
  --bg-primary:  #161b22;
  --bg-secondary:#1c2128;
  --bg-hover:    #21262d;
  --border:      #3a424d;
  --border-muted:#262d36;
  --text-primary:  #f0f6fc;
  --text-secondary:#c9d1d9;
  --text-muted:    #8d96a0;
  --accent:      #58a6ff;
  --accent-dim:  #1f6feb33;
  --green:       #3fb950;
  --green-dim:   #238636;
  --yellow:      #e3b341;
  --yellow-dim:  #9e6a03;
  --red:         #f85149;
  --red-dim:     #da3633;
  --purple:      #d2a8ff;
  --cyan:        #39d353;
  --sidebar-w:   234px;
  --radius:      8px;
  --radius-sm:   5px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.sidebar-brand-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #1a6dff 0%, #00c6ff 60%, #58a6ff 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  box-shadow: 0 0 12px #1a6dff55;
}
.sidebar-brand-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.4px;
  line-height: 1.2;
}
.sidebar-brand-tagline {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
  line-height: 1.2;
}

.sidebar-section {
  padding: 16px 8px 8px;
}
.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .12s, color .12s;
  margin-bottom: 1px;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent);
}
.nav-item .nav-icon {
  width: 17px;
  text-align: center;
  font-size: 15px;
  opacity: .8;
}
.nav-badge {
  margin-left: auto;
  font-size: 11px;
  background: var(--bg-hover);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 1px 7px;
  font-weight: 600;
}
.nav-item.active .nav-badge {
  background: var(--accent-dim);
  color: var(--accent);
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}

/* ── Main content ────────────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  padding: 0 26px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-heading {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}
.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}
.topbar-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.2;
}
.topbar-spacer { flex: 1; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
}
.topbar-avatar {
  width: 30px;
  height: 30px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

.page-content {
  padding: 26px;
  flex: 1;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; margin-bottom: 16px; }

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.breadcrumb a { color: var(--text-secondary); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb-sep { opacity: .4; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.card-header-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}
.stat-card-sub { font-size: 11px; color: var(--text-muted); }
.stat-card.green { border-color: var(--green-dim); }
.stat-card.green .stat-card-value { color: var(--green); }
.stat-card.yellow { border-color: var(--yellow-dim); }
.stat-card.yellow .stat-card-value { color: var(--yellow); }
.stat-card.red { border-color: var(--red-dim); }
.stat-card.red .stat-card-value { color: var(--red); }
.stat-card.blue { border-color: var(--accent); }
.stat-card.blue .stat-card-value { color: var(--accent); }
.stat-card.purple { border-color: var(--purple); }
.stat-card.purple .stat-card-value { color: var(--purple); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
thead tr {
  border-bottom: 1px solid var(--border);
}
thead th {
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  white-space: nowrap;
  text-align: left;
}
tbody tr {
  border-bottom: 1px solid var(--border-muted);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td {
  padding: 12px 16px;
  color: var(--text-secondary);
  vertical-align: middle;
}
tbody td.bold { font-weight: 600; color: var(--text-primary); }
tbody td a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
tbody td a:hover { text-decoration: underline; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-dc      { background: #1f6feb22; color: #58a6ff; border: 1px solid #1f6feb55; }
.badge-ddc     { background: #8957e533; color: #bc8cff; border: 1px solid #8957e555; }
.badge-cg      { background: #2ea04322; color: #3fb950; border: 1px solid #2ea04355; }
.badge-draft   { background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border); }
.badge-running { background: #1f6feb22; color: #58a6ff; border: 1px solid #1f6feb55; }
.badge-completed { background: #2ea04322; color: #3fb950; border: 1px solid #2ea04355; }
.badge-pending { background: #9e6a0322; color: #d29922; border: 1px solid #9e6a0355; }
.badge-authorized { background: #2ea04322; color: #3fb950; border: 1px solid #2ea04355; }
.badge-error, .badge-expired, .badge-declined, .badge-denied, .badge-cancelled {
  background: #da363322; color: #f85149; border: 1px solid #da363355;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all .12s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: #238636; border-color: #2ea043; color: #fff; }
.btn-primary:hover { background: #2ea043; color: #fff; }
.btn-accent    { background: #1f6feb; border-color: #388bfd; color: #fff; }
.btn-accent:hover { background: #388bfd; color: #fff; }
.btn-outline   { background: transparent; border-color: var(--border); color: var(--text-secondary); }
.btn-outline:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--text-muted); }
.btn-danger    { background: transparent; border-color: var(--red-dim); color: var(--red); }
.btn-danger:hover { background: #da363322; }
.btn-warning   { background: transparent; border-color: var(--yellow-dim); color: var(--yellow); }
.btn-warning:hover { background: #9e6a0322; }
.btn-ghost     { background: transparent; border-color: transparent; color: var(--text-secondary); padding: 5px 8px; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-xs { padding: 3px 9px; font-size: 12px; }
.btn-icon { padding: 6px; }
.btn-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-label .required { color: var(--red); margin-left: 2px; }
.form-control, .form-select {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-primary);
  font-size: 14.5px;
  transition: border-color .12s;
  outline: none;
  font-family: inherit;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-control-mono {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12.5px;
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
}
.form-hint code {
  background: var(--bg-hover);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.form-check-input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.form-check-label { font-size: 13px; color: var(--text-secondary); cursor: pointer; }

.form-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: background .2s;
}
.switch-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(16px); }
.switch-label { font-size: 13px; color: var(--text-secondary); cursor: pointer; }

/* Select arrow */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%238b949e'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.form-select option { background: var(--bg-secondary); color: var(--text-primary); }

/* ── Alerts / Flash ──────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-success { background: #2ea04322; border-color: var(--green-dim); color: var(--green); }
.alert-danger  { background: #da363322; border-color: var(--red-dim);   color: var(--red); }
.alert-warning { background: #9e6a0322; border-color: var(--yellow-dim); color: var(--yellow); }
.alert-info    { background: #1f6feb22; border-color: #1f6feb55; color: var(--accent); }
.alert-icon { flex-shrink: 0; font-size: 15px; }

/* ── Code / Mono ─────────────────────────────────────────────────────────── */
code, .mono {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
  background: var(--bg-hover);
  border-radius: 3px;
  padding: 1px 6px;
  color: var(--text-primary);
}
.code-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 12.5px;
  color: var(--text-primary);
  overflow-x: auto;
  white-space: pre;
}

/* ── Utility ─────────────────────────────────────────────────────────────── */
.text-muted  { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-accent { color: var(--accent); }
.text-purple { color: var(--purple); }
.d-none { display: none !important; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-1 { flex: 1; }
.ms-auto { margin-left: auto; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-0 { margin-bottom: 0; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── Copy button ─────────────────────────────────────────────────────────── */
.copy-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.copy-target {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-backdrop.hidden { display: none; }
.modal-box {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s, border-color .12s;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Status indicator ────────────────────────────────────────────────────── */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.running { background: var(--accent); box-shadow: 0 0 0 3px #1f6feb33; animation: pulse 1.5s infinite; }
.status-dot.authorized, .status-dot.completed { background: var(--green); }
.status-dot.pending { background: var(--yellow); }
.status-dot.error, .status-dot.expired, .status-dot.declined, .status-dot.cancelled, .status-dot.denied { background: var(--red); }
.status-dot.draft { background: var(--text-muted); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 #1f6feb66; }
  50% { box-shadow: 0 0 0 5px transparent; }
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 36px; margin-bottom: 12px; opacity: .4; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state-text { font-size: 13px; }

/* ── Auth layout ─────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: var(--bg-canvas);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-card {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 40px;
  width: 100%;
  max-width: 380px;
}
.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}
.auth-brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1a6dff 0%, #00c6ff 60%, #58a6ff 100%);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 10px;
  box-shadow: 0 0 18px #1a6dff44;
}
.auth-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.auth-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 4px 0 0;
}

/* ── Endpoint URL display ────────────────────────────────────────────────── */
.endpoint-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}
.endpoint-row + .endpoint-row {
  border-top: 1px solid var(--border-muted);
}
.endpoint-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  min-width: 100px;
  flex-shrink: 0;
}
.endpoint-url {
  font-family: monospace;
  font-size: 12.5px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* ── Progress/spinner ────────────────────────────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
