:root {
  /* Backgrounds — Hozana light warm */
  --bg: #F7F7F7;        /* background (theme.ts) */
  --bg2: #FFFFFF;        /* white cards */
  --bg3: #F0EEED;       /* default-bg-loading — subtle warm gray */
  --border: #E1E4E6;    /* black10 */

  /* Text — warm dark tones */
  --text: #16181A;       /* black */
  --text2: #747A80;      /* black50 */

  /* Accent — Hozana amber / orange */
  --accent: #F09226;     /* amber.500 */
  --accent2: #DA7918;    /* amber.600 */

  /* Semantic */
  --green: #559549;      /* green.600 */
  --red: #D52E2B;        /* red.600 */
  --yellow: #AD5700;     /* amber.800 — lisible sur fond clair */
  --blue: #235E8B;       /* blue.700 */
  --purple: #AE0A4B;     /* rosary.medium — Rosario */
  --orange: #F07900;     /* fire.dark */
  --cyan: #0C7792;       /* cyan.11 — lisible sur fond clair */

  /* Gradients */
  --gradient-hozana: linear-gradient(135deg, #F08100 0%, #FFB119 100%);
  --gradient-rosario: linear-gradient(135deg, #AE0A4B 0%, #D160E8 100%);
}

* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: 'Nunito', 'Open Sans', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}
code, pre, .mono {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--accent); }

/* SIDEBAR — always open */
nav {
  position: fixed; top: 0; left: 0; width: 260px; height: 100vh;
  background: var(--bg2); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 16px; z-index: 100;
  box-shadow: 1px 0 3px rgba(0,0,0,0.04);
}
nav .nav-inner { opacity: 1; pointer-events: all; }
nav .nav-toggle { display: none; }
nav h2 {
  font-family: 'Montserrat', 'Nunito', system-ui;
  font-size: 12px; color: var(--accent2); margin: 16px 0 8px;
  text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700;
}
nav h2:first-child { margin-top: 0; }
nav a {
  display: block; padding: 5px 10px; font-size: 13px;
  color: var(--text2); border-radius: 8px; margin: 1px 0;
  transition: background .15s, color .15s;
}
nav a:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
nav .logo {
  font-family: 'Montserrat', 'Nunito', system-ui;
  font-size: 18px; font-weight: 700;
  background: var(--gradient-hozana);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 12px;
}
#search {
  width: 100%; padding: 7px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px;
  font-family: 'Nunito', sans-serif; margin-bottom: 12px;
  transition: border-color .2s;
}
#search:focus { border-color: var(--accent); outline: none; }
#search::placeholder { color: var(--text2); }

/* MAIN */
main {
  margin-left: 260px; padding: 32px 40px;
  max-width: 100%; flex: 1;
}

