/* ============================================================
   SCHULPORTAL — portal.css
   EINE zentrale Quelle für Design-Tokens und Komponenten.
   Gilt für alle Module. CI-konform (OSZ I Barnim):
   Orange = Akzent/Linie/aktiv · Rot = Aktion/Tabellenkopf
   Beige = Fläche · Anthrazit = Text/Sidebar · System-Font.
   Stand: P0-Fundament (Redesign-Plan §2/§3).
   ============================================================ */

/* ---------- Tokens ---------- */
:root{
  /* Marke (CI) */
  --ink:#2B2B29;
  --orange:#F29200;
  --red:#A51009;        --red-h:#7d0d08;
  --beige:#FACB97;      --beige-light:#fdf7f0;
  --grey:#B3B3B3;

  /* Flächen / Text */
  --bg:#f6f3ee;
  --surface:#ffffff;
  --text:#26201c;
  --muted:#7a6f66;
  --border:#e7ded3;
  --border-strong:#d8ccbe;

  /* Semantik */
  --ok:#3d8c40;   --ok-bg:#eaf3ea;
  --warn:#c87000; --warn-bg:#fdf5e0;
  --err:#c0392b;  --err-bg:#fdecea;
  --info:#2f6fa8; --info-bg:#e9f1f8;

  /* Form / Tiefe */
  --radius:14px; --radius-sm:8px; --radius-pill:999px;
  --shadow-sm:0 2px 6px rgba(80,60,40,.07);
  --shadow-md:0 8px 22px rgba(80,60,40,.14);
  --shadow-lg:0 16px 38px rgba(80,60,40,.20);

  /* Typo */
  --font:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  --mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;

  /* Layout */
  --sidebar-w:248px; --topbar-h:56px; --content-max:1100px;
}

/* ---------- Reset / Base ---------- */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%}
body{font-family:var(--font);background:var(--bg);color:var(--text);line-height:1.5;-webkit-font-smoothing:antialiased}
a{color:var(--red);text-decoration:none}
a:hover{text-decoration:underline}
img,svg{display:block;max-width:100%}
:focus-visible{outline:2px solid var(--orange);outline-offset:2px}

/* ============================================================
   APP-SHELL  (von portal-shell.js erzeugt)
   ============================================================ */
.app{display:flex;min-height:100vh;background:var(--bg)}

/* Sidebar (Staff) */
.sidebar{width:var(--sidebar-w);background:var(--ink);color:#cfc7bd;flex-shrink:0;
  display:flex;flex-direction:column;padding:1rem .8rem;position:sticky;top:0;height:100vh}
