/* ============================================================
   COMPLYYY - Stylesheet
   Design principle: cockpit calm. Small, slim typeface (Inter 300-600),
   generous whitespace, dark slate sidebar, a single accent colour (signal blue).
   Responsive: sidebar on the left (desktop), slide-in (mobile/tablet).
   ============================================================ */

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

:root {
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --line:      #e4e7ec;
  --text:      #1f2733;
  --muted:     #6b7482;
  --accent:    #1c5fa8;   /* Signalblau */
  --accent-soft:#e8f0f9;
  --sidebar:   #0f1b2a;   /* dunkles Slate */
  --sidebar-line:#1e2c3e;
  --green:#1a7f4b; --green-bg:#e4f4ec;
  --yellow:#8a6d1a; --yellow-bg:#faf3d9;
  --red:#b03234; --red-bg:#fbe9e9;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16,24,40,.05);
}

* { box-sizing: border-box; }
html { font-size: 13px; }                 /* kleine Grundschrift */
body {
  margin: 0;
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}

h1 { font-size: 1.35rem; font-weight: 500; letter-spacing: -.01em; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; font-weight: 500; margin: 1.25rem 0 .5rem; }
p  { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.page-sub { color: var(--muted); margin-bottom: 1.25rem; }

/* ---------- App-Raster ---------- */
.app { display: flex; min-height: 100vh; }
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--sidebar); color: #c6d0dc;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-head { padding: 1.1rem 1rem .9rem; border-bottom: 1px solid var(--sidebar-line); }
.entity-logo { max-width: 100%; max-height: 44px; object-fit: contain; display: block; margin-bottom: .5rem; background:#fff; border-radius: 4px; padding: 3px 6px; }
.brand { font-size: 1.15rem; letter-spacing: .01em; }
.brand-name { font-weight: 600; color: #6aa5e0; letter-spacing: .02em; }

.nav { padding: .6rem 0 1.5rem; }
.nav-group { margin-top: .9rem; }
.nav-title {
  padding: 0 1rem .25rem;
  font-size: .68rem; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: #7a8aa0;
}
.nav a {
  display: block; padding: .42rem 1rem;
  color: #c6d0dc; text-decoration: none;
  font-weight: 400; font-size: .93rem;
  border-left: 2px solid transparent;
}
.nav a.nav-sub { padding-left: 1.6rem; }
.nav a:hover { background: #16283c; color: #fff; }
.nav a.active { background: #16283c; color: #fff; border-left-color: #6aa5e0; }
.nav-admin { border-top: 1px solid var(--sidebar-line); padding-top: .9rem; }
.nav-admin .nav-title { color: #d0a45c; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: .9rem;
  padding: .55rem 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.burger { display: none; background: none; border: 1px solid var(--line); border-radius: 6px; padding: .2rem .55rem; font-size: 1rem; cursor: pointer; }
.topbar-entity { font-weight: 500; }
.entity-switch select {
  font-weight: 500; border: 1px solid var(--line); border-radius: 6px;
  padding: .3rem .5rem; background: var(--accent-soft); color: var(--accent);
}
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .75rem; }
.topbar-name { color: var(--muted); }

/* ---------- Inhalt ---------- */
.content { padding: 1.5rem 1.75rem 2.5rem; max-width: 1800px; width: 100%; }
.content.htmx-request { opacity: .45; transition: opacity .15s; }
.footer { margin-top: auto; padding: .8rem 1.75rem; color: var(--muted); font-size: .8rem; border-top: 1px solid var(--line); }

/* Long body text (policy content etc.) stays legibly constrained on large monitors,
   while tables/tiles/matrices use the full content width. */
.prose { max-width: 78ch; }

/* ---------- Karten & Tabellen ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem; margin-bottom: 1.25rem;
}
.card h2:first-child { margin-top: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th {
  text-align: left; font-weight: 500; color: var(--muted);
  font-size: .78rem; letter-spacing: .04em; text-transform: uppercase;
  padding: .5rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* ---------- KPI tiles ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem; margin-bottom: 1.25rem; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; box-shadow: var(--shadow); }
.kpi[title] { cursor: help; }
.kpi .kpi-num { font-size: 1.7rem; font-weight: 300; line-height: 1.1; }
.kpi .kpi-label { color: var(--muted); font-size: .8rem; margin-top: .15rem; }
.kpi.tone-red  { border-top: 3px solid #c93234; }
.kpi.tone-yellow { border-top: 3px solid #d9b23a; }
.kpi.tone-green { border-top: 3px solid #2f9e64; }
.kpi.tone-blue { border-top: 3px solid var(--accent); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .74rem; font-weight: 500; white-space: nowrap;
}
.badge-gray   { background: #eef0f3; color: #5a626e; }
.badge-blue   { background: var(--accent-soft); color: var(--accent); }
.badge-green  { background: var(--green-bg); color: var(--green); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-red    { background: #fbe9e9; color: #b03234; }

/* ---------- Formulare ---------- */
.form-grid { display: grid; gap: .8rem; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); font-weight: 500; }
.form-grid .span-all { grid-column: 1 / -1; }
input, select, textarea {
  font: inherit; color: var(--text);
  border: 1px solid var(--line); border-radius: 6px;
  padding: .45rem .6rem; background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
textarea { min-height: 90px; resize: vertical; }

.btn {
  display: inline-block; font: inherit; font-weight: 500;
  border-radius: 6px; padding: .45rem .95rem; cursor: pointer;
  border: 1px solid transparent; text-decoration: none; text-align: center;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #174e8b; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: #f0f2f5; }
.btn-danger { background: #fbe9e9; color: #b03234; }
.btn-sm { padding: .25rem .6rem; font-size: .82rem; }

/* ---------- Meldungen ---------- */
.alert { border-radius: 6px; padding: .6rem .85rem; margin-bottom: 1rem; font-size: .9rem; }
.alert-ok    { background: var(--green-bg); color: var(--green); }
.alert-error { background: #fbe9e9; color: #b03234; }
.alert-info  { background: var(--accent-soft); color: var(--accent); }

/* ---------- Risk matrix ---------- */
.risk-cell { display: inline-block; min-width: 2.4rem; text-align: center; border-radius: 4px; padding: .1rem .35rem; font-weight: 500; }
.risk-green  { background: var(--green-bg); color: var(--green); }
.risk-yellow { background: var(--yellow-bg); color: var(--yellow); }
.risk-red    { background: #fbe9e9; color: #b03234; }

/* ---------- Login / Installer ---------- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--sidebar); }
.auth-card { background: var(--surface); border-radius: 10px; padding: 2rem 2.25rem; width: 100%; max-width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.35); margin: 1rem; }
.auth-brand { font-size: 1.6rem; }
.auth-brand .brand-name { font-weight: 600; color: var(--accent); letter-spacing: .02em; }
.auth-sub { color: var(--muted); font-size: .82rem; margin: .25rem 0 1.25rem; }

/* ---------- Kopfzeile mit Aktionen ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* ---------- Risk matrix (Risk Management & Management of Change) ---------- */
.risk-matrix-wrap { overflow-x: auto; margin: .75rem 0 1rem; }
table.risk-matrix { border-collapse: collapse; font-size: .78rem; table-layout: fixed; width: 100%; min-width: 480px; }
table.risk-matrix th, table.risk-matrix td { border: 1px solid #fff; text-align: center; padding: 0; }
.rm-corner {
  background: var(--surface); color: var(--muted); font-size: .68rem; font-weight: 500;
  padding: .4rem .6rem; text-align: left; text-transform: none; white-space: normal;
}
.rm-axis {
  background: #eef0f3; color: var(--text); font-weight: 500;
  padding: .4rem .3rem; vertical-align: middle;
  white-space: normal; word-break: normal; line-height: 1.2; font-size: .68rem;
  text-transform: none; letter-spacing: normal;
}
.rm-axis-row { text-align: left; padding-left: .5rem; }
.rm-axis .rm-num { display: block; font-weight: 700; font-size: .95rem; margin-bottom: 2px; }
.rm-cell { height: 42px; position: relative; font-weight: 600; }
.rm-cell.rm-clickable { cursor: pointer; }
.rm-cell.rm-clickable:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.rm-cell.rm-clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.rm-green  { background: #cdeedd; color: #1a7f4b; }
.rm-yellow { background: #f7e5a8; color: #8a6d1a; }
.rm-red    { background: #f3b7b8; color: #8f2224; }
.rm-score { display: block; }
.rm-count {
  position: absolute; top: 2px; right: 3px;
  background: rgba(0,0,0,.55); color: #fff; border-radius: 999px;
  font-size: .62rem; font-weight: 600; padding: 0 .3rem; line-height: 1.3;
}

/* Matrix legend: short explanation instead of repeating every level (those are
   already legible in the matrix itself). */
.rm-legend { margin-top: .75rem; display: flex; flex-direction: column; gap: .5rem; }
.rm-legend p { margin: 0; font-size: .85rem; color: var(--muted); }
.rm-legend strong { color: var(--text); }

/* ---------- Matrix size preview (admin configuration) ---------- */
.threshold-legend { display: flex; gap: 1rem; flex-wrap: wrap; margin: .5rem 0 1rem; font-size: .85rem; }
.threshold-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.threshold-swatch { width: .85rem; height: .85rem; border-radius: 3px; display: inline-block; }

/* ---------- Gauge (circular ring chart on the dashboard) ---------- */
.gauge-wrap { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.gauge-legend { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; }
.gauge-legend .dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .4rem; }

/* ---------- 6-month outlook ---------- */
.outlook-month {
  margin-bottom: 1rem; padding: .75rem .9rem;
  background: #fafbfc; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 6px;
}
.outlook-month:nth-child(even) { border-left-color: #8aa8c4; }
.outlook-month h3 { font-size: .8rem; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 .5rem; }
.outlook-item { display: flex; justify-content: space-between; gap: .75rem; padding: .35rem 0; border-bottom: 1px dashed var(--line); font-size: .88rem; }
.outlook-item:last-child { border-bottom: none; }


/* ---------- Modal (weekend choice dialog) ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,27,42,.55); z-index: 50; align-items: center; justify-content: center; }
.modal-box { background: var(--surface); border-radius: 10px; padding: 1.5rem; max-width: 380px; width: calc(100% - 2rem); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.modal-box h3 { margin: 0 0 .6rem; font-size: 1.05rem; font-weight: 500; }
.modal-box p { margin: 0 0 1.1rem; font-size: .9rem; color: var(--muted); }
.modal-actions { display: flex; flex-direction: column; gap: .5rem; }

/* ---------- Sidebar backdrop (mobile) ---------- */
.sidebar-backdrop { display: none; }

/* ============================================================
   Responsive: Tablet & Telefon
   ============================================================ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 20;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15,27,42,.5); z-index: 15; }
  .burger { display: inline-block; }
  .content { padding: 1rem; }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .topbar-name { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
