:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #dde2e7;
  --text: #1c2733;
  --text-muted: #5b6b7c;
  --primary: #1f5c8b;
  --primary-dark: #164667;
  --danger: #b3311c;
  --success: #1f7a4d;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 32, 0.06), 0 1px 1px rgba(16, 24, 32, 0.04);
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}

#app {
  min-height: 100vh;
}

a {
  color: var(--primary);
}

/* ---------- Auth screens ---------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #123a54 0%, #1f5c8b 55%, #2c7bb0 100%);
}

.auth-card {
  width: 360px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(10, 20, 30, 0.25);
  padding: 32px 32px 28px;
}

.auth-logo {
  display: block;
  max-width: 200px;
  height: auto;
  margin: 0 auto 18px;
}

.auth-card h1 {
  font-size: 20px;
  margin: 0 0 4px;
  color: var(--text);
  text-align: center;
}

.auth-card .subtitle {
  text-align: center;
}

.auth-card .subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 13px;
}

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

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--primary-dark);
  color: #eaf2f8;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar .brand-logo {
  background: #ffffff;
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar .brand-logo img {
  max-width: 100%;
  height: auto;
  display: block;
}

.sidebar .brand-title {
  margin-top: 8px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: center;
  color: #ffffff;
}

/* Print-only branded report header */
.report-print-header {
  display: none;
}

.report-print-header img {
  max-width: 260px;
  height: auto;
}

.report-print-title {
  font-size: 18px;
  font-weight: 700;
  margin-top: 6px;
}

.sidebar nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar .nav-item {
  display: block;
  padding: 10px 20px;
  color: #cfe1ee;
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  cursor: pointer;
}

.sidebar .nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.sidebar .nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: #6fc0ee;
  color: #ffffff;
  font-weight: 600;
}

.sidebar .nav-item.disabled {
  color: rgba(207, 225, 238, 0.4);
  cursor: default;
}

.sidebar .nav-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  color: #a9c3d6;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar h2 {
  margin: 0;
  font-size: 17px;
}

.topbar .user-info {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.content {
  padding: 24px 28px;
  flex: 1;
}

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

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  cursor: pointer;
}

.tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(16, 24, 32, 0.1);
}

.tile.disabled {
  opacity: 0.55;
  cursor: default;
}

.tile.disabled:hover {
  transform: none;
  box-shadow: var(--shadow);
}

.tile h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.tile p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ---------- Forms / buttons ---------- */
label {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
  margin-top: 12px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
}

input:focus {
  outline: 2px solid #9dc4e0;
  outline-offset: 0;
}

button, .btn {
  font-size: 13.5px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

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

.btn-secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #f0f3f6;
}

.btn-danger {
  background: #fff;
  border-color: #e6b3ac;
  color: var(--danger);
}

.btn-danger:hover {
  background: #fdf1ef;
}

.btn-block {
  width: 100%;
  margin-top: 18px;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

.form-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.form-row input {
  flex: 1;
}

/* ---------- Tables / lists ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
}

th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

tr.row-actions td {
  white-space: nowrap;
  width: 1%;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 16px;
  font-size: 13px;
}

.breadcrumb .crumb {
  color: var(--primary);
  cursor: pointer;
  text-decoration: none;
}

.breadcrumb .crumb.current {
  color: var(--text);
  font-weight: 600;
  cursor: default;
}

.breadcrumb .sep {
  color: var(--text-muted);
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.tabs a {
  padding: 9px 14px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 13.5px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tabs a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.alert {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin: 12px 0;
}

.alert-error {
  background: #fbeceb;
  color: var(--danger);
  border: 1px solid #f0cac5;
}

.alert-info {
  background: #eaf4fb;
  color: var(--primary-dark);
  border: 1px solid #c8e0ef;
}

.empty-state {
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 20px 0;
}

.roadmap-note {
  margin-top: 28px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ---------- Risk matrix ---------- */
.matrix-table {
  border-collapse: collapse;
  margin: 8px 0 16px;
}

.matrix-table th,
.matrix-table td {
  border: 1px solid rgba(255, 255, 255, 0.6);
  text-align: center;
  padding: 0;
}

.matrix-axis-label {
  border: none !important;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 4px 8px !important;
  white-space: nowrap;
  text-align: right !important;
}

.matrix-cell {
  width: 46px;
  height: 34px;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

.matrix-cell:hover {
  outline: 2px solid #1c2733;
  outline-offset: -2px;
}

.matrix-cell.selected {
  outline: 3px solid #1c2733;
  outline-offset: -3px;
}

.risk-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.step-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  background: #fbfcfd;
}

.step-card h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.control-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef2f6;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12.5px;
  margin: 3px 6px 3px 0;
}

.control-chip button {
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-weight: 700;
  padding: 0;
}

.risk-flow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
  font-size: 13px;
}

.risk-flow .arrow {
  color: var(--text-muted);
}

/* ---------- Responsive / mobile (Phase 7) ---------- */
@media (max-width: 860px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .sidebar .brand {
    padding: 12px 16px;
    border-bottom: none;
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    white-space: nowrap;
  }

  .sidebar nav {
    display: flex;
    padding: 0;
  }

  .sidebar .nav-item {
    padding: 12px 14px;
    border-left: none;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
  }

  .sidebar .nav-item.active {
    border-left-color: transparent;
    border-bottom-color: #6fc0ee;
  }

  .sidebar .nav-footer {
    display: none;
  }

  .topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .content {
    padding: 16px;
  }

  .form-row {
    flex-wrap: wrap;
  }

  .form-row input,
  .form-row select {
    min-width: 140px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .matrix-table {
    display: table; /* keep the risk matrix as a real grid, just let the card scroll */
  }

  .card {
    overflow-x: auto;
  }
}

/* ---------- Print (Reports -> "Print / Save as PDF") ---------- */
@media print {
  .sidebar,
  .topbar,
  .tabs,
  form,
  .form-row {
    display: none !important;
  }

  .report-print-header {
    display: block !important;
    margin-bottom: 16px;
    border-bottom: 2px solid #1c2733;
    padding-bottom: 10px;
  }

  .app-shell,
  .main,
  .content {
    display: block;
    padding: 0;
    margin: 0;
  }

  .card {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  table {
    width: 100%;
  }
}
