/* ============================================================
   LAYOUT — nav, sidebar, main, toolbar, stats, table, cards
   ============================================================ */

/* TOP NAV */
.topnav {
  background: #0747A6;
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
}
.topnav-logo {
  display: flex; align-items: center; gap: 8px;
  color: #fff; font-size: 14px; font-weight: 600;
  padding: 0 8px;
}
.topnav-logo svg { flex-shrink: 0; }
.topnav-sep { width: 1px; height: 20px; background: rgba(255,255,255,.2); margin: 0 4px; }
.topnav-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #0052CC; color: #fff;
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.btn-tutorial {
  display: flex; align-items: center; gap: 5px;
  background: rgba(255,255,255,.15);
  color: rgba(255,255,255,.9);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 3px;
  padding: 5px 10px;
  font-family: 'Inter', sans-serif;
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background .1s;
}
.btn-tutorial:hover { background: rgba(255,255,255,.25); }

/* LAYOUT SHELL */
.layout { display: flex; height: calc(100vh - 48px); }

/* SIDEBAR */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: #253858;
  padding: 16px 0;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar-section { padding: 0 12px; margin-bottom: 8px; }
.sidebar-label {
  font-size: 11px; font-weight: 600;
  color: rgba(255,255,255,.45);
  letter-spacing: .06em; text-transform: uppercase;
  padding: 6px 8px 4px;
}
.sidebar-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 3px;
  color: rgba(255,255,255,.75); font-size: 13px;
  cursor: pointer; transition: background .1s;
}
.sidebar-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-item.active { background: rgba(255,255,255,.15); color: #fff; font-weight: 500; }
.sidebar-item svg { flex-shrink: 0; opacity: .7; }
.sidebar-item.active svg { opacity: 1; }

/* MAIN */
.main { flex: 1; overflow-y: auto; padding: 24px 32px; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; gap: 16px;
}
.page-title { font-size: 20px; font-weight: 600; color: var(--text); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.btn-primary {
  display: flex; align-items: center; gap: 6px;
  background: var(--blue); color: #fff;
  border: none; border-radius: 3px;
  padding: 7px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .1s; white-space: nowrap;
}
.btn-primary:hover { background: #0065FF; }

/* TOOLBAR */
.toolbar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.search-box { display: flex; align-items: center; gap: 6px; transition: border-color .1s; }
.search-box:focus-within { border-color: var(--blue); }
.search-box input {
  border: none; outline: none; background: transparent;
  font-family: 'Inter', sans-serif; font-size: 13px;
  color: var(--text); width: 180px;
}
.search-box input::placeholder { color: var(--text-faint); }

.filter-wrapper { position: relative; }
.filter-toggle {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 3px;
  padding: 5px 10px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  cursor: pointer;
  transition: border-color .1s;
}
.filter-toggle:hover { border-color: var(--border-strong); }
.filter-dropdown {
  position: absolute; top: 110%; right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  display: none; flex-direction: column; gap: 10px;
  box-shadow: 0 8px 20px rgba(9,30,66,.15);
  z-index: 20;
}
.filter-dropdown.open { display: flex; }
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; color: var(--text-muted); }
.filter-dropdown select { width: 100%; }
.clear-filters {
  margin-top: 6px; padding: 6px;
  font-size: 12px; font-family: 'Inter', sans-serif;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 3px; cursor: pointer;
}
.clear-filters:hover { background: #EDEFF2; }

/* STATS ROW */
.stats-row {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 3px; padding: 14px 16px;
}
.stat-num { font-size: 22px; font-weight: 600; color: var(--text); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* TABLE */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--surface2); border-bottom: 2px solid var(--border); }
th {
  padding: 8px 12px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  text-align: left; white-space: nowrap;
  cursor: pointer; user-select: none;
}
th:hover { color: var(--text); }
th .sort { opacity: .4; margin-left: 3px; font-size: 10px; }
tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; transition: background .08s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #F8F9FA; }
tbody tr.selected { background: var(--blue-bg); }
td { padding: 10px 12px; font-size: 13px; vertical-align: middle; }
.td-key { font-family: 'Inter', sans-serif; font-size: 12px; color: var(--blue); font-weight: 500; white-space: nowrap; }
.td-title { color: var(--text); font-weight: 400; max-width: 320px; }
.td-title-inner { display: flex; flex-direction: column; gap: 2px; }
.td-desc { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }

/* CARD VIEW (mobile) */
.card-view { display: none; flex-direction: column; gap: 10px; }
.risk-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 12px; cursor: pointer; transition: all .1s;
}
.risk-card:hover { background: #F8F9FA; }
.rc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.rc-title { font-size: 14px; font-weight: 500; }
.rc-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.rc-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }

/* RESPONSIVE */
@media(max-width:900px) {
  .table-wrap { display: none; }
  .card-view { display: flex; }
  .sidebar { display: none; }
  .stats-row { grid-template-columns: 1fr 1fr; }
}
@media(max-width:600px) {
  .main { padding: 16px; }
}
