/* Resilio — styles */

:root {
  /* Roussinov Consulting palette (roussinov.eu): deep red on white, K2D type */
  --navy: #1e1c1c;     /* ink — headings, dark chips */
  --navy-2: #3a3636;
  --teal: #980909;     /* brand red — primary accent */
  --teal-dark: #7a0707;/* brand red — hover */
  --bg: #f8f8f8;
  --surface: #ffffff;
  --border: #e4e0e0;
  --text: #1e1c1c;
  --muted: #5d5d5d;
  --faint: #8a8585;

  --green: #1f9d57;
  --amber: #c8860b;
  --blue: #2f6fed;
  --grey: #9a9595;
  --red: #980909;

  --radius: 10px;
  --shadow: 0 1px 3px rgba(30, 28, 28, 0.08), 0 1px 2px rgba(30, 28, 28, 0.06);
  --shadow-lg: 0 8px 30px rgba(30, 28, 28, 0.16);
  --font: "K2D", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--teal-dark); }

/* ---------- Header ---------- */
header.app-header {
  background: #fff;
  color: var(--text);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 3px solid var(--red);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}
.brand-lockup { display: flex; align-items: center; text-decoration: none; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-divider { width: 1px; align-self: stretch; background: var(--border); margin: 2px 2px; }
.product h1 { font-size: 19px; margin: 0; font-weight: 700; color: var(--navy); line-height: 1.05; }
.product .tagline { font-size: 12px; color: var(--muted); margin-top: 1px; }
/* ---------- Auth area (header) ---------- */
.lang-select {
  padding: 7px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font-family: var(--font); font-size: 13px; cursor: pointer;
}
.auth-area { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15;
}
.user-chip .uname { font-size: 13px; font-weight: 700; color: var(--text); }
.user-chip .utenant { font-size: 11px; color: var(--muted); }
.user-chip .utenant b { color: var(--red); font-weight: 700; }

/* ---------- Mode banner ---------- */
.mode-banner {
  background: #fff8e8; border-bottom: 1px solid #f0e0b4; color: #7a5e08;
  font-size: 12.5px; padding: 8px 24px; text-align: center;
}
.mode-banner code { background: #f3e6c4; padding: 1px 5px; border-radius: 4px; }

/* ---------- Login gate ---------- */
.login-gate { min-height: 72vh; display: grid; place-items: center; padding: 40px 20px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--red);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 36px 34px; max-width: 420px; text-align: center;
}
.login-logo { height: 34px; margin-bottom: 18px; }
.login-card h2 { margin: 0 0 8px; font-size: 22px; color: var(--navy); }
.login-card p { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.ms-logo {
  display: inline-block; width: 16px; height: 16px; vertical-align: -2px; margin-right: 6px;
  background:
    linear-gradient(#f25022 0 0) 0 0 / 7px 7px no-repeat,
    linear-gradient(#7fba00 0 0) 9px 0 / 7px 7px no-repeat,
    linear-gradient(#00a4ef 0 0) 0 9px / 7px 7px no-repeat,
    linear-gradient(#ffb900 0 0) 9px 9px / 7px 7px no-repeat;
}
.header-spacer { flex: 1; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
button {
  font-family: var(--font);
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--text);
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
}
button:active { transform: translateY(1px); }
.btn-ghost {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-color: rgba(255,255,255,0.25);
}
.btn-ghost:hover { background: rgba(255,255,255,0.16); }
.btn-primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn-primary:hover { background: var(--teal-dark); }
.btn-outline { border-color: var(--border); }
.btn-outline:hover { background: #eef2f6; }
.btn-danger { color: var(--red); border-color: #ecc9c9; background: #fdf4f4; }
.btn-danger:hover { background: #f9e7e7; }

/* ---------- Layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 24px 24px 80px; }

/* ---------- Dashboard ---------- */
.dashboard {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 18px;
  margin-bottom: 22px;
}
@media (max-width: 880px) { .dashboard { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card h2 { margin: 0 0 14px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); }

.overall {
  display: flex; align-items: center; gap: 22px;
}
.donut {
  --pct: 0;
  width: 116px; height: 116px; border-radius: 50%;
  flex-shrink: 0;
  background:
    radial-gradient(closest-side, var(--surface) 70%, transparent 71%),
    conic-gradient(var(--green) calc(var(--pct) * 1%), #e7ecf1 0);
  display: grid; place-items: center;
  position: relative;
}
.donut .pct { font-size: 26px; font-weight: 800; color: var(--navy); }
.donut .pct small { display: block; font-size: 10.5px; font-weight: 600; color: var(--faint); letter-spacing: 0.5px; text-transform: uppercase; }
.overall-stats { display: flex; flex-direction: column; gap: 6px; }
.overall-stats .row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.overall-stats .count { font-weight: 700; min-width: 28px; }

.framework-bars { display: flex; flex-direction: column; gap: 14px; }
.fw-bar .fw-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.fw-bar .fw-label .name { font-weight: 700; }
.fw-bar .fw-label .frac { color: var(--muted); }
.track { height: 9px; background: #e7ecf1; border-radius: 6px; overflow: hidden; }
.track .fill { height: 100%; background: var(--teal); border-radius: 6px; transition: width 0.4s; }

/* ---------- Status dots / legend ---------- */
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.complete { background: var(--green); }
.dot.in-review { background: var(--blue); }
.dot.in-progress { background: var(--amber); }
.dot.not-started { background: var(--grey); }
.dot.na { background: #c8d0d9; }

/* ---------- Toolbar / filters ---------- */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  margin-bottom: 16px;
}
.toolbar .search {
  flex: 1; min-width: 220px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--surface);
}
.toolbar select {
  padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px; background: var(--surface); color: var(--text);
}
.profile-bar {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.profile-bar .label { font-weight: 700; font-size: 13px; }
.profile-bar select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.profile-note { font-size: 12.5px; color: var(--muted); flex: 1; min-width: 200px; }
.appl-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 11.5px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
}
.pill.direct { background: #e3f5ec; color: #157a43; }
.pill.conditional { background: #fdf3da; color: #946b08; }
.pill.out { background: #eef1f4; color: #7a8696; }

/* ---------- Control groups & cards ---------- */
.group-header {
  display: flex; align-items: center; gap: 10px;
  margin: 26px 0 12px; padding-bottom: 8px; border-bottom: 2px solid var(--border);
}
.group-header h3 { margin: 0; font-size: 16px; color: var(--navy); }
.group-header .fw-tag {
  font-size: 11px; font-weight: 800; letter-spacing: 0.5px; text-transform: uppercase;
  background: var(--navy); color: #fff; padding: 3px 8px; border-radius: 5px;
}
.group-header .fw-full { font-size: 12px; color: var(--muted); font-weight: 400; }
.group-header .grp-count { margin-left: auto; font-size: 12.5px; color: var(--muted); }

.control {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--grey);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.control.s-complete { border-left-color: var(--green); }
.control.s-in-review { border-left-color: var(--blue); }
.control.s-in-progress { border-left-color: var(--amber); }
.control.s-not-started { border-left-color: var(--grey); }
.control.s-na { border-left-color: #c8d0d9; opacity: 0.78; }

.control-head {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px; cursor: pointer; user-select: none;
}
.control-head:hover { background: #fafbfc; }
.ref-badge {
  font-size: 11.5px; font-weight: 800; color: var(--teal-dark);
  background: #fbe9e9; border-radius: 6px; padding: 3px 8px; flex-shrink: 0; min-width: 38px; text-align: center;
}
.control-title { font-weight: 600; flex: 1; }
.control-title .cat { display: block; font-size: 11.5px; color: var(--faint); font-weight: 500; margin-top: 1px; }
.head-status { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); flex-shrink: 0; }
.chevron { transition: transform 0.15s; color: var(--faint); flex-shrink: 0; }
.control.open .chevron { transform: rotate(90deg); }

.control-body { display: none; padding: 4px 16px 16px; border-top: 1px solid var(--border); }
.control.open .control-body { display: block; }

.field { margin-top: 12px; }
.field .flabel { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--faint); margin-bottom: 3px; }
.field .ftext { font-size: 13.5px; color: var(--text); }
.meta-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-top: 12px; }
@media (max-width: 680px) { .meta-grid { grid-template-columns: 1fr; } }
.relief-box {
  margin-top: 12px; background: #fff8e8; border: 1px solid #f0e0b4; border-radius: 8px;
  padding: 9px 12px; font-size: 12.5px; color: #7a5e08;
}
.relief-box b { color: #6a5207; }

/* ---------- Deeper detail: steps & evidence ---------- */
.detail-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
@media (max-width: 680px) { .detail-cols { grid-template-columns: 1fr; } }
.detail-block {
  border: 1px solid var(--border); border-radius: 8px; padding: 11px 13px 12px; background: #fcfbfb;
}
.detail-block.steps { border-left: 3px solid var(--red); }
.detail-block.evidence { border-left: 3px solid var(--navy); }
.detail-block .dhead {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px;
  margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.detail-block.steps .dhead { color: var(--red); }
.detail-block.evidence .dhead { color: var(--navy); }
.detail-block ol, .detail-block ul { margin: 0; padding-left: 18px; }
.detail-block li { font-size: 13px; margin-bottom: 6px; line-height: 1.45; }
.detail-block li:last-child { margin-bottom: 0; }
.detail-block .dhead .scount {
  margin-left: auto; font-size: 11px; font-weight: 800; color: var(--red);
  background: #fbe9e9; padding: 1px 7px; border-radius: 999px;
}
.detail-block .dhead.full { display: flex; align-items: center; }

/* interactive checklist */
ul.checklist { list-style: none; margin: 0; padding: 0; }
ul.checklist li { margin-bottom: 7px; }
ul.checklist li:last-child { margin-bottom: 0; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; }
.check input { margin: 2px 0 0; width: 16px; height: 16px; accent-color: var(--red); flex-shrink: 0; cursor: pointer; }
.check span { font-size: 13px; line-height: 1.45; }
.check input:checked + span { color: var(--faint); text-decoration: line-through; }

/* ---------- Editable audit panel ---------- */
.audit-panel {
  margin-top: 16px; background: #f7f9fb; border: 1px solid var(--border); border-radius: 8px; padding: 14px;
}
.audit-panel h4 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.audit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 680px) { .audit-grid { grid-template-columns: 1fr; } }
.audit-grid .full { grid-column: 1 / -1; }
.audit-grid label { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.audit-grid input, .audit-grid select, .audit-grid textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px;
  font-family: var(--font); font-size: 13.5px; background: #fff; color: var(--text);
}
.audit-grid textarea { resize: vertical; min-height: 56px; }
.saved-flash { font-size: 12px; color: var(--green); margin-left: 8px; opacity: 0; transition: opacity 0.2s; }
.saved-flash.show { opacity: 1; }

/* ---------- Empty / footer ---------- */
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
footer.app-footer {
  max-width: 1180px; margin: 0 auto; padding: 20px 24px 40px; color: var(--faint); font-size: 12px; line-height: 1.6;
}
footer.app-footer strong { color: var(--muted); }
.brand-signoff {
  display: flex; align-items: center; gap: 12px;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 12.5px;
}
.brand-signoff .brand-mark {
  width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0;
  background: var(--navy); color: #fff; display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: 0.5px;
}
.brand-signoff strong { color: var(--text); }
.brand-signoff a { color: var(--teal-dark); }

/* ---------- Read-only / disabled ---------- */
.ro-tag {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--muted); background: #eef1f4; border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 999px; flex-shrink: 0;
}
.audit-grid input:disabled, .audit-grid select:disabled, .audit-grid textarea:disabled {
  background: #f4f4f4; color: var(--muted); cursor: not-allowed;
}
.check input:disabled { cursor: not-allowed; opacity: 0.55; }

/* ---------- Modal (roles) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(30,28,28,0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 200; overflow: auto;
}
.modal {
  background: var(--surface); border-radius: 12px; border-top: 4px solid var(--red);
  box-shadow: var(--shadow-lg); width: 100%; max-width: 720px; padding: 22px 24px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 18px; color: var(--navy); }
.modal-close { border: none; background: transparent; font-size: 18px; color: var(--muted); cursor: pointer; }
.modal-sub { font-size: 13px; color: var(--muted); margin: 6px 0 16px; }
.roles-add { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.roles-add input, .roles-add select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-family: var(--font); font-size: 13.5px;
}
.roles-add input { flex: 1; min-width: 180px; }
.roles-list { display: flex; flex-direction: column; gap: 6px; }
.role-row {
  display: grid; grid-template-columns: 1.6fr 1.2fr 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.role-row .re { font-weight: 600; word-break: break-all; }
.role-row .rf, .role-row .rr { color: var(--muted); }
.role-row .btn-danger { padding: 4px 10px; font-size: 12px; }
.roles-list .muted, .modal .muted { color: var(--muted); font-size: 13px; padding: 8px 0; }
.roles-legend { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.roles-legend h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }
.roles-legend .lg { font-size: 12.5px; margin-bottom: 6px; }
.roles-legend .lg b { color: var(--navy); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 9px;
  box-shadow: var(--shadow-lg); font-size: 13.5px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