/* COLLAPSIBLE SECTIONS via h2 */
.section-collapsible { overflow: hidden; transition: max-height .3s ease; }
.section-collapsible.collapsed { max-height: 0 !important; }
h2 {
  font-family: 'Montserrat', 'Nunito', system-ui;
  font-size: 22px; font-weight: 700; margin: 32px 0 0;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none; color: var(--text);
}
h2::after { content: ' \25BE'; font-size: 14px; color: var(--text2); }
h2.collapsed::after { content: ' \25B8'; }
h1 {
  font-family: 'Montserrat', 'Nunito', system-ui;
  font-size: 28px; font-weight: 700; margin-bottom: 8px;
  color: var(--text);
}
h2 {
  font-size: 22px; margin: 32px 0 16px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
h3 {
  font-family: 'Montserrat', 'Nunito', system-ui;
  font-size: 17px; font-weight: 700; margin: 20px 0 10px;
  color: var(--accent2);
}

/* KPI CARDS */
.kpi-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 16px 0; }
.kpi {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 20px; min-width: 140px; flex: 1;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: 0px 1px 2px rgba(0,0,0,0.04);
}
.kpi:hover { border-color: var(--accent); box-shadow: 0px 2px 8px rgba(240,146,38,0.10); }
.kpi .value { font-size: 32px; font-weight: 700; color: var(--accent); }
.kpi .label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* BADGES */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600; margin: 2px;
}
.badge-source { background: #DCECF8; color: var(--blue); }
.badge-dest   { background: #DFF7DA; color: #3D7732; }
.badge-lock   { background: #FFF2D8; color: #8B3F0C; }
.badge-dep    { background: #FDEEED; color: var(--purple); }
.badge-sat    { background: #FFF4D5; color: var(--yellow); }
.badge-daily  { background: #E7F9FB; color: var(--cyan); }
.badge-crit   { background: #FFE1E1; color: var(--red); }
.badge-warn   { background: #FFF4D5; color: var(--yellow); }
.badge-info   { background: #DCECF8; color: var(--blue); }

/* CARDS / DETAILS */
details {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; margin: 8px 0;
  box-shadow: 0px 1px 2px rgba(0,0,0,0.04);
}
details > summary {
  padding: 12px 16px; cursor: pointer; font-weight: 600; font-size: 14px;
  list-style: none; display: flex; align-items: center; gap: 8px;
  border-radius: 12px; transition: background .15s;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: '\25B6'; font-size: 10px; color: var(--text2);
  transition: transform .2s;
}
details[open] > summary::before { transform: rotate(90deg); }
details > summary:hover { background: var(--bg3); }
.card-body { padding: 0 16px 16px; }

/* TABS */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs input[type="radio"] { display: none; }
.tabs label {
  padding: 8px 16px; font-size: 13px; color: var(--text2);
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.tabs label:hover { color: var(--text); }
.tab-content { display: none; }
.tabs input:nth-of-type(1):checked ~ .tabs label:nth-of-type(1),
.tabs input:nth-of-type(2):checked ~ .tabs label:nth-of-type(2),
.tabs input:nth-of-type(3):checked ~ .tabs label:nth-of-type(3),
.tabs input:nth-of-type(4):checked ~ .tabs label:nth-of-type(4) {
  color: var(--accent); border-bottom-color: var(--accent);
}

/* TABLES */
table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 8px 0; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text2); font-weight: 600; background: var(--bg3); }
tr:hover { background: #FFF9ED; }

/* MERMAID — zoomable */
.mermaid-wrapper { position: relative; }
.mermaid-wrapper .zoom-btn { display: none; }
.diagram-thumb {
  cursor: pointer; transition: border-color .2s;
  border: 1px solid var(--border); border-radius: 12px;
}
.diagram-thumb:hover { border-color: var(--accent); }
.mermaid {
  background: var(--bg2); padding: 16px; border-radius: 12px;
  margin: 12px 0; overflow-x: auto; min-height: 300px; text-align: center;
  border: 1px solid var(--border);
}
.mermaid svg { margin: 0 auto; display: block; }
.mermaid svg .node, .modal-content .node, #modalGraph .node { cursor: pointer; }
.node:hover rect, .node:hover polygon { filter: brightness(0.92); }
.node:hover .nodeLabel, .node:hover span { text-decoration: underline; }

/* ZOOM MODAL — graph */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  z-index: 9999; justify-content: center; align-items: center;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px;
  width: 92vw; height: 90vh; overflow: auto;
  position: relative; text-align: center;
  box-shadow: 0px 20px 60px rgba(0,0,0,0.15);
}
.modal-close {
  position: fixed; top: 20px; right: 20px;
  background: var(--bg2); border: 1px solid var(--border);
  color: var(--text); padding: 8px 18px; border-radius: 8px;
  cursor: pointer; font-size: 14px; z-index: 10001;
  font-family: 'Nunito', sans-serif; transition: background .15s;
  box-shadow: 0px 2px 8px rgba(0,0,0,0.10);
}
.modal-close:hover { background: var(--red); color: #fff; }

/* TASK CARD (generated) */
.tcard {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 12px; margin: 8px 0; padding: 14px 18px;
  cursor: pointer; transition: border-color .2s, box-shadow .2s;
  box-shadow: 0px 1px 2px rgba(0,0,0,0.04);
}
.tcard:hover {
  border-color: var(--accent);
  box-shadow: 0px 4px 12px rgba(240, 146, 38, 0.10);
}
.tcard-header { display: flex; align-items: center; gap: 8px; }
.tcard-title { font-weight: 700; font-size: 14px; flex: 1; }
.tcard-subtitle { font-size: 12px; color: var(--text2); margin-top: 2px; }
.tcard-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }

/* TASK MODAL BODY TEMPLATE */
.tm-section { margin-bottom: 16px; }
.tm-section-title {
  font-family: 'Montserrat', 'Nunito', system-ui;
  font-size: 11px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 6px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.tm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tm-field { background: var(--bg3); border-radius: 8px; padding: 8px 12px; }
.tm-field-label {
  font-size: 10px; color: var(--text2);
  text-transform: uppercase; letter-spacing: .5px;
}
.tm-field-value { font-size: 13px; margin-top: 2px; }
.tm-field-value code {
  background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 12px;
}
.tm-table-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tm-table-list code {
  background: var(--bg); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 6px; font-size: 12px;
}
.tm-mini-graph { background: var(--bg); border-radius: 8px; padding: 12px; margin-top: 8px; }
.tm-business {
  background: linear-gradient(135deg, #FFFCED 0%, #FDEEED 100%);
  border-radius: 8px; padding: 12px 16px; font-size: 13px; line-height: 1.6;
  color: var(--text);
}

/* TASK DETAIL MODAL */
.task-modal-overlay {
  display: none; position: fixed; top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  z-index: 10002; justify-content: center; align-items: center;
}
.task-modal-overlay.active { display: flex; }
.task-modal-content {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px;
  width: min(700px, 90vw); max-height: 85vh;
  overflow-y: auto; position: relative;
  box-shadow: 0px 20px 60px rgba(0,0,0,0.15);
}
.task-modal-content h3 { margin-top: 0; }
.task-modal-close {
  position: absolute; top: 12px; right: 16px;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); padding: 6px 14px; border-radius: 8px;
  cursor: pointer; font-size: 14px; font-family: 'Nunito', sans-serif;
  transition: background .15s;
}
.task-modal-close:hover { background: var(--red); color: #fff; }
pre.sql {
  background: var(--bg3); padding: 12px; border-radius: 8px;
  overflow-x: auto; font-size: 12px; margin: 8px 0;
}
.severity { font-size: 18px; margin-right: 4px; }
p { margin: 6px 0; line-height: 1.6; font-size: 14px; }
ul, ol { margin: 6px 0 6px 20px; font-size: 14px; }
li { margin: 3px 0; }

@media (max-width: 900px) {
  nav { width: 48px; }
  nav.open { width: 100vw; }
  main { margin-left: 48px; padding: 16px; }
}
