:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #0f172a;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0d9488;
  --brand-2: #134e4a;
  --sidebar-grad-start: #0f172a;
  --sidebar-grad-end: #111827;
  --sidebar-text: #dbeafe;
  --nav-active-bg: #1e293b;
  --nav-active-border: #334155;
  --app-title-size: 20px;
  --brand-logo-size: 28px;
  --danger: #dc2626;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 0% 0%, #d9f7f4 0%, transparent 40%),
    radial-gradient(circle at 100% 0%, #dce4ff 0%, transparent 35%),
    var(--bg);
  min-height: 100vh;
}

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

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid #d9e6f2;
  padding: 28px;
}

h1,
h2,
h3 {
  margin: 0;
}

.brand {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

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

label {
  display: block;
  margin: 12px 0 6px;
  font-weight: 600;
  font-size: 14px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

button {
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 120ms ease, background 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--brand-2);
}

button.secondary {
  background: #0f172a;
}

button.ghost {
  background: #e2e8f0;
  color: #0f172a;
}

button.danger {
  background: var(--danger);
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar-grad-start) 0%, var(--sidebar-grad-end) 100%);
  color: var(--sidebar-text);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar .title {
  font-size: var(--app-title-size);
  font-weight: 800;
  padding: 8px 10px 16px;
}

.sidebar .title img {
  max-height: var(--brand-logo-size);
  max-width: 100%;
  vertical-align: middle;
  margin-right: 8px;
  border-radius: 6px;
}

.nav-btn {
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  color: var(--sidebar-text);
  border-radius: 10px;
  padding: 10px;
  font-weight: 600;
}

.nav-btn.active,
.nav-btn:hover {
  background: var(--nav-active-bg);
  border-color: var(--nav-active-border);
}

.main {
  padding: 18px;
}