.sb-brand{display:flex;align-items:center;gap:.7rem;padding:.3rem .5rem 1rem;border-bottom:1px solid #43403c;margin-bottom:.9rem}
.sb-logo{width:40px;height:40px;flex-shrink:0}
.sb-name{font-size:.95rem;font-weight:750;color:#fff;line-height:1.1}
.sb-sub{font-size:.68rem;color:#a89b8d}
.nav{display:flex;flex-direction:column;gap:.12rem;flex:1;overflow:auto}
.nv{display:flex;align-items:center;gap:.7rem;padding:.58rem .7rem;border-radius:9px;font-size:.88rem;
  color:#c4b9ad;text-decoration:none;cursor:pointer;border-left:3px solid transparent}
.nv:hover{background:#3a3733;color:#fff;text-decoration:none}
.nv.on{background:rgba(242,146,0,.14);color:#fff;font-weight:650;border-left-color:var(--orange)}
.nv .e{width:20px;height:20px;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.nv .e svg{width:17px;height:17px}
.sb-user{display:flex;align-items:center;gap:.6rem;padding:.7rem .5rem 0;border-top:1px solid #43403c;margin-top:.6rem;font-size:.84rem}
.sb-user .nm{color:#fff;font-weight:650}
.sb-user .lo{color:#a89b8d;font-size:.72rem;cursor:pointer;background:none;border:none;font-family:inherit;padding:0;text-align:left}
.sb-user .lo:hover{color:#fff}
.av{width:32px;height:32px;border-radius:50%;background:#4a3f37;color:#f3c9a0;font-size:.72rem;font-weight:700;
  display:flex;align-items:center;justify-content:center;flex-shrink:0}

/* Main-Spalte */
.main-col{flex:1;min-width:0;display:flex;flex-direction:column}
.topbar{height:var(--topbar-h);background:var(--surface);border-bottom:3px solid var(--orange);
  display:flex;align-items:center;justify-content:space-between;padding:0 1.25rem;gap:1rem;flex-shrink:0;
  position:sticky;top:0;z-index:20}
.crumb{font-size:.85rem;color:var(--muted)}
.crumb b{color:var(--text)}
.tb-right{display:flex;align-items:center;gap:1rem;font-size:.82rem;color:var(--muted)}
.hamburger{display:none;background:none;border:1px solid var(--border-strong);border-radius:8px;
  font-size:1.1rem;line-height:1;padding:.35rem .55rem;cursor:pointer;color:var(--text)}

/* Public-Header (Schülerseiten, keine Sidebar) */
.public-head{background:var(--ink);color:#f3ede4;padding:.7rem 1rem;display:flex;align-items:center;gap:.6rem;
  border-bottom:3px solid var(--orange)}
.public-head .ph-logo{width:30px;height:30px;flex-shrink:0}
.public-head .t{font-size:1rem;font-weight:750;line-height:1.05}
.public-head .s{font-size:.66rem;color:#b8ada0}

/* Drawer-Overlay (mobil) */
.scrim{position:fixed;inset:0;background:rgba(28,26,24,.45);z-index:40;opacity:0;visibility:hidden;transition:opacity .2s}
.app.drawer-open .scrim{opacity:1;visibility:visible}

/* Inhalt */
main, .content{max-width:var(--content-max);width:100%;margin:0 auto;padding:1.7rem 1.5rem 3rem}

/* ============================================================
   KOMPONENTEN
   ============================================================ */

/* Buttons */
.btn{font-family:inherit;font-size:.875rem;font-weight:600;border-radius:var(--radius-sm);padding:.5rem .95rem;
  border:1px solid transparent;cursor:pointer;display:inline-flex;align-items:center;gap:.4rem;white-space:nowrap;
  line-height:1.2;transition:background .15s,border-color .15s,color .15s}
.btn-primary{background:var(--red);color:#fff}
.btn-primary:hover{background:var(--red-h)}
.btn-secondary{background:var(--surface);color:var(--text);border-color:var(--border-strong)}
.btn-secondary:hover{border-color:var(--red);color:var(--red)}
.btn-ghost{background:transparent;color:var(--muted)}
.btn-ghost:hover{background:#efe7dd;color:var(--text)}
.btn-danger{background:var(--err);color:#fff}
.btn-danger:hover{background:#9a2f23}
.btn-sm{padding:.34rem .62rem;font-size:.8rem}
.btn-lg{padding:.75rem 1.2rem;font-size:1rem}
.btn[disabled]{opacity:.55;cursor:not-allowed}

/* Karten */
.card{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-sm)}
.card-pad{padding:1.4rem}

/* Abschnitts-Label */
.section-label{font-size:.74rem;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);
  margin:0 0 .8rem;display:flex;align-items:center;gap:.5rem}
.section-label::after{content:"";flex:1;height:1px;background:var(--border)}

/* Seitentitel + Toolbar */
.page-head{display:flex;align-items:flex-end;justify-content:space-between;gap:1rem;flex-wrap:wrap;margin-bottom:1.2rem}
.page-title{font-size:1.35rem;font-weight:750;letter-spacing:-.01em}
.page-desc{color:var(--muted);font-size:.85rem;margin-top:.15rem}
.toolbar{display:flex;gap:.5rem;align-items:center;flex-wrap:wrap}

/* Tabs */
.tabs{display:flex;gap:.15rem;border-bottom:1px solid var(--border);margin-bottom:1.2rem;overflow-x:auto}
.tab{font-size:.875rem;font-weight:600;color:var(--muted);background:none;border:none;cursor:pointer;
  padding:.6rem .9rem;border-bottom:2px solid transparent;margin-bottom:-1px;font-family:inherit;white-space:nowrap}
.tab:hover{color:var(--text)}
.tab.on{color:var(--red);border-bottom-color:var(--orange)}

/* Statistik-Kacheln */
.stats{display:flex;gap:1rem;flex-wrap:wrap;margin-bottom:1.3rem}
.stat{flex:1;min-width:150px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  padding:1rem 1.2rem;box-shadow:var(--shadow-sm)}
.stat .k{font-size:.72rem;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--muted)}
.stat .v{font-size:1.8rem;font-weight:800;letter-spacing:-.02em;margin-top:.1rem}

/* Tabellen — mobiler Standard: horizontaler Scroll */
.tbl-scroll{overflow-x:auto;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-sm)}
table.tbl{width:100%;border-collapse:collapse;font-size:.875rem;min-width:640px}
table.tbl thead th{background:var(--red);color:#fff;text-align:left;font-size:.72rem;font-weight:700;
  letter-spacing:.04em;text-transform:uppercase;padding:.65rem .9rem;white-space:nowrap;position:sticky;top:0}
table.tbl th.num,table.tbl td.num{text-align:right;font-variant-numeric:tabular-nums}
table.tbl td{padding:.65rem .9rem;border-bottom:1px solid var(--border)}
table.tbl tbody tr:last-child td{border-bottom:none}
table.tbl tbody tr:hover{background:var(--beige-light)}
.bar{height:7px;border-radius:4px;background:var(--border);overflow:hidden;width:96px;display:inline-block;vertical-align:middle}
.bar>i{display:block;height:100%;border-radius:4px}

/* Badges / Tags / Pills */
.badge{font-size:.68rem;font-weight:700;padding:.2em .65em;border-radius:var(--radius-pill);display:inline-block}
.badge.ok{color:var(--ok);background:var(--ok-bg)}
.badge.warn{color:var(--warn);background:var(--warn-bg)}
.badge.err{color:var(--err);background:var(--err-bg)}
.badge.info{color:var(--info);background:var(--info-bg)}
.tag{font-size:.68rem;color:var(--muted);background:var(--bg);border:1px solid var(--border);padding:.16em .55em;border-radius:var(--radius-pill)}
.pill{display:inline-block;border-radius:var(--radius-pill);padding:.25rem .7rem;font-size:.8rem;font-weight:700}
.pill.lk{background:var(--beige);color:#5a3d18}

/* Formularfelder */
.field{margin-bottom:1rem}
.field label{display:block;font-size:.9rem;font-weight:650;margin-bottom:.35rem}
.field .hint{font-size:.78rem;color:var(--muted);margin-top:.3rem}
.input,select.input,textarea.input{width:100%;font-family:inherit;font-size:16px;padding:.6rem .75rem;
  border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:#fff;color:var(--text)}
.input:focus,select.input:focus,textarea.input:focus{outline:2px solid var(--orange);outline-offset:0;border-color:var(--orange)}
.input.code{letter-spacing:.25em;text-transform:uppercase;font-weight:700;text-align:center;font-size:1.4rem}

/* Hinweisboxen */
.note{border-radius:var(--radius-sm);padding:.8rem 1rem;font-size:.88rem;display:flex;gap:.6rem;align-items:flex-start}
.note.ok{background:var(--ok-bg);color:#235427;border:1px solid #c2e0c4}
.note.warn{background:var(--warn-bg);color:#7a4a00;border:1px solid #ecd9a8}
.note.err{background:var(--err-bg);color:#7a2018;border:1px solid #ecc7c2}
.note.info{background:var(--info-bg);color:#1d4d77;border:1px solid #c5dcee}

/* Read-only-Banner */
.readonly-banner{background:var(--warn-bg);color:#7a4a00;border-bottom:1px solid #ecd9a8;
  text-align:center;font-size:.85rem;padding:.55rem 1rem}

/* Toast */
#toast-container{position:fixed;bottom:1.5rem;right:1.5rem;display:flex;flex-direction:column;gap:.5rem;z-index:9999}
.toast{padding:.7rem 1.1rem;border-radius:8px;color:#fff;font-size:.86rem;box-shadow:var(--shadow-md);
  pointer-events:none;animation:toastIn .2s ease}
.toast-success{background:var(--ok)}
.toast-error{background:var(--err)}
.toast-warning{background:var(--warn)}
@keyframes toastIn{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}

/* Dashboard: Begrüßung */
.greet{font-size:1.5rem;font-weight:800;letter-spacing:-.01em;margin-bottom:.3rem}
.greet small{display:block;font-size:.9rem;font-weight:500;color:var(--muted);margin-top:.2rem}

/* Anwesenheit */
.presence-grid{display:flex;flex-wrap:wrap;gap:1rem}
.presence{background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);
  padding:1rem 1.2rem;box-shadow:var(--shadow-sm);min-width:230px;flex:1}
.presence.is-own{border-color:var(--orange)}
.presence .nm{font-size:.72rem;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--muted)}
.presence .now{display:flex;align-items:center;gap:.5rem;margin-top:.25rem;font-weight:750;font-size:1.05rem}
.presence .dot{width:11px;height:11px;border-radius:50%;background:var(--ok);flex-shrink:0}
.presence .dot.off{background:var(--grey)}
.presence .meta{font-size:.74rem;color:var(--muted);margin-top:.15rem}
.presence .chips{display:flex;gap:.4rem;flex-wrap:wrap;margin-top:.8rem}
.presence .custom{display:flex;gap:.4rem;margin-top:.5rem}
.presence .custom input{flex:1;min-width:0;font-family:inherit;font-size:16px;padding:.4rem .6rem;
  border:1px solid var(--border-strong);border-radius:var(--radius-sm);background:#fff;color:var(--text)}
.presence .custom input:focus{outline:2px solid var(--orange);outline-offset:0;border-color:var(--orange)}

/* Chips (Auswahl-Tasten) */
.chip{font-size:.82rem;font-weight:600;border-radius:var(--radius-pill);padding:.4rem .8rem;cursor:pointer;
  border:1px solid var(--border);background:var(--bg);color:var(--text);font-family:inherit}
.chip:hover{border-color:var(--orange)}
.chip.on{background:var(--beige);border-color:var(--beige);color:#5a3d18}

/* "Zuletzt verwendet" */
.recent{display:flex;gap:.55rem;flex-wrap:wrap}
.rl{display:flex;align-items:center;gap:.5rem;background:var(--surface);border:1px solid var(--border);
  border-radius:var(--radius-pill);padding:.45rem .9rem;font-size:.88rem;font-weight:600;text-decoration:none;color:var(--text)}
.rl:hover{border-color:var(--orange);color:var(--red);text-decoration:none}
.rl .e{display:flex;align-items:center}
.rl .e svg{width:15px;height:15px}

/* Stepper */
.stepper{display:flex;align-items:center;gap:.3rem;margin-bottom:1.2rem;flex-wrap:wrap}
.step{display:flex;align-items:center;gap:.4rem;font-size:.75rem;color:var(--muted)}
.step .n{width:22px;height:22px;border-radius:50%;background:var(--border);color:var(--muted);
  display:flex;align-items:center;justify-content:center;font-weight:700;font-size:.7rem;flex-shrink:0}
.step.done .n{background:var(--ok);color:#fff}
.step.active .n{background:var(--orange);color:var(--ink)}
.step.active{color:var(--text);font-weight:700}
.step-line{flex:1;height:1px;background:var(--border);min-width:10px}

/* Helfer */
.hidden{display:none !important}
.muted{color:var(--muted)}
.mono{font-family:var(--mono)}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width:1023px){
  .hamburger{display:inline-flex}
  .sidebar{position:fixed;left:0;top:0;height:100vh;z-index:50;transform:translateX(-100%);
    transition:transform .22s ease;box-shadow:var(--shadow-lg)}
  .app.drawer-open .sidebar{transform:translateX(0)}
}
@media (min-width:1024px){
  .scrim{display:none}
}
@media (max-width:640px){
  main,.content{padding:1.1rem 1rem 2.5rem}
  .page-head{align-items:flex-start}
  .btn{padding:.6rem 1rem}
}

/* Touch-Zielgrößen: an Eingabemethode statt Viewport-Breite koppeln
   (ein Tablet-Zeiger ist genauso grob wie ein Telefon, egal wie breit
   das Fenster ist) — Ziel 44×44px für Hamburger, Chips, kleine Buttons. */
@media (pointer:coarse){
  .hamburger{padding:.85rem 1rem}
  .chip{padding:.8rem 1.1rem}
  .btn-sm{padding:.8rem 1rem}
}

/* ============================================================
   DRUCK — Shell/Chrome ausblenden (Türaushänge, Gutachten, Pläne)
   ============================================================ */
@media print{
  .sidebar,.topbar,.public-head,.scrim,#toast-container,.hamburger,.readonly-banner{display:none !important}
  .app,.main-col{display:block}
  main,.content{max-width:none;margin:0;padding:0}
  body{background:#fff}
}
