/* ==========================================================================
   Azubiplan – Design-System („Datenweiser"-Stil)
   ========================================================================== */
@font-face {
  font-family: 'Manrope';
  src: url('../fonts/manrope-var.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --ink: #16232e;
  --ink-soft: #51616e;
  --paper: #f4f6f5;
  --surface: #ffffff;
  --line: #e2e7e6;

  --brand: #1e56a0;
  --brand-deep: #163f77;
  --brand-soft: #e3ebf7;
  --brand-ghost: #f1f5fb;
  --brand-dark: #0f2c54;

  --amber: #a86a12;  --amber-bg: #fbf2e0;
  --green: #2c7a52;  --green-bg: #e5f2ea;
  --red:   #b0392f;  --red-bg:   #f9e9e7;
  --gray:  #51616e;  --gray-bg:  #eceff0;

  --radius: 10px;  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(22,35,46,.05), 0 4px 14px rgba(22,35,46,.06);
  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', 'Consolas', monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0;
  font-family: 'Manrope', system-ui, sans-serif;
  font-weight: 450;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.45rem; font-weight: 750; letter-spacing: -.015em; }
h2 { font-size: 1.05rem; font-weight: 700; }
h3 { font-size: .95rem; font-weight: 700; }
p { margin: 0 0 .8rem; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 1rem; }
.mb0 { margin-bottom: 0; }
.flex { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* --- App-Rahmen ---------------------------------------------------------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--brand-deep), var(--brand-dark));
  color: #fff;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 1.2rem 1rem;
}
.brand { display: flex; flex-direction: column; padding: .2rem .6rem 1.2rem; }
.brand strong { font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; color: #fff; }
.brand span { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.6); font-weight: 700; }
.nav { flex: 1; display: flex; flex-direction: column; gap: .15rem; }
.nav-label { font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.5); font-weight: 700; padding: .9rem .6rem .3rem; }
.nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .65rem; border-radius: var(--radius-sm);
  color: #e6efee; font-size: .9rem; font-weight: 550;
}
.nav a svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.active { background: rgba(255,255,255,.13); color: #fff; font-weight: 700; }
.nav a .cnt { margin-left: auto; font-size: .7rem; background: rgba(255,255,255,.18); padding: .05rem .45rem; border-radius: 99px; font-weight: 700; }
.sidebar-user { border-top: 1px solid rgba(255,255,255,.12); padding-top: .9rem; margin-top: .6rem; }
.sidebar-user .name { font-weight: 700; font-size: .9rem; }
.sidebar-user .roles { font-size: .72rem; color: rgba(255,255,255,.6); margin-bottom: .6rem; }
.btn-ghost-light {
  display: inline-flex; width: 100%; justify-content: center; align-items: center;
  min-height: 36px; padding: .3rem .8rem; border-radius: var(--radius-sm);
  border: 1.5px solid rgba(255,255,255,.35); background: transparent; color: #fff;
  font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer;
}
.btn-ghost-light:hover { background: rgba(255,255,255,.1); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem; padding: .65rem 2rem;
}
.search { position: relative; flex: 1; max-width: 460px; }
.search svg { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; stroke: var(--ink-soft); fill: none; stroke-width: 2; }
.search input {
  width: 100%; border: 1.5px solid transparent; border-radius: 99px;
  padding: .5rem .9rem .5rem 2.3rem; background: var(--paper);
  font: inherit; font-size: .9rem; min-height: 40px;
}
.search input:focus { outline: none; background: #fff; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent); }
.topbar-right { margin-left: auto; display: flex; gap: .6rem; align-items: center; font-size: .85rem; color: var(--ink-soft); }

.content { padding: 1.6rem 2rem 2.4rem; width: 100%; max-width: none; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .8rem; margin-bottom: 1.2rem; }
.page-head h1 { font-size: 1.35rem; margin: 0; }
.page-head .sub { color: var(--ink-soft); font-size: .9rem; margin: .15rem 0 0; }
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.head-actions .btn, .head-actions .btn-outline { min-height: 42px; }

/* --- Karten ---------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem 1.4rem; margin-bottom: 1.2rem;
}
.card > h2 { font-size: 1.02rem; }
.card-hint { font-size: .82rem; color: var(--ink-soft); margin: -.2rem 0 .9rem; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.2rem; align-items: start; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.2rem; }
.stat .num { font-size: 1.7rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; letter-spacing: -.02em; }
.stat .lbl { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); font-weight: 700; margin-top: .3rem; }
.stat.green .num { color: var(--green); }
.stat.amber .num { color: var(--amber); }
.stat.red .num { color: var(--red); }

/* --- Tabellen -------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); font-weight: 700; padding: .5rem .6rem; border-bottom: 1.5px solid var(--line); }
td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--brand-ghost); }
td .btn-sm { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

/* --- Badges ---------------------------------------------------------------- */
.az {
  font-family: var(--mono); font-size: .82rem; font-weight: 600;
  background: var(--brand-soft); color: var(--brand-deep);
  padding: .12rem .45rem; border-radius: 5px; white-space: nowrap;
}
.badge {
  display: inline-block; font-size: .72rem; font-weight: 700; padding: .15rem .6rem;
  border-radius: 99px; vertical-align: middle; white-space: nowrap; line-height: 1.5;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-gray { background: var(--gray-bg); color: var(--gray); }
.badge-brand { background: var(--brand-soft); color: var(--brand-deep); }

/* --- Buttons --------------------------------------------------------------- */
.btn, .btn-outline {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 40px; padding: .4rem 1rem; border-radius: var(--radius-sm);
  font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; white-space: nowrap;
  text-decoration: none; transition: background .15s;
}
.btn { background: var(--brand); color: #fff; border: 1.5px solid var(--brand); }
.btn:hover { background: var(--brand-deep); border-color: var(--brand-deep); text-decoration: none; }
.btn-outline { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn-outline:hover { background: var(--brand-ghost); text-decoration: none; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red-bg); }
.btn-green { background: var(--green); border-color: var(--green); }
.btn-green:hover { background: #226340; border-color: #226340; }
.btn-sm { min-height: 33px; padding: .2rem .7rem; font-size: .82rem; }
.btn svg, .btn-outline svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn:disabled, .btn-outline:disabled { opacity: .5; cursor: not-allowed; }
form.inline { display: inline; }

/* --- Formulare ------------------------------------------------------------- */
.field { margin-bottom: 1rem; }
.field label, label.lbl { display: block; font-size: .82rem; font-weight: 700; margin-bottom: .3rem; }
.help { font-size: .78rem; color: var(--ink-soft); margin-top: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time],
input:not([type]), select, textarea {
  width: 100%; font: inherit; font-size: .92rem; color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: .5rem .75rem; min-height: 42px; background: #fff;
  appearance: none; -webkit-appearance: none;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2351616e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2.2rem; }
input[type=date]::-webkit-calendar-picker-indicator { opacity: .45; cursor: pointer; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 10%, transparent);
}
input[type=checkbox], input[type=radio] { width: 17px; height: 17px; accent-color: var(--brand); vertical-align: -3px; margin-right: .35rem; }
.check { display: flex; align-items: center; gap: .2rem; font-size: .9rem; font-weight: 500; margin-bottom: .4rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: .5rem; }
.input-sm { min-height: 34px !important; padding: .25rem .5rem !important; font-size: .86rem !important; }
.code-input { font-family: var(--mono); font-size: 1.35rem; letter-spacing: .45em; text-align: center; }

/* --- Flash ----------------------------------------------------------------- */
.flash { padding: .7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .9rem; font-weight: 550; }
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error { background: var(--red-bg); color: var(--red); }
.flash-info { background: var(--brand-soft); color: var(--brand-deep); }
.flash-warn { background: var(--amber-bg); color: var(--amber); }

/* --- Leerzustand, Tabs, Meter, Dialog ------------------------------------- */
.empty { text-align: center; color: var(--ink-soft); padding: 2.5rem 1rem; }
.empty p { margin-bottom: 1rem; }

.tabs { display: flex; gap: 1.4rem; border-bottom: 1.5px solid var(--line); margin-bottom: 1.2rem; overflow-x: auto; }
.tabs a { padding: .6rem 0; font-size: .9rem; font-weight: 600; color: var(--ink-soft); border-bottom: 2.5px solid transparent; margin-bottom: -1.5px; white-space: nowrap; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { color: var(--brand); font-weight: 800; border-bottom-color: var(--brand); }

.meter { height: 12px; border-radius: 99px; background: var(--paper); overflow: hidden; border: 1px solid var(--line); }
.meter > span { display: block; height: 100%; border-radius: 99px; }
.meter-green > span { background: var(--green); }
.meter-amber > span { background: var(--amber); }
.meter-red > span { background: var(--red); }
.meter-brand > span { background: var(--brand); }
.meter-row { display: flex; align-items: center; gap: .8rem; }
.meter-row .meter { flex: 1; }
.meter-row .val { font-variant-numeric: tabular-nums; font-size: .85rem; font-weight: 700; min-width: 3.5em; text-align: right; }

.dw-dialog { border: 0; border-radius: var(--radius); padding: 1.4rem 1.5rem; max-width: 460px; width: calc(100% - 2rem); box-shadow: 0 10px 40px rgba(22,35,46,.25); }
.dw-dialog::backdrop { background: rgba(22,35,46,.45); }
.dw-dialog.wide { max-width: 720px; }
.dw-dialog h2 { margin-bottom: .8rem; }

/* --- Auth / öffentliche Seiten -------------------------------------------- */
.auth-body { background: var(--paper) radial-gradient(circle at 100% 0%, var(--brand-soft), transparent 45%) no-repeat; min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 1.8rem 1.8rem 1.5rem; width: 100%; max-width: 400px; }
.auth-card h2 { margin-top: 1.2rem; }
.auth-brand { text-align: center; margin-bottom: 1.4rem; display: flex; flex-direction: column; }
.auth-brand strong { font-size: 1.4rem; font-weight: 800; color: var(--brand-deep); letter-spacing: -.015em; }
.auth-brand span { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); font-weight: 700; }
.auth-links { text-align: center; font-size: .85rem; margin-top: 1rem; }

/* --- Wochenraster (Planung & Nachweis) ----------------------------------- */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: .6rem; }
.day { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .7rem; background: #fff; min-height: 120px; display: flex; flex-direction: column; gap: .4rem; }
.day.off { background: var(--paper); }
.day.today { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 15%, transparent); }
.day-head { display: flex; justify-content: space-between; align-items: baseline; font-size: .8rem; }
.day-head strong { font-weight: 800; }
.day-head .d { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.day .hours { font-family: var(--mono); font-size: .85rem; font-weight: 700; color: var(--brand-deep); }
.entry { font-size: .82rem; border-left: 3px solid var(--brand-soft); padding: .2rem .5rem; background: var(--brand-ghost); border-radius: 0 5px 5px 0; }
.entry.schule { border-left-color: #c9a85a; background: var(--amber-bg); }
.entry.unterweisung { border-left-color: var(--green); background: var(--green-bg); }
.entry .meta { font-size: .72rem; color: var(--ink-soft); display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.entry form { display: inline; }
.entry .del { background: none; border: 0; color: var(--red); cursor: pointer; font: inherit; font-size: .72rem; padding: 0; }
.week-sum { display: flex; justify-content: flex-end; gap: 1.5rem; margin-top: .8rem; font-size: .9rem; }
.week-sum strong { font-family: var(--mono); font-size: 1rem; }
.week-nav { display: flex; align-items: center; gap: .5rem; }
.week-nav .cur { font-weight: 800; min-width: 190px; text-align: center; }
.pos-list { max-height: 360px; overflow-y: auto; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: .4rem .6rem; }
.pos-list label { display: flex; gap: .5rem; align-items: flex-start; padding: .3rem 0; font-size: .84rem; font-weight: 450; border-bottom: 1px solid var(--line); }
.pos-list label:last-child { border-bottom: 0; }
.pos-list input { margin-top: .2rem; }
.chip-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.6rem; text-align: center; cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-ghost); }
.dropzone input { display: none; }
.kbd { font-family: var(--mono); font-size: .78rem; background: var(--paper); border: 1px solid var(--line); padding: .05rem .35rem; border-radius: 4px; }

/* --- Druck ----------------------------------------------------------------- */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { box-shadow: none; break-inside: avoid; }
}

/* --- Responsiv ------------------------------------------------------------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .4rem; padding: .7rem 1rem; }
  .brand { padding: 0 .8rem 0 0; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: .2rem; }
  .nav-label { display: none; }
  .nav a { padding: .35rem .55rem; font-size: .82rem; }
  .sidebar-user { border: 0; padding: 0; margin: 0 0 0 auto; display: flex; gap: .6rem; align-items: center; }
  .sidebar-user .roles { display: none; }
  .btn-ghost-light { width: auto; }
  .topbar, .content { padding-left: 1rem; padding-right: 1rem; }
  .form-row, .form-row-3, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .week { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) { .week { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* --- Rahmenplan-Tabelle (dreistufig) -------------------------------------- */
.rp-table td { border-bottom: 0; padding: .35rem .6rem; }
.rp-table tbody { border-top: 1px solid var(--line); }
.rp-table tbody:first-child { border-top: 0; }
.rp-table tbody tr:hover { background: transparent; }
.rp-head td { padding-top: .7rem; background: var(--brand-ghost); }
.rp-nr { width: 4.5rem; white-space: nowrap; vertical-align: top; }
.rp-fert td { font-size: .86rem; }
.rp-fert:last-child td { padding-bottom: .6rem; }
.rp-actions { width: 1%; }

.sidebar-version { font-size: .68rem; color: rgba(255,255,255,.45); margin-top: .6rem; }

/* --- Rahmenplan (Leseansicht mit Einzug, Filter, Klappen) --------------- */
.rp-filter { padding: .8rem 1.2rem; }
.rp-filter select, .rp-filter input { min-height: 38px !important; padding: .3rem .7rem !important; }
.rp-filter [data-filter-abschnitt] { min-width: 200px; }
.rp-filter [data-filter-bbp] { min-width: 340px; max-width: 420px; }
.rp-filter [data-filter-text] { min-width: 300px; }
@media (max-width: 900px) { .rp-filter select, .rp-filter input { min-width: 0 !important; width: 100% !important; max-width: none !important; } }
.rp-jump a { margin-right: .2rem; }
.rp-toggle { cursor: pointer; user-select: none; }
.rp-caret { display: inline-block; font-size: .8em; transition: transform .15s; color: var(--ink-soft); }
.rp-abschnitt.collapsed .rp-body { display: none; }
.rp-abschnitt.collapsed .rp-caret { transform: rotate(-90deg); }
.rp-bbp { padding: .6rem 0 .4rem; border-top: 1px solid var(--line); }
.rp-bbp:first-child { border-top: 0; }
.rp-bbp-head { display: grid; grid-template-columns: 3.6rem 1fr auto; gap: .4rem .6rem; align-items: start; }
.rp-num { justify-self: start; }
.rp-bbp-title { padding-top: .1rem; }
.rp-list { list-style: none; margin: .3rem 0 0; padding: 0 0 0 4.2rem; }
.rp-item { display: grid; grid-template-columns: 2rem 1fr auto; gap: .2rem .4rem; align-items: start; padding: .22rem 0; font-size: .9rem; }
.rp-letter { font-family: var(--mono); color: var(--ink-soft); font-size: .85rem; padding-top: .1rem; }
.rp-item-actions { display: flex; gap: .3rem; }
.rp-item.hit .rp-text { background: var(--amber-bg); border-radius: 4px; padding: 0 .2rem; }
.rp-item.hide, .rp-bbp.hide, .rp-abschnitt.hide { display: none; }
@media (max-width: 700px) { .rp-list { padding-left: 1rem; } .rp-bbp-head { grid-template-columns: 3.2rem 1fr; } .rp-bbp-actions { grid-column: 1 / -1; } }
