/* GRC Portal design system. Brand colors are injected as CSS variables in base.html. */
:root {
  /* Default theme follows the defaultroute.online design system.
     Tenant branding (primary/accent/sidebar) overrides these per workspace. */
  --primary: #0b1422;
  --accent: #0e7c7b;
  --sidebar: #0b1422;
  --bg: #fafaf7;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent-soft: #e6f4f4;
  --highlight: #fbbf24;
  --ok: #15803d;
  --warn: #c2410c;
  --bad: #dc2626;
  --radius: 12px;
  --f-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --f-head: "Space Grotesk", "Inter", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: var(--f-sans); background: var(--bg); color: var(--text); font-size: 15px; }
h1, h2, h3, h4, .kpi .value, .sidebar .brand span { font-family: var(--f-head); letter-spacing: -0.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: var(--sidebar); color: #dce6f2; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar .brand { padding: 18px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand img { max-height: 36px; max-width: 140px; border-radius: 4px; background:#fff; padding:2px; }
.sidebar .brand span { font-weight: 600; font-size: 15px; color: #fff; }
.sidebar nav { padding: 12px 0; flex: 1; }
.sidebar nav a { display: block; padding: 9px 18px; color: #b9c8da; font-size: 14px; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; border-left: 3px solid var(--accent); padding-left: 15px; }
.sidebar .nav-section { padding: 14px 18px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7f93ab; }
.sidebar .foot { padding: 14px 18px; font-size: 12px; color: #7f93ab; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; min-width: 0; }
.topbar { background: var(--card); border-bottom: 1px solid var(--border); padding: 10px 24px; display: flex; align-items: center; justify-content: space-between; }
.topbar .tenant-switch select { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); }
.content { padding: 24px; max-width: 1280px; }

h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px){ .grid.cols-2,.grid.cols-3,.grid.cols-4 { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.kpi { text-align: center; padding: 20px 12px; }
.kpi .value { font-size: 30px; font-weight: 700; color: var(--primary); }
.kpi .label { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.kpi.ok .value { color: var(--ok); } .kpi.warn .value { color: var(--warn); } .kpi.bad .value { color: var(--bad); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge.ok, .badge.approved, .badge.done, .badge.low { background: #e3f7ec; color: #1d8348; }
.badge.warn, .badge.in_progress, .badge.submitted, .badge.medium, .badge.review { background: #fdf3e0; color: #b9770e; }
.badge.bad, .badge.rejected, .badge.overdue, .badge.high, .badge.critical { background: #fdeceb; color: #c0392b; }
.badge.muted, .badge.draft, .badge.todo, .badge.not_started { background: #edf1f6; color: #5d6d7e; }
.badge.info, .badge.basic { background: var(--accent-soft); color: var(--accent); }
.badge.important { background: #fdf3e0; color: #b9770e; }
.badge.essential { background: #f4e8fd; color: #7d3c98; }
.badge.key { background: var(--primary); color: #fff; }

table.data { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--border); background: #fafbfd; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }

.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 7px; padding: 8px 16px; font-size: 14px; cursor: pointer; text-decoration: none; }
.btn:hover { filter: brightness(1.1); text-decoration: none; color:#fff; }
.btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.secondary { background: #eef2f7; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }

form.inline { display: inline; }
input, select, textarea { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; background: #fff; max-width: 100%; }
textarea { width: 100%; min-height: 80px; }
label { font-size: 13px; color: var(--muted); display: block; margin: 10px 0 4px; }
.form-row { margin-bottom: 12px; }

.messages { list-style: none; margin: 0 0 16px; padding: 0; }
.messages li { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; }
.messages .success { background: #e3f7ec; color: #1d8348; }
.messages .info { background: #e8f0fe; color: #2b6cb0; }
.messages .warning { background: #fdf3e0; color: #b9770e; }
.messages .error { background: #fdeceb; color: #c0392b; }

.progressbar { height: 10px; background: #e9eef5; border-radius: 6px; overflow: hidden; }
.progressbar > div { height: 100%; background: var(--accent); border-radius: 6px; }

/* Assessment accordion */
details.func { margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); }
details.func > summary { padding: 13px 16px; font-weight: 600; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
details.func[open] > summary { border-bottom: 1px solid var(--border); }
.cat-block { padding: 8px 16px 16px; }
.cat-title { font-weight: 600; margin: 12px 0 4px; font-size: 14px; }
.cat-desc { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.req-row { display: grid; grid-template-columns: 1fr 360px; gap: 14px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: #fbfcfe; }
.req-row .code { font-weight: 600; font-size: 13.5px; }
.req-row .text { font-size: 13.5px; color: #33414f; margin-top: 3px; white-space: pre-line; }
.score-controls { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.score-controls .row { display: flex; align-items: center; gap: 6px; }
.score-controls select { padding: 4px 6px; }
.score-controls textarea { min-height: 110px; font-size: 13px; resize: vertical; }

/* Kanban */
.kanban { display: flex; gap: 14px; overflow-x: auto; align-items: flex-start; padding-bottom: 10px; }
.kanban .col { background: #eef2f7; border-radius: var(--radius); min-width: 270px; width: 270px; flex-shrink: 0; }
.kanban .col h4 { margin: 0; padding: 12px 14px; font-size: 13.5px; display:flex; justify-content: space-between; }
.kanban .col .cards { padding: 6px 10px 12px; min-height: 60px; }
.kanban .task-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: grab; font-size: 13.5px; }
.kanban .task-card .meta { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.kanban .task-card .assignee { font-size: 12px; color: var(--muted); }
.kanban .drag-over { outline: 2px dashed var(--accent); }

/* Risk matrix */
.riskmatrix { border-collapse: collapse; }
.riskmatrix td, .riskmatrix th { border: 1px solid var(--border); width: 110px; height: 60px; text-align: center; font-size: 12px; vertical-align: middle; padding:2px; }
.rm-1 { background: #e3f7ec; } .rm-2 { background: #f5f9d8; } .rm-3 { background: #fdf3e0; } .rm-4 { background: #fde4d4; } .rm-5 { background: #fdeceb; }

/* Public / auth pages */
.public-wrap { max-width: 860px; margin: 40px auto; padding: 0 20px; }
.auth-wrap { max-width: 420px; margin: 8vh auto; padding: 0 20px; }
.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 30px; }
.auth-card h1 { font-size: 20px; }
.auth-card input[type=text], .auth-card input[type=email], .auth-card input[type=password] { width: 100%; margin-bottom: 10px; }
.auth-card .btn { width: 100%; }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand img { max-height: 48px; }

/* Print / report */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { break-inside: avoid; }
}
.report-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid var(--primary); padding-bottom: 14px; margin-bottom: 20px; }
.helptext { color: var(--muted); font-size: 12.5px; }
ul.errorlist { color: var(--bad); font-size: 13px; margin: 4px 0; padding-left: 18px; }
.chart-box { position: relative; height: 300px; }


/* ---------- Responsive / mobile ---------- */
.menu-toggle { display: inline-block; background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 11px; font-size: 18px; cursor: pointer; color: var(--text); }
@media (min-width: 881px) {
  body.nav-collapsed .sidebar { display: none; }
  body.nav-collapsed .main { width: 100%; }
}
.sidebar-backdrop { display: none; }

@media (max-width: 880px) {
  .layout { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease; overflow-y: auto; }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0;
    background: rgba(11,20,34,.5); z-index: 50; }
  .topbar { position: sticky; top: 0; z-index: 40; gap: 8px; flex-wrap: wrap; }
  .content { padding: 14px; }
  h1 { font-size: 19px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .req-row { grid-template-columns: 1fr; }
  .score-controls { max-width: 420px; }
  table.data { display: block; overflow-x: auto; white-space: nowrap; }
  table.data td, table.data th { white-space: normal; min-width: 90px; }
  .kanban { gap: 10px; scroll-snap-type: x mandatory; }
  .kanban .col { min-width: 82vw; width: 82vw; scroll-snap-align: start; }
  .public-wrap { margin: 16px auto; }
  .auth-wrap { margin: 4vh auto; }
  .topbar .helptext { display: none; }
  input, select, textarea { font-size: 16px; } /* prevents iOS zoom */
}
@media (min-width: 881px) and (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: 1fr 1fr; }
}


/* Topbar icons & user menu */
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: 50%; border: 1px solid var(--border); background: var(--card); font-size: 17px;
  text-decoration: none; }
.icon-btn:hover { background: var(--accent-soft); text-decoration: none; }
.user-menu { position: relative; }
.user-menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--primary); color: #fff; font-size: 17px; }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu .menu { position: absolute; right: 0; top: 44px; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(15,23,42,.15);
  min-width: 230px; z-index: 80; padding: 6px 0; }
.user-menu .menu-head { padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13.5px; }
.user-menu .menu a, .user-menu .menu button { display: block; width: 100%; text-align: left;
  padding: 9px 14px; font-size: 13.5px; color: var(--text); background: none; border: 0; cursor: pointer; }
.user-menu .menu a:hover, .user-menu .menu button:hover { background: var(--accent-soft); text-decoration: none; }

/* Guidance panels */
details.guidance { background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 10px; margin: 0 0 16px; }
details.guidance > summary { cursor: pointer; padding: 10px 14px; font-weight: 600;
  font-size: 13.5px; color: var(--accent); }
details.guidance .guidance-body { padding: 0 14px 12px; font-size: 13.5px; line-height: 1.55;
  white-space: pre-line; color: var(--text); }


/* Chat */
.chat { display: flex; flex-direction: column; gap: 10px; max-height: 62vh; overflow-y: auto;
  padding: 8px 4px; scroll-behavior: smooth; }
.bubble { max-width: 76%; padding: 10px 14px; border-radius: 16px; font-size: 14px;
  line-height: 1.45; white-space: pre-line; }
.bubble.me { align-self: flex-end; background: var(--accent); color: #fff;
  border-bottom-right-radius: 5px; }
.bubble.them { align-self: flex-start; background: #eef2f7; border-bottom-left-radius: 5px; }
.bubble.ext { align-self: flex-start; background: var(--accent-soft);
  border: 1px solid var(--accent); border-bottom-left-radius: 5px; }
.bubble .who { font-size: 11.5px; font-weight: 700; margin-bottom: 3px; opacity: .85; }
.bubble .when { display: block; font-size: 10.5px; opacity: .65; margin-top: 5px; text-align: right; }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; margin-top: 12px;
  border-top: 1px solid var(--border); padding-top: 12px; }
.chat-compose textarea { flex: 1; min-height: 46px; max-height: 140px; border-radius: 14px; resize: none; }
.chat-compose .btn { border-radius: 12px; padding: 11px 18px; }


/* Drata-style dashboard */
.dash-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.dash-row .card { flex: 1; min-width: 220px; }
.readiness-row { display: flex; gap: 12px; flex-wrap: wrap; }
.ready-card { flex: 1; min-width: 230px; border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; text-decoration: none; color: var(--text); background: #fbfcfe;
  transition: box-shadow .15s, transform .15s; }
.ready-card:hover { box-shadow: 0 8px 24px rgba(15,23,42,.10); transform: translateY(-2px);
  text-decoration: none; }
.ready-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.fw-chip { width: 34px; height: 34px; border-radius: 9px; background: var(--accent);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; font-family: var(--f-head); }
.progressbar.rainbow > div { background: linear-gradient(90deg, #0e7c7b, #4dd0c7, #fbbf24); }
.ready-stats { display: flex; gap: 14px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.ready-stats .k { font-size: 11px; color: var(--muted); }
.donut-card { min-width: 200px; }
.donut-wrap { position: relative; height: 150px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; pointer-events: none; }
.donut-center strong { font-size: 24px; font-family: var(--f-head); }
.donut-center span { font-size: 11px; color: var(--muted); }
ul.legend { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 4px 12px; }
ul.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.notif { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 8px;
  font-size: 13px; color: var(--text); text-decoration: none; }
.notif:hover { background: var(--accent-soft); text-decoration: none; }
.notif .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--muted); }
.notif.bad .dot { background: var(--bad); } .notif.warn .dot { background: var(--warn); }
.notif.ok .dot { background: var(--ok); } .notif.plain .dot { background: var(--accent); }
.notif .chev { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }


/* Report hero + print fidelity */
.report-hero { background: radial-gradient(ellipse 600px 300px at 10% -30%, rgba(14,124,123,.4), transparent 60%),
  linear-gradient(150deg, #0b1422, #0e1a2e); border-radius: var(--radius); color: #f8fafc;
  padding: 26px 24px; margin-bottom: 16px; display: flex; justify-content: space-between;
  align-items: center; gap: 16px; flex-wrap: wrap; }
.report-hero img { max-height: 52px; background: #fff; border-radius: 8px; padding: 4px 8px; }
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .dash-row { display: block; }
  .dash-row .card { margin-bottom: 12px; }
  .report-hero { border-radius: 0; }
}


/* Clickable cards & rows */
.card.linked { position: relative; transition: box-shadow .15s, transform .15s; }
.card.linked:hover { box-shadow: 0 10px 28px rgba(15,23,42,.12); transform: translateY(-2px); }
.card.linked > a.stretch { position: absolute; inset: 0; z-index: 5; border-radius: var(--radius); }
tr.rowlink { cursor: pointer; }
tr.rowlink:hover td { background: var(--accent-soft); }


/* Roadmap grid */
.roadmap-grid { display: grid; gap: 8px; overflow-x: auto; }
.rm-head { font-weight: 700; font-family: var(--f-head); font-size: 13px; padding: 6px 8px;
  color: var(--muted); border-bottom: 2px solid var(--border); }
.rm-init { padding: 10px 8px; font-size: 13px; border-right: 2px solid var(--border); }
.rm-cell { padding: 4px; min-height: 54px; background: #fbfcfe; border-radius: 8px; }
.rm-chip { position: relative; background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 8px; padding: 8px 10px 8px 10px; font-size: 12.5px; line-height: 1.4; height: 100%; }
.rm-chip.done { background: #e3f7ec; border-color: var(--ok); text-decoration: none; }
.rm-chip.done::after { content: " ✓"; color: var(--ok); font-weight: 700; }
.rm-tick { background: none; border: 0; cursor: pointer; font-size: 11px; color: var(--muted); padding: 0 2px; }
@media (max-width: 880px) { .roadmap-grid { grid-template-columns: 160px repeat(8, 220px) !important; } }


/* Breadcrumbs */
.crumbs { font-size: 12.5px; color: var(--muted); margin: -6px 0 12px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { color: var(--border); }
.crumbs span:last-child { color: var(--text); font-weight: 600; }


/* Sidebar search + collapsible admin group */
.nav-search { padding: 12px 14px 4px; }
.nav-search input { width: 100%; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
  color: #fff; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.nav-search input::placeholder { color: #8ba0b8; }
.nav-group > summary { cursor: pointer; list-style: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { color: #fff; }

.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
