/* EuBiA · gemeinsames Stylesheet für CRM, LMS und Backoffice.
   Quelle: input/style (Style-JSON von www.eubia.de) → design/tokens.json. Bei Änderungen beide pflegen. */
@import url("https://fonts.googleapis.com/css2?family=Jost:wght@400;500;600&display=swap");

:root {
  --primary: #9D1915;
  --secondary: #9A1B1B;
  --primary-dark: #7A1310;
  --primary-soft: #F6E8E7;
  --accent: #2EA3F2;
  --accent-soft: #E6F4FD;
  --navy: #112337;
  --text: #545454;
  --heading: #222222;
  --text-muted: #8A8A8A;
  --border: #E2E2E2;
  --surface: #FFFFFF;
  --bg: #F2F2F2;
  --input-bg: #F4F4F4;
  --input-text: #333333;
  --input-border: #CCCCCC;
  --success: #2E7D4F;
  --success-soft: #E5F2EA;
  --warn: #B26A00;
  --warn-soft: #FFF3DC;
  --radius: 3px;
  --font: "Jost", Helvetica, Arial, Lucida, sans-serif;
  --area: var(--primary);
}
[data-area="crm"] { --area: var(--primary); }
[data-area="lms"] { --area: var(--accent); }
[data-area="backoffice"] { --area: var(--navy); }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 16px; line-height: 1.5; color: var(--text); background: var(--bg); }
h1, h2, h3 { font-weight: 600; color: var(--heading); line-height: 1.2; margin: 0 0 .4em; }
h1 { font-size: 30px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
a { color: var(--accent); }

/* ---------- Rahmen ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); border-top: 4px solid var(--area); padding: 20px 14px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; overflow: auto; }
.brand { display: block; padding: 0 8px; text-decoration: none; }
.brand img { width: 150px; height: auto; display: block; }
.brand span { display: block; margin-top: 6px; font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--area); font-weight: 600; }

.areas { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: var(--radius); }
.areas a { flex: 1; text-align: center; font-size: 13px; font-weight: 500; color: var(--text); text-decoration: none; padding: 6px 4px; border-radius: var(--radius); }
.areas a:hover { color: var(--heading); }
.areas a.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--text); text-decoration: none; padding: 9px 12px; border-radius: var(--radius); border-left: 3px solid transparent; }
.nav a:hover { background: var(--bg); color: var(--heading); }
.nav a.active { background: var(--primary-soft); color: var(--primary); border-left-color: var(--primary); font-weight: 500; }
.side .foot { margin-top: auto; font-size: 12px; color: var(--text-muted); padding: 0 8px; }

.main { padding: 28px 36px 60px; min-width: 0; }
.top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.top p { margin: 0; color: var(--text-muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Bausteine ---------- */
.btn { font: inherit; font-size: 15px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; border: 0; cursor: pointer; padding: 9px 18px; border-radius: var(--radius); background: var(--primary); color: #fff; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: var(--primary); box-shadow: inset 0 0 0 1.5px var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.plain { background: transparent; color: var(--text); padding: 6px 10px; }
.btn.plain:hover { background: var(--bg); }
.btn.danger { background: transparent; color: var(--primary); }
.btn.small { font-size: 13px; padding: 5px 10px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.card.accent { border-top: 3px solid var(--area); }
.card p { margin: 0; color: var(--text-muted); font-size: 15px; }
.kpi { font-size: 34px; font-weight: 600; color: var(--heading); line-height: 1.1; }
.kpi-label { font-size: 14px; color: var(--text-muted); }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; }
.panel-body { padding: 18px; }
.stack { display: grid; gap: 20px; }
.two { display: grid; gap: 20px; grid-template-columns: 1fr 1fr; }

.tag { display: inline-block; font-size: 12px; line-height: 1.6; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--text); font-weight: 500; white-space: nowrap; }
.tag.red { background: var(--primary-soft); color: var(--primary); }
.tag.blue { background: var(--accent-soft); color: #1878B8; }
.tag.green { background: var(--success-soft); color: var(--success); }
.tag.amber { background: var(--warn-soft); color: var(--warn); }
.muted { color: var(--text-muted); }
.empty { padding: 32px; text-align: center; color: var(--text-muted); }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-weight: 500; color: var(--text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #FAFAFA; }
td strong { color: var(--heading); font-weight: 500; }

/* Formulare – eckig wie auf eubia.de */
input, select, textarea { font: inherit; font-size: 15px; color: var(--input-text); background: var(--input-bg); border: 1px solid var(--input-border); border-radius: 0; padding: 9px 11px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; background: #fff; }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }
label { display: block; font-size: 14px; color: var(--text); }
label > span { display: block; margin-bottom: 4px; font-weight: 500; }
.form { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form .full { grid-column: 1 / -1; }
.search { max-width: 280px; }

/* Dialog */
dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(720px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--text); }
dialog::backdrop { background: rgba(17,35,55,.45); }
dialog header { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--border); border-top: 4px solid var(--area); }
dialog header h3 { margin: 0; }
dialog .body { padding: 20px 22px; max-height: 70vh; overflow: auto; }
dialog footer { display: flex; justify-content: space-between; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: #FAFAFA; }

/* Kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #E9E9E9; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.col h4 { margin: 2px 4px 10px; font-size: 14px; font-weight: 600; color: var(--heading); display: flex; justify-content: space-between; }
.col.over { outline: 2px dashed var(--accent); }
.lead { background: var(--surface); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.08); cursor: grab; border-left: 3px solid var(--area); }
.lead b { display: block; color: var(--heading); font-weight: 500; }
.lead small { color: var(--text-muted); display: block; }

/* Anwesenheits-Raster */
.att td, .att th { text-align: center; padding: 8px 6px; }
.att td:first-child, .att th:first-child { text-align: left; }
.att button { width: 30px; height: 30px; border: 1px solid var(--input-border); background: #fff; border-radius: var(--radius); cursor: pointer; font: inherit; font-weight: 600; }
.att button.a { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.att button.f { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.att button.e { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }

.progress { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; min-width: 80px; }
.progress i { display: block; height: 100%; background: var(--area); }

.toast { position: fixed; bottom: 20px; right: 20px; background: var(--heading); color: #fff; padding: 10px 16px; border-radius: var(--radius); opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 99; }
.toast.show { opacity: 1; transform: none; }

/* Anmeldung */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--area); border-radius: var(--radius); padding: 32px 28px; display: grid; gap: 16px; }
.login-card form { display: grid; gap: 14px; }
.login-card .btn { justify-content: center; width: 100%; }
.login-logo { width: 170px; height: auto; margin: 0 auto; display: block; }
.login-area { text-align: center; margin: -6px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600; color: var(--area); }
.login-sep { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 13px; margin: 4px 0 14px; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login-error { margin: 0; min-height: 1.4em; color: var(--primary); font-size: 14px; text-align: center; }
.login-foot { color: var(--text-muted); font-size: 13px; margin-top: 16px; }
.btn:disabled { opacity: .6; cursor: wait; }
.user { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.user b { font-weight: 500; color: var(--heading); display: block; }
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: var(--radius); max-width: 420px; margin-bottom: 16px; }
.tabs button { flex: 1; font: inherit; font-size: 13px; font-weight: 500; border: 0; background: transparent; color: var(--text); padding: 6px 4px; border-radius: var(--radius); cursor: pointer; }
.tabs button.active { background: var(--surface); color: var(--primary); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Kopf der Seitenleiste – Menüknopf nur mobil */
.side-head { display: contents; }
.side-menu { display: contents; }
.side-current, .menu-toggle { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { position: sticky; top: 0; z-index: 20; height: auto; padding: 10px 16px; gap: 0; border-right: 0; border-bottom: 1px solid var(--border); overflow: visible; }
  .side-head { display: flex; align-items: center; gap: 12px; }
  .brand { padding: 0; display: flex; align-items: center; gap: 10px; }
  .brand img { width: 96px; }
  .brand span { margin: 0; font-size: 11px; }
  .side-current { display: block; flex: 1; text-align: right; font-weight: 500; color: var(--heading); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .menu-toggle { display: grid; gap: 4px; place-content: center; width: 44px; height: 44px; margin-right: -8px; background: none; border: 0; cursor: pointer; }
  .menu-toggle i { display: block; width: 22px; height: 2px; background: var(--heading); transition: .2s; }
  .side.open .menu-toggle i:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .side.open .menu-toggle i:nth-child(2) { opacity: 0; }
  .side.open .menu-toggle i:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
  .side-menu { display: none; }
  .side.open .side-menu { display: grid; gap: 14px; padding: 14px 0 6px; max-height: calc(100vh - 70px); overflow: auto; }
  .areas a { padding: 10px 4px; font-size: 14px; }
  .nav a { padding: 12px; font-size: 16px; }
  .side .foot { margin-top: 0; padding: 12px 4px 0; }

  .main { padding: 18px 14px 48px; }
  h1 { font-size: 24px; }
  .top { margin-bottom: 14px; align-items: stretch; }
  .top > div:first-child { width: 100%; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; justify-content: center; }
  .actions .search, .actions select { max-width: none; flex: 1 1 100%; width: 100% !important; }
  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 14px; }
  .kpi { font-size: 26px; }
  .kpi-label { font-size: 13px; }
  .two, .form { grid-template-columns: 1fr; }
  .stack { gap: 14px; }
  .panel-head { padding: 12px 14px; }

  /* iOS zoomt bei Schrift < 16px in Eingabefeldern */
  input, select, textarea { font-size: 16px; padding: 11px 12px; }
  .btn { padding: 11px 18px; }

  /* Tabellen werden zu Karten */
  .table-wrap table:not(.att), .table-wrap table:not(.att) tbody, .table-wrap table:not(.att) tr, .table-wrap table:not(.att) td { display: block; width: 100%; }
  .table-wrap table:not(.att) thead { display: none; }
  .table-wrap table:not(.att) tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .table-wrap table:not(.att) tr:last-child { border-bottom: 0; }
  .table-wrap table:not(.att) td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .table-wrap table:not(.att) td::before { content: attr(data-label); color: var(--text-muted); font-size: 13px; text-align: left; flex-shrink: 0; }
  .table-wrap table:not(.att) td:first-child { display: block; text-align: left; font-size: 16px; padding-bottom: 6px; }
  .table-wrap table:not(.att) td:first-child::before { display: none; }
  .table-wrap table:not(.att) td .progress { min-width: 100px; }

  /* Anwesenheit/Fortschritt: erste Spalte bleibt stehen, große Tipp-Flächen */
  .att th:first-child, .att td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 120px; }
  .att button { width: 40px; height: 40px; }

  /* Kanban: eine Spalte pro Bildschirmbreite, wischen */
  .board { grid-auto-columns: 82%; scroll-snap-type: x mandatory; margin: 0 -14px; padding: 0 14px 8px; }
  .col { scroll-snap-align: start; }
  .tabs { max-width: none; }

  /* Dialoge im Vollbild */
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  dialog form { display: flex; flex-direction: column; height: 100%; }
  dialog .body { flex: 1; max-height: none; padding: 16px; }
  dialog header { padding: 10px 16px; }
  dialog footer { padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }

  .login-card { padding: 26px 20px; }
  .toast { left: 16px; right: 16px; text-align: center; }
}
