/* ═══════════════════════════════════════════
   DARKPORT.RA  — Main Stylesheet
   Based on DarkPort Inventory design language
   ═══════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Reset & Base ───────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:       #0f1b2d;
  --navy-mid:   #1b3a5c;
  --blue:       #2563eb;
  --blue-light: #3b82f6;
  --teal:       #0e7490;
  --sidebar-bg: #0a0f1a;
  --sidebar-w:  248px;
  --bg:         #f1f5f9;
  --card-bg:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --text-muted: #64748b;
  --radius:     10px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 12px rgba(0,0,0,.1);

  /* Risk colours */
  --risk-e:   #dc2626;
  --risk-h:   #d97706;
  --risk-m:   #ca8a04;
  --risk-l:   #16a34a;
  --risk-e-bg:#fef2f2;
  --risk-h-bg:#fffbeb;
  --risk-m-bg:#fefce8;
  --risk-l-bg:#f0fdf4;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

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

.brand-link {
  text-decoration: none;
  display: block;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}

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

.logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 8px;
}

.brand-text h2 {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
}

.brand-text p {
  color: #3b82f6;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* Nav */
.nav {
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-section-label {
  color: rgba(255,255,255,.3);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 12px 10px 4px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 450;
  transition: background .15s, color .15s;
}

.nav a:hover {
  background: rgba(255,255,255,.06);
  color: #fff;
}

.nav a.active {
  background: rgba(37,99,235,.25);
  color: #93c5fd;
  font-weight: 600;
}

.nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .75;
}

.nav a.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.07);
}

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

/* ── Topbar ─────────────────────────────── */
.topbar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--navy-mid);
}

/* User menu */
.user-menu { position: relative; }

