/* Cortex-CI am Bildschirm (dunkel, Gold-Akzente); Druck neutral hell. */
:root {
  --bg-deep: #002B36;
  --bg: #00343F;
  --bg-mid: #004D5C;
  --bg-light: #0A6070;
  --gold-dark: #8B6914;
  --gold: #C9A84C;
  --gold-light: #E8C97D;
  --text: #F5F0E8;
  --text-gold: #E8C97D;
  --text-2: #A89060;
  --muted: #6B7A7A;
  --ok: #2D9E6B;
  --danger: #B84040;
  --border: rgba(201, 168, 76, 0.18);
  --gradient-gold: linear-gradient(135deg, #8B6914 0%, #C9A84C 35%, #E8C97D 65%, #C9A84C 100%);
  /* Schicht-Zellen: gedämpft, CI-nah */
  --c-D: rgba(201, 168, 76, 0.32);
  --c-N: rgba(74, 122, 138, 0.75);
  --c-df: rgba(255, 255, 255, 0.05);
  --c-U: rgba(107, 122, 122, 0.45);
  --c-K: rgba(184, 64, 64, 0.40);
  --c-FB: rgba(45, 158, 107, 0.30);
  --c-other: rgba(232, 201, 125, 0.18);
  --we: rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(ellipse at top left, #004D5C 0%, #002B36 50%, #001820 100%) fixed;
  background-color: var(--bg-deep);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, sans-serif;
  min-height: 100vh;
}
h1, h2, h3, .app-title, .btn, .tab { font-family: Montserrat, Inter, sans-serif; }
h2 { font-size: 16px; font-weight: 600; color: var(--text-gold); margin: 18px 0 10px; }
h3 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); margin: 0 0 10px; }
.hidden { display: none !important; }

/* Kopfzeile */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: rgba(0, 24, 32, .6);
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 34px; height: 18px; }
.app-title { font-size: 18px; font-weight: 700; letter-spacing: .05em; color: var(--text-gold); }
.station { color: var(--text-2); font-size: 13px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  background: none; border: 1px solid transparent; color: var(--text-2); padding: 6px 12px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.tab:hover { color: var(--gold-light); }
.tab.active { color: var(--gold-light); border-color: var(--border); background: rgba(201, 168, 76, .08); }

main { padding: 16px; max-width: 1800px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }

/* Buttons & Formulare */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: rgba(0, 77, 92, .6); color: var(--text-gold);
  font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--bg-light); }