.panel {
  background: var(--panel);
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.kpi {
  background: linear-gradient(145deg, #f8fafc, #eff6ff);
  border: 1px solid #dbeafe;
  border-radius: 12px;
  padding: 14px;
}

.kpi .v {
  font-size: 26px;
  font-weight: 800;
}

.dashboard-hero {
  background: #ffffff;
  color: #000000;
  border-color: #dbe3ea;
}

.dash-kpi {
  border: 1px solid #d7e2ec;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.dash-kpi .muted {
  color: #4b5563;
}

.dash-kpi-a { background: linear-gradient(140deg, #e8f3ee, #dceee6); }
.dash-kpi-b { background: linear-gradient(140deg, #f6efe7, #f1e6da); }
.dash-kpi-c { background: linear-gradient(140deg, #e9eff8, #dde8f5); }
.dash-kpi-d { background: linear-gradient(140deg, #eeeaf7, #e5def3); }
.dash-kpi-e { background: linear-gradient(140deg, #e7f1f3, #dcecef); }
.dash-kpi-f { background: linear-gradient(140deg, #eef1f4, #e4e9ef); }

.dash-panel-pipeline {
  background: linear-gradient(170deg, #f5f8fb, #edf3f8);
  border-color: #d9e3ed;
}

.dash-panel-ops {
  background: linear-gradient(170deg, #f4f7fb, #ecf1f7);
  border-color: #d9e3ed;
}

.dash-panel-risk {
  background: linear-gradient(170deg, #f8f5f2, #f3eeea);
  border-color: #ddd5cf;
}

.dash-bar-row {
  margin: 8px 0;
}

.dash-bar-track {
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.dash-bar-fill {
  height: 100%;
  transition: width 180ms ease;
}

.dash-risk-item {
  margin-bottom: 10px;
  padding: 8px;
  border-radius: 8px;
  border-left: 4px solid #b08968;
  background: #fcfaf8;
}

.dash-activity-item {
  margin-bottom: 10px;
  padding: 8px;
  border-radius: 8px;
  border-left: 4px solid #7c93ad;
  background: #f8fafc;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  padding: 10px 8px;
  font-size: 14px;
}

.section-box {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px;
  margin-top: 10px;
  background: #fafafa;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.tag-on {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.tag-off {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fdba74;
}

.gantt-wrap {
  display: grid;
  gap: 8px;
}

.gantt-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(260px, 2.4fr) minmax(180px, 1fr);
  gap: 8px;
  align-items: center;
}

.gantt-label {
  font-size: 12px;
  font-weight: 600;
}

.gantt-track {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.gantt-bar {
  position: absolute;
  top: 2px;
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #0d9488, #14b8a6);
}

.gantt-date {
  font-size: 12px;
  color: #475569;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.integration-card {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: 1px solid #d7e2ec;
  background: linear-gradient(155deg, #f8fbfd, #eef4f8);
  color: #0f172a;
  border-radius: 12px;
  padding: 10px;
}

.integration-card:hover {
  border-color: #94a3b8;
  transform: translateY(-1px);
}

.integration-card.active {
  border-color: #0d9488;
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.16);
  background: linear-gradient(155deg, #f0fdfa, #e6fffb);
}

.integration-icon {
  min-width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 12px;
  color: #0f172a;
  background: #ffffff;
  border: 1px solid #dbe5ef;
}

.integration-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.integration-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}

.integration-subtitle {
  font-size: 11px;
  color: #64748b;
  line-height: 1.2;
}

.integration-state {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.integration-state.connected {
  background: #ecfdf5;
  color: #166534;
  border-color: #bbf7d0;
}

.integration-state.not-connected {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.integration-detail {
  margin-top: 12px;
  border: 1px solid #dbe5ef;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(160deg, #ffffff, #f7fafc);
}

.role-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.role-card {
  border: 1px solid #dbe5ef;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(160deg, #ffffff, #f7fafc);
}

.role-level {
  font-size: 11px;
  font-weight: 700;
  color: #0f766e;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  border-radius: 999px;
  padding: 3px 8px;
}

.role-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.role-chip {
  font-size: 11px;
  border-radius: 999px;
  padding: 3px 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
}

.compact-role-table th,
.compact-role-table td {
  padding: 6px 6px;
  font-size: 12px;
  white-space: nowrap;
}

.compact-role-table input[type="checkbox"] {
  transform: scale(0.95);
}

.compact-role-table tr.role-tier-high td {
  background: #ecfdf5;
}

.compact-role-table tr.role-tier-medium td {
  background: #eff6ff;
}

.compact-role-table tr.role-tier-low td {
  background: #fff7ed;
}

.compact-intel-panel {
  padding: 12px;
}

.compact-intel-panel h3 {
  font-size: 17px;
  margin-bottom: 8px;
}

.compact-intel-panel h4 {
  margin: 8px 0 4px;
  font-size: 14px;
}

.compact-intel-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.compact-intel-panel .section-box {
  padding: 8px 10px;
  margin-top: 6px;
}

.compact-intel-panel .section-box .v {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.compact-contradictions {
  max-height: 120px;
  overflow: auto;
  line-height: 1.3;
  font-size: 13px;
}

.compact-controls {
  gap: 6px;
  margin: 6px 0;
}

.compact-controls button,
.compact-controls select,
.compact-controls input {
  font-size: 12px;
  padding: 6px 8px;
  min-height: 30px;
}

.compact-controls select {
  width: auto;
  max-width: 170px;
}

.compact-controls input {
  max-width: 260px;
}

.compact-box {
  margin-bottom: 6px;
}

.compact-table {
  margin-top: 6px;
}

.compact-table th,
.compact-table td,
.compact-intel-panel table th,
.compact-intel-panel table td {
  padding: 6px 6px;
  font-size: 12px;
  line-height: 1.25;
}

.error {
  color: #b91c1c;
  font-size: 13px;
  margin-top: 8px;
}

.success {
  color: #065f46;
  font-size: 13px;
  margin-top: 8px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    flex-direction: row;
    overflow-x: auto;
    white-space: nowrap;
  }

  .sidebar .title {
    display: none;
  }

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

  .gantt-row {
    grid-template-columns: 1fr;
  }

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

  .role-cards {
    grid-template-columns: 1fr;
  }
}