.user-menu-button {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.user-menu-button:hover { background: #e2e8f0; }

.user-dropdown {
  display: none;
  position: absolute;
  right: 0; top: calc(100% + 6px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  min-width: 180px;
  overflow: hidden;
  z-index: 200;
}

.user-menu.open .user-dropdown { display: block; }

.user-dropdown-link, .logout-button {
  display: block;
  width: 100%;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background .1s;
}

.user-dropdown-link:hover, .logout-button:hover { background: var(--bg); }

/* ── Page body ──────────────────────────── */
.page-body {
  padding: 24px;
  flex: 1;
}

/* ── Messages ───────────────────────────── */
.messages { margin-bottom: 16px; }

.message {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 6px;
}

.message.success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.message.error   { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.message.warning { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }
.message.info    { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ── Cards ──────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-mid);
}

/* ── Stat grid ──────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--navy-mid);
  line-height: 1;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Actions bar ────────────────────────── */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity .15s, box-shadow .15s;
  white-space: nowrap;
}

.btn:hover { opacity: .88; }

.btn-primary   { background: var(--blue); color: #fff; }
.btn-success   { background: #16a34a; color: #fff; }
.btn-danger    { background: var(--risk-e); color: #fff; }
.btn-warning   { background: var(--risk-h); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-teal      { background: var(--teal); color: #fff; }
.btn-navy      { background: var(--navy-mid); color: #fff; }
.btn-sm        { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-xs        { padding: 3px 8px; font-size: 11px; border-radius: 5px; }

/* ── Tables ─────────────────────────────── */
.table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.table-wrap > h3 {
  padding: 14px 16px 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy-mid);
  border-bottom: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--navy-mid);
  color: #fff;
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .03em;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

td {
  padding: 10px 14px;
  color: var(--text);
  vertical-align: middle;
}

td a {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}

td a:hover { text-decoration: underline; }

/* ── Risk badges ────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  min-width: 36px;
}

.badge-extreme  { background: var(--risk-e); color: #fff; }
.badge-high     { background: var(--risk-h); color: #fff; }
.badge-medium   { background: var(--risk-m); color: #fff; }
.badge-low      { background: var(--risk-l); color: #fff; }
.badge-none     { background: #e2e8f0; color: var(--text-muted); }

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
}

.status-draft     { background: #e2e8f0; color: #475569; }
.status-submitted { background: #dbeafe; color: #1d4ed8; }
.status-approved  { background: #dcfce7; color: #15803d; }
.status-archived  { background: #f1f5f9; color: #94a3b8; }

/* ── Forms ──────────────────────────────── */
.form-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.form-section-header {
  background: var(--navy-mid);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 7px;
  margin: 24px 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section-header:first-child { margin-top: 0; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.form-group .help-text {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.4;
}

.form-input,
input[type=text], input[type=number], input[type=email],
input[type=password], input[type=date], select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-input:focus,
input[type=text]:focus, input[type=number]:focus, input[type=email]:focus,
input[type=password]:focus, input[type=date]:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

select { appearance: auto; }
textarea { resize: vertical; min-height: 70px; }

.errorlist {
  list-style: none;
  margin: 4px 0 0;
}

.errorlist li {
  font-size: 12px;
  color: var(--risk-e);
  font-weight: 500;
}

/* ── Scored field ───────────────────────── */
.scored-group {
  position: relative;
}

.score-range {
  font-size: 11px;
  color: var(--text-muted);
  position: absolute;
  right: 0;
  top: 0;
}

.scored-field {
  background: #f0f9ff !important;
  border-color: #7dd3fc !important;
  font-weight: 600;
  text-align: center;
}

/* Computed display field */
.computed-display {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy-mid);
  min-height: 36px;
}

.computed-display.has-value { background: #f0fdf4; border-color: #86efac; }

/* ── Live score panel ───────────────────── */
.score-panel {
  position: sticky;
  top: 70px;
  background: var(--navy-mid);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px;
  font-size: 13px;
}

.score-panel-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: rgba(255,255,255,.5);
  margin-bottom: 10px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
}

.score-row:last-child { border-bottom: none; }

.score-val {
  font-size: 20px;
  font-weight: 700;
}

.score-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.score-badge.E, .score-badge.Critical { background: var(--risk-e); }
.score-badge.H, .score-badge.High     { background: var(--risk-h); }
.score-badge.M, .score-badge.Medium   { background: var(--risk-m); }
.score-badge.L, .score-badge.Low      { background: var(--risk-l); }
.score-badge.none                     { background: rgba(255,255,255,.2); }

/* ── Detail grid ────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.detail-item.full-width { grid-column: 1 / -1; }

.detail-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.detail-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 450;
}

/* ── Breadcrumb ─────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.breadcrumb a { color: var(--blue); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--border); }

/* ── Filters ─────────────────────────────── */
.filter-bar {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-group select,
.filter-group input[type=text] {
  padding: 6px 9px;
  font-size: 13px;
  min-width: 140px;
  border-radius: 7px;
  border: 1px solid var(--border);
}

/* ── Charts ─────────────────────────────── */
.dashboard-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.chart-wrap {
  height: 220px;
  position: relative;
}

/* ── Assessment form layout ─────────────── */
.assessment-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 20px;
  align-items: start;
}

@media (max-width: 900px) {
  .assessment-layout { grid-template-columns: 1fr; }
  .score-panel { position: static; }
}

/* ── Login page ─────────────────────────── */
.app-login-body {
  background: #000;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-login-wrapper {
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.app-login-card {
  background: #0d1117;
  border: 1px solid #1e2d40;
  border-radius: 16px;
  padding: 36px 32px;
}

.app-login-header { text-align: center; margin-bottom: 28px; }
.app-login-logo { display: block; margin: 0 auto 14px; max-width: 72px; height: auto; border-radius: 10px; }
.app-login-subtitle { color: #64748b; font-size: 13px; margin-bottom: 4px; }
.app-login-title { color: #fff; font-size: 20px; font-weight: 700; }
.app-login-title span { color: var(--blue-light); }

.app-login-error {
  background: #3f1212;
  border: 1px solid #7f1d1d;
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
}

.app-login-form .form-group label { color: #cbd5e1; }
.app-login-form input {
  background: #0a0f1a;
  border-color: #1e2d40;
  color: #f1f5f9;
}
.app-login-form input:focus { border-color: var(--blue); }

.app-login-button {
  width: 100%;
  padding: 11px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}

.app-login-button:hover { background: #1d4ed8; }

/* ── Confirm delete ─────────────────────── */
.delete-card {
  max-width: 480px;
  margin: 60px auto;
}

/* ── Empty state ────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  opacity: .35;
}

/* ── Tabs ───────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Utility ─────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 12px; }
.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
