:root {
  --bg: #0b1220;
  --surface: #141d2f;
  --surface-2: #1a2540;
  --border: #2a3a5c;
  --text: #e8edf7;
  --muted: #8b9dc3;
  --accent: #3b82f6;
  --accent-2: #06b6d4;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --container-pad: 24px;
  --header-gap: 12px;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: radial-gradient(ellipse at top, #152238 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.5;
  overflow-x: hidden;
}

a { color: var(--accent-2); text-decoration: none; }

img, svg { max-width: 100%; height: auto; }

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: var(--container-pad);
  padding-left: max(var(--container-pad), env(safe-area-inset-left));
  padding-right: max(var(--container-pad), env(safe-area-inset-right));
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: var(--header-gap);
}

.header-brand { flex: 1 1 200px; min-width: 0; }

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex: 1 1 auto;
}

.header-actions .btn,
.header-actions select {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.header-actions select {
  min-width: 140px;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo span { color: var(--accent-2); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.badge.live { color: var(--success); }
.badge.demo { color: var(--warning); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

h1, h2, h3 { letter-spacing: -0.02em; }
h2 { font-size: 1.1rem; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 0.9rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform 0.15s, opacity 0.15s;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: linear-gradient(135deg, var(--accent), #2563eb); color: white; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; }
.btn-record { background: linear-gradient(135deg, #ef4444, #b91c1c); color: white; font-size: 1rem; padding: 16px 28px; border-radius: 999px; }
.btn-record.recording { animation: pulse 1.5s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5); }
  50% { box-shadow: 0 0 0 16px rgba(239, 68, 68, 0); }
}

.stat-value { font-size: 2rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 0.85rem; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  width: 100%;
  min-width: 0;
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  font: inherit;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}

.stat-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  background: var(--surface-2);
}

.stat-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.stat-card .stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-card .stat-label {
  font-size: 0.72rem;
  line-height: 1.25;
  margin-top: 4px;
}

.stat-card.highlight {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.12);
}

.section-flash {
  animation: section-flash 1.2s ease;
}

@keyframes section-flash {
  0%, 100% { box-shadow: var(--shadow); }
  40% { box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.55); }
}

.task-item {
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.task-item:hover, .task-item.active { border-color: var(--accent); }
.task-item.active { background: rgba(59, 130, 246, 0.06); }

.task-card {
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.task-card.expanded { border-color: var(--accent); }

.task-header {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: none;
  border: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.task-header:hover { background: rgba(255, 255, 255, 0.02); }

.task-header-main { flex: 1; min-width: 0; }

.task-header-main strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.35;
  word-break: break-word;
}

.task-progress {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.task-progress.done { color: var(--success); border-color: rgba(34, 197, 94, 0.35); }

.task-body {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}

.task-checklist {
  list-style: none;
  margin: 12px 0;
}

.task-checklist li { margin-bottom: 4px; }

.task-checklist label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.task-checklist label:hover { background: rgba(255, 255, 255, 0.03); }

.task-checklist input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.task-checklist label span {
  flex: 1;
  font-size: 0.92rem;
  line-height: 1.4;
}

.task-checklist input:checked + span {
  color: var(--muted);
  text-decoration: line-through;
}

.task-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.82rem;
}
.task-item .priority { font-size: 0.7rem; text-transform: uppercase; font-weight: 700; }
.priority-high { color: var(--danger); }
.priority-medium { color: var(--warning); }

.transcript-box {
  min-height: 120px;
  max-height: 280px;
  overflow-y: auto;
  padding: 16px;
  background: #0a0f1a;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.voice-orb {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  margin: 24px auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 30%, #1e3a5f, #0b1220);
  border: 2px solid var(--border);
  font-size: 3rem;
  transition: all 0.3s;
}

.voice-orb.listening {
  border-color: var(--danger);
  background: radial-gradient(circle at 30% 30%, #4a1520, #1a0a10);
}

.checklist li {
  list-style: none;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.checklist .done { color: var(--success); }

.task-actions .btn {
  flex: 1 1 auto;
  min-width: min(100%, 160px);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  padding: 0 4px 4px;
}

.table-scroll table {
  min-width: 520px;
}

.table-scroll::-webkit-scrollbar {
  height: 6px;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; white-space: nowrap; }
td { word-break: break-word; }

.severity-critical { color: var(--danger); }
.severity-warning { color: var(--warning); }
.severity-ok { color: var(--success); }

.nav-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.nav-tabs a {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
}
.nav-tabs a.active { background: var(--accent); border-color: var(--accent); color: white; }

.hero {
  text-align: center;
  padding: 60px 20px;
}
.hero h1 { font-size: 2.2rem; margin-bottom: 12px; }
.hero p { color: var(--muted); max-width: 560px; margin: 0 auto 28px; }

.role-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; max-width: 700px; margin: 0 auto; }
.role-card {
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}
.role-card:hover { transform: translateY(-4px); border-color: var(--accent); }

.role-card .icon-box {
  width: 2.4em;
  height: 2.4em;
  font-size: 1.1rem;
  margin: 0 auto 0.65em;
  border-radius: 0.55em;
  background: linear-gradient(145deg, var(--surface-2) 0%, #111827 100%);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.role-card .icon-box svg {
  width: 1.1em;
  height: 1.1em;
  color: #c8d4ea;
  opacity: 0.92;
}

.role-card:hover .icon-box {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transform: scale(1.04);
}

.role-card:hover .icon-box svg {
  color: #e8edf7;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.section-header h2 { margin-bottom: 0; }

.section-header select {
  flex: 1 1 180px;
  max-width: 100%;
}

.page-intro {
  margin-bottom: 12px;
}

.toolbar-compact .btn {
  font-size: 0.8rem;
  padding: 8px 12px;
}

#status-toast {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  right: auto;
  max-width: min(92vw, 420px);
  padding: 12px 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: none;
  z-index: 100;
  text-align: center;
  box-shadow: var(--shadow);
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.task-rank {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-2);
}

.integral-score {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 600;
}

.task-context {
  font-size: 0.82rem;
  margin-top: 2px;
}

.meeting-block {
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border);
}

.block-header strong {
  font-size: 0.9rem;
}

.block-script {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
}

.blocks-container .meeting-block:last-child {
  margin-bottom: 0;
}

.history-meta {
  margin-bottom: 6px;
}

.sla-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

.sla-badge.overdue {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.status-pill {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
}

.branch-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.branch-block {
  border-color: rgba(6, 182, 212, 0.35);
}

.esc-level {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
  margin-right: 6px;
}

.section-spaced { margin-top: 16px; }

select.btn {
  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='none' stroke='%238b9dc3' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  text-overflow: ellipsis;
  overflow: hidden;
}
@media (min-width: 900px) {
  :root { --container-pad: 28px; }

  .stats-row {
    grid-template-columns: repeat(auto-fit, minmax(120px, 140px));
    justify-content: flex-start;
  }

  .stat-card { width: 100%; }

  .grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-tabs {
    display: flex;
    width: fit-content;
    max-width: 100%;
  }

  .nav-tabs a {
    padding: 8px 20px;
    white-space: nowrap;
  }

  .meeting-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
  }

  .meeting-layout .meeting-main {
    grid-column: 1 / -1;
  }

  #status-toast {
    left: auto;
    right: max(24px, env(safe-area-inset-right));
    transform: none;
    text-align: left;
  }
}

@media (min-width: 1100px) {
  .container { max-width: 1200px; }

  .stats-row--manager {
    grid-template-columns: repeat(6, minmax(100px, 1fr));
  }
}

/* ——— Mobile optimizations ——— */
@media (max-width: 640px) {
  :root { --container-pad: 16px; }

  header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: stretch;
    width: 100%;
  }

  .header-actions .btn,
  .header-actions select,
  .header-actions a.btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
  }

  .header-actions select {
    flex: 1 1 100%;
    width: 100%;
  }

  .toolbar-compact .btn,
  .toolbar-compact a.btn {
    flex: 1 1 calc(50% - 4px);
    white-space: normal;
    line-height: 1.2;
    min-height: 40px;
  }

  .card { padding: 16px; }

  .logo { font-size: 1.1rem; }

  h2 { font-size: 1rem; }

  .hero { padding: 32px 0 40px; }
  .hero h1 { font-size: 1.65rem; }
  .hero p { font-size: 0.92rem; }

  .role-cards {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .role-card { padding: 22px 18px; }

  .stat-card .stat-value { font-size: 1.15rem; }
  .stat-card .stat-label { font-size: 0.68rem; }

  .task-header {
    padding: 12px;
    gap: 10px;
  }

  .task-body { padding: 0 12px 12px; }

  .task-progress {
    align-self: flex-start;
    margin-top: 2px;
  }

  .task-meta {
    gap: 6px;
  }

  .task-meta > * {
    font-size: 0.65rem !important;
  }

  .task-actions {
    flex-direction: column;
  }

  .task-actions .btn {
    width: 100%;
    min-width: 0;
  }

  .branch-choices .btn {
    width: 100%;
    white-space: normal;
    text-align: left;
    justify-content: flex-start;
    line-height: 1.35;
    padding: 12px 14px;
  }

  .voice-orb {
    width: 110px;
    height: 110px;
    font-size: 2.4rem;
    margin: 16px auto;
  }

  .btn-record {
    width: 100%;
    max-width: 320px;
    padding: 14px 20px;
    font-size: 0.95rem;
  }

  .transcript-box {
    min-height: 100px;
    max-height: 220px;
    padding: 12px;
    font-size: 0.9rem;
  }

  .meeting-block { padding: 10px; }

  .task-checklist label {
    padding: 10px;
    gap: 12px;
  }

  .task-checklist input[type="checkbox"] {
    width: 22px;
    height: 22px;
    margin-top: 0;
  }

  .nav-tabs a {
    font-size: 0.82rem;
    padding: 10px 8px;
  }

  .table-scroll table {
    min-width: 480px;
    font-size: 0.82rem;
  }

  th, td { padding: 8px 10px; }

  .section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .section-header select {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .nav-tabs {
    grid-template-columns: 1fr;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

#status-toast.show { display: block; }

.v2-tag {
  font-size: 0.65em;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(59,130,246,0.3), rgba(6,182,212,0.2));
  color: var(--accent-2);
  vertical-align: middle;
  margin-left: 4px;
}

.role-card--admin {
  border-color: rgba(245, 158, 11, 0.4) !important;
  background: linear-gradient(160deg, var(--surface), rgba(245, 158, 11, 0.06));
}