.btn.gold { background: var(--gradient-gold); color: #000; border: none; }
.btn.gold:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: #e39a9a; }
.btn:disabled { opacity: .5; cursor: wait; }
input, select, textarea {
  background: rgba(0, 24, 32, .7); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; font: inherit;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
textarea { width: 100%; resize: vertical; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.toolbar .group { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.replan { display: inline-flex; gap: 4px; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); }
.badge.draft { color: var(--gold); }
.badge.published { color: #8fd9b6; border-color: rgba(45, 158, 107, .5); background: rgba(45, 158, 107, .12); }

.info { padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: rgba(0, 52, 63, .8); margin-bottom: 12px; }
.info.error { border-color: rgba(184, 64, 64, .6); background: rgba(184, 64, 64, .12); }
.info ul { margin: 6px 0 0; padding-left: 20px; }

.card { background: linear-gradient(135deg, #003B49 0%, #002530 100%); border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-head h2 { margin: 0; }
.panels { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 900px) { .panels { grid-template-columns: 1fr; } }
.hint { color: var(--text-2); font-size: 12px; }
.help { margin: 0; padding-left: 18px; color: var(--text); font-size: 13px; }
.violations { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; font-size: 13px; }
.violations li { padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.violations li.error::before { content: "● "; color: #e06b6b; }
.violations li.warning::before { content: "● "; color: var(--gold); }
.violations li.ok { color: #8fd9b6; }

/* Raster */
.grid-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: rgba(0, 24, 32, .45); }
.grid { border-collapse: separate; border-spacing: 0; font-size: 12px; min-width: 100%; }
.grid th, .grid td { border-right: 1px solid rgba(255, 255, 255, .06); border-bottom: 1px solid rgba(255, 255, 255, .06); text-align: center; padding: 0; }
.grid thead th { position: sticky; top: 0; background: #00303a; z-index: 2; padding: 4px 0; font-weight: 600; color: var(--text-2); min-width: 30px; }
.grid thead th .dom { display: block; color: var(--text-gold); font-size: 13px; }
.grid th.we, .grid td.we { background-color: var(--we); }
.grid thead th.we { background: #002630; }
.grid thead th.hol .dom { text-decoration: underline dotted; }
.grid .name {
  position: sticky; left: 0; z-index: 1; background: #00303a; text-align: left; padding: 4px 10px;
  white-space: nowrap; min-width: 150px; font-weight: 500;
}
.grid thead .name { z-index: 3; }
.grid .role { color: var(--muted); font-size: 11px; margin-left: 4px; }
.grid td.cell { height: 30px; min-width: 30px; cursor: pointer; position: relative; font-weight: 600; }
.grid td.cell:hover { outline: 2px solid var(--gold); outline-offset: -2px; }
.grid td.cell.s-D { background: var(--c-D); color: var(--gold-light); }
.grid td.cell.s-N { background: var(--c-N); color: #fff; }
.grid td.cell.s-other { background: var(--c-other); color: var(--gold-light); }
.grid td.cell.s-df { background: var(--c-df); color: var(--muted); font-weight: 400; }
.grid td.cell.s-U { background: var(--c-U); color: #dfe6e6; }
.grid td.cell.s-K { background: var(--c-K); color: #fbe0e0; }
.grid td.cell.s-FB { background: var(--c-FB); color: #d6f2e5; }
.grid td.cell.err { box-shadow: inset 0 0 0 2px #e06b6b; }
.grid td.cell .pin { position: absolute; top: 0; left: 1px; font-size: 8px; }
.grid td.cell .wish { position: absolute; top: 2px; right: 2px; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }
.grid td.cell .wish.met { background: var(--ok); }
.grid td.cell .wish.bad { background: #e06b6b; }
.grid .stat { padding: 0 8px; white-space: nowrap; color: var(--text); min-width: 46px; }
.grid .stat small { color: var(--muted); }
.grid tfoot td { color: var(--text-2); height: 24px; }
.grid tfoot td.bad { color: #ff9b9b; font-weight: 700; background: rgba(184, 64, 64, .18); }
.grid tfoot .name { color: var(--text-2); font-weight: 400; }
.grid tr.sep td { border-top: 1px solid var(--border); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 2px; font-size: 12px; color: var(--text-2); }
.legend span i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -3px; margin-right: 5px; }

/* Zellen-Menü */
.popover {
  position: absolute; z-index: 50; background: #00343F; border: 1px solid rgba(201, 168, 76, .4);
  border-radius: 12px; padding: 12px; width: 280px; box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}
.popover h4 { margin: 0 0 6px; font: 600 13px Montserrat, sans-serif; color: var(--gold-light); }
.popover .sec { margin-top: 10px; }
.popover .sec-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-2); margin-bottom: 4px; }
.popover .chips { display: flex; flex-wrap: wrap; gap: 4px; }
.popover .chip { padding: 4px 9px; font-size: 12px; }
.popover .chip.on { background: var(--gradient-gold); color: #000; border: none; }
.popover .wishlist { margin: 4px 0 0; padding: 0; list-style: none; font-size: 12px; }
.popover .wishlist li { display: flex; justify-content: space-between; gap: 6px; padding: 2px 0; }
.popover .close { position: absolute; top: 6px; right: 8px; background: none; border: none; color: var(--text-2); cursor: pointer; font-size: 16px; }
.popover label { font-size: 12px; color: var(--text-2); }

/* Formular-Tabellen */
.table-scroll { overflow-x: auto; }
.form-table { border-collapse: collapse; width: 100%; margin-top: 10px; }
.form-table th { text-align: left; font-size: 11px; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; padding: 6px; }
.form-table td { padding: 4px 6px; border-top: 1px solid rgba(255, 255, 255, .05); }
.form-table input[type=number] { width: 80px; }
.form-table input.w-s { width: 70px; }
.rules { max-width: 640px; }
.rules label { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 0; }
.rules input[type=number] { width: 100px; }
.saved { color: #8fd9b6; font-size: 13px; margin-left: 8px; }

dialog { background: #00343F; color: var(--text); border: 1px solid rgba(201, 168, 76, .4); border-radius: 14px; width: min(760px, calc(100vw - 32px)); padding: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.dialog-body h2 { margin: 0; }
.dialog-body label { display: flex; gap: 8px; align-items: center; color: var(--text-2); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.proposals { width: 100%; border-collapse: collapse; font-size: 13px; }
.proposals td, .proposals th { padding: 4px 6px; border-bottom: 1px solid rgba(255, 255, 255, .06); text-align: left; }
.proposals .quote { color: var(--text-2); font-style: italic; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #00343F; border: 1px solid var(--gold); padding: 10px 16px; border-radius: 10px; z-index: 100; max-width: calc(100vw - 32px); }
.print-head { display: none; }

.login { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at top left, #004D5C 0%, #002B36 50%, #001820 100%); }
.login-card { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; margin: 0; }
.login-card h2 { margin: 0 0 4px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-2); }
.login-card .logo { width: 44px; height: 22px; }
.login-card .btn { justify-content: center; padding: 9px 12px; }
.login-error { color: #ff9b9b; font-size: 13px; min-height: 18px; }

@media (max-width: 640px) {
  main { padding: 12px 16px; }
  .app-title { font-size: 16px; }
  .station { display: none; }
  .grid .name { min-width: 110px; padding: 4px 6px; }
}

/* ============ Druck: A4 quer, hell, schwarzweiß-tauglich ============ */
@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff !important; color: #000; font-size: 9px; }
  .topbar, .toolbar, .panels, #solveInfo, .popover, .toast, .view:not(#view-plan) { display: none !important; }
  main { padding: 0; max-width: none; }
  .print-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4mm; }
  .print-head h1 { font-size: 15px; margin: 0; color: #000; }
  .print-head div { font-size: 9px; color: #333; }
  .grid-wrap { overflow: visible; border: none; background: none; border-radius: 0; }
  .grid { width: 100%; font-size: 9px; border-collapse: collapse; }
  .grid th, .grid td { border: 0.5pt solid #777 !important; color: #000 !important; }
  .grid thead th, .grid .name { background: #fff !important; position: static; }
  .grid thead th .dom { color: #000; }
  .grid th.we, .grid td.we, .grid thead th.we { background: #eee !important; }
  .grid td.cell { height: 18px; min-width: 0; box-shadow: none !important; }
  .grid td.cell.s-D { background: #f4e7c0 !important; }
  .grid td.cell.s-N { background: #b9cdd4 !important; }
  .grid td.cell.s-other { background: #efe6cc !important; }
  .grid td.cell.s-df { background: #fff !important; color: #666 !important; }
  .grid td.cell.s-U { background: #d6d6d6 !important; }
  .grid td.cell.s-K { background: #f0c8c8 !important; }
  .grid td.cell.s-FB { background: #d9e8d0 !important; }
  .grid td.cell .wish, .grid td.cell .pin, .grid .stat small { display: none; }
  .grid tfoot td.bad { background: #fff !important; }
  .legend { color: #000; font-size: 9px; }
  .legend span i { border: 0.5pt solid #777; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
