/* AES Intranet – Gestaltung (passend zur Website: Dunkelblau / Weiß) */
:root {
  --navy-950: #071426; --navy-900: #0b1d36; --navy-800: #102a4c; --navy-700: #17396a; --navy-600: #1f4c8c;
  --steel: #8fb3dc; --steel-soft: #e6eef8; --paper: #f4f6f9; --white: #fff;
  --ink: #0e1a2b; --text: #33404f; --muted: #6b7684; --line: #dde3ea;
  --ok: #1d7a4c; --ok-bg: #e3f4ea; --warn: #9a5b00; --warn-bg: #fdf1dc; --bad: #b42318; --bad-bg: #fde8e6;
  --radius: 8px;
  --head: "Barlow Condensed", "Arial Narrow", Arial, sans-serif;
  --body: "Barlow", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 400 15px/1.5 var(--body); color: var(--text); background: var(--paper); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--navy-600); }
h1, h2, h3 { margin: 0; font-family: var(--head); color: var(--ink); text-transform: uppercase; letter-spacing: .01em; line-height: 1.1; }
:focus-visible { outline: 3px solid var(--steel); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Grundlayout */
.app { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--navy-950); color: #b9c7d8; padding: 22px 16px; background-image: linear-gradient(rgba(143,179,220,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(143,179,220,.05) 1px, transparent 1px); background-size: 24px 24px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; border-bottom: 1px solid rgba(255,255,255,.08); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; background: #fff; color: var(--navy-900); font: 700 18px/1 var(--head); letter-spacing: .04em; }
.brand strong { display: block; font: 700 20px/1 var(--head); color: #fff; text-transform: uppercase; letter-spacing: .06em; }
.brand small { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--steel); }
.nav { display: grid; gap: 4px; margin-top: 18px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px; text-decoration: none; color: #c3d0df; font-weight: 500; transition: background .2s, color .2s; }
.nav a svg { width: 19px; height: 19px; flex: none; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--navy-700); color: #fff; box-shadow: inset 3px 0 0 var(--steel); }
.nav .count { margin-left: auto; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: rgba(143,179,220,.18); color: #fff; font-size: 12px; text-align: center; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 13px; }
.sidebar-foot a, .sidebar-foot button { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 0; border-radius: 8px; background: none; color: #9fb0c5; text-decoration: none; cursor: pointer; text-align: left; }
.sidebar-foot a:hover, .sidebar-foot button:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-foot svg { width: 17px; height: 17px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 32px; background: rgba(244,246,249,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 30px; }
.topbar .crumb { font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.icon-btn.menu-btn { display: none; }
.content { padding: 28px 32px 60px; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; padding: 14px 18px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); border: 1px solid #f3d9a8; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid var(--navy-700); border-radius: 7px; background: var(--navy-700); color: #fff; font-weight: 600; font-size: 14px; letter-spacing: .02em; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .2s, border-color .2s, color .2s; }
.btn:hover { background: var(--navy-900); border-color: var(--navy-900); }
.btn svg { width: 17px; height: 17px; }
.btn-light { background: #fff; color: var(--navy-800); border-color: var(--line); }
.btn-light:hover { background: var(--steel-soft); border-color: var(--steel); color: var(--navy-900); }
.btn-danger { background: #fff; color: var(--bad); border-color: #f2c4bf; }
.btn-danger:hover { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.btn-ok { background: var(--ok); border-color: var(--ok); }
.btn-ok:hover { background: #145c39; border-color: #145c39; }
.btn-sm { min-height: 32px; padding: 0 11px; font-size: 13px; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--navy-800); cursor: pointer; }
.icon-btn:hover { background: var(--steel-soft); }
.icon-btn svg { width: 16px; height: 16px; }

/* Karten & Kennzahlen */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 21px; }
.card-body { padding: 20px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { position: relative; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.kpi::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--navy-600); }
.kpi.warn::after { background: #d98a1c; }
.kpi.ok::after { background: var(--ok); }
.kpi small { display: block; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.kpi strong { display: block; margin-top: 8px; font: 700 32px/1 var(--head); color: var(--ink); }
.kpi span { display: block; margin-top: 6px; font-size: 13px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.quick { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
.list th { padding: 11px 14px; text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); background: var(--paper); border-bottom: 1px solid var(--line); white-space: nowrap; }
.list td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr { transition: background .15s; }
.list tbody tr.clickable { cursor: pointer; }
.list tbody tr.clickable:hover { background: #f8fafc; }
.list .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list .actions { text-align: right; white-space: nowrap; }
.list .actions > * + * { margin-left: 6px; }
.strong { font-weight: 600; color: var(--ink); }
.sub { display: block; font-size: 13px; color: var(--muted); }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 42px; height: 42px; color: var(--steel); margin-bottom: 10px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type=search] { flex: 1; min-width: 200px; max-width: 360px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; background: #fff; }
.seg button { padding: 7px 13px; border: 0; background: none; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--navy-700); color: #fff; }

/* Status-Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; letter-spacing: .03em; white-space: nowrap; background: var(--steel-soft); color: var(--navy-800); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-draft { background: #eef0f3; color: #59636f; }
.b-open { background: var(--steel-soft); color: var(--navy-700); }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); }

/* Formulare */
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px 16px; }
.f { display: grid; gap: 5px; grid-column: span 6; }
.f.s3 { grid-column: span 3; } .f.s4 { grid-column: span 4; } .f.s8 { grid-column: span 8; } .f.s12 { grid-column: span 12; } .f.s2 { grid-column: span 2; }
.f label { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=time], input[type=number], input[type=search], input[type=password], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: 8px 11px; border: 1px solid var(--line); border-radius: 7px; background: #fff; transition: border-color .2s, box-shadow .2s; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-600); box-shadow: 0 0 0 3px rgba(31,76,140,.12); }
.hint { font-size: 12px; color: var(--muted); }
.section-title { grid-column: span 12; margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line); font: 700 17px/1 var(--head); text-transform: uppercase; color: var(--navy-700); letter-spacing: .04em; }

/* Dokument-Editor */
.doc-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.items { width: 100%; border-collapse: collapse; }
.items th { padding: 8px 6px; font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); text-align: left; border-bottom: 1px solid var(--line); }
.items td { padding: 6px; vertical-align: top; border-bottom: 1px dashed var(--line); }
.items td.pos { width: 34px; padding-top: 15px; color: var(--muted); font-weight: 600; }
.items td.sum { width: 120px; padding-top: 15px; text-align: right; font-weight: 600; color: var(--ink); white-space: nowrap; }
.items textarea { min-height: 40px; height: 40px; }
.items .w-qty { width: 80px; } .items .w-unit { width: 92px; } .items .w-price { width: 115px; } .items .w-vat { width: 84px; }
.items input, .items select { min-height: 38px; }
.totals { display: grid; gap: 8px; }
.totals div { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; }
.totals .grand { margin-top: 6px; padding-top: 12px; border-top: 2px solid var(--navy-700); font: 700 24px/1 var(--head); color: var(--ink); }
.side-stack { display: grid; gap: 16px; position: sticky; top: 92px; }
.locked-note { display: flex; gap: 10px; padding: 12px 14px; border-radius: 7px; background: var(--steel-soft); color: var(--navy-800); font-size: 13px; }
.locked-note svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.meta-list { display: grid; gap: 10px; font-size: 14px; }
.meta-list div { display: flex; justify-content: space-between; gap: 10px; }
.meta-list span:first-child { color: var(--muted); }

/* Kalender */
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-head h2 { font-size: 26px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.cal .dow { padding: 9px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); background: var(--paper); border-bottom: 1px solid var(--line); text-align: center; }
.cal .day { min-height: 112px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: pointer; transition: background .15s; }
.cal .day:nth-child(7n) { border-right: 0; }
.cal .day:hover { background: #f8fafc; }
.cal .day.other { background: #fafbfc; color: #aab3be; }
.cal .day .d { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-weight: 600; font-size: 13px; }
.cal .day.today .d { background: var(--navy-700); color: #fff; }
.cal .ev { display: block; margin-top: 3px; padding: 3px 6px; border-radius: 5px; background: var(--steel-soft); color: var(--navy-800); font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--navy-600); }
.cal .ev:hover { background: #d6e4f5; }
.cal .more { font-size: 11px; color: var(--muted); padding-left: 4px; }
.agenda { display: grid; gap: 10px; }
.agenda-item { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; }
.agenda-item:hover { border-color: var(--steel); }
.agenda-date { text-align: center; padding: 6px 0; border-radius: 7px; background: var(--navy-900); color: #fff; }
.agenda-date strong { display: block; font: 700 22px/1 var(--head); }
.agenda-date small { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--steel); }

/* Dialog */
dialog { width: min(720px, calc(100% - 24px)); max-height: calc(100% - 40px); padding: 0; border: 0; border-radius: 12px; box-shadow: 0 30px 80px rgba(7,20,38,.35); }
dialog::backdrop { background: rgba(7,20,38,.55); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 24px; }
.dlg-body { padding: 22px; max-height: calc(100vh - 220px); overflow: auto; }
.dlg-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 16px 22px; border-top: 1px solid var(--line); background: var(--paper); }
.dlg-foot .right { display: flex; gap: 10px; margin-left: auto; }

/* Hinweis-Toast */
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 300; max-width: 380px; padding: 13px 18px; border-radius: 8px; background: var(--navy-900); color: #fff; box-shadow: 0 16px 40px rgba(7,20,38,.3); transform: translateY(20px); opacity: 0; transition: opacity .25s, transform .25s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }

/* Sperrbildschirm */
.lock { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 20px; background: var(--navy-950); background-image: linear-gradient(rgba(143,179,220,.06) 1px, transparent 1px), linear-gradient(90deg, rgba(143,179,220,.06) 1px, transparent 1px); background-size: 32px 32px; }
.lock-card { width: min(380px, 100%); padding: 34px 30px; border-radius: 12px; background: #fff; text-align: center; }
.lock-card .brand-mark { margin: 0 auto 16px; width: 54px; height: 54px; font-size: 24px; background: var(--navy-900); color: #fff; }
.lock-card h1 { font-size: 28px; }
.lock-card p { margin: 8px 0 20px; color: var(--muted); }
.lock-card input { text-align: center; font-size: 22px; letter-spacing: .4em; }
.lock-card .btn { width: 100%; margin-top: 12px; }
.lock-err { color: var(--bad); font-size: 13px; min-height: 20px; margin-top: 8px; }

/* Anmeldung */
.auth-card { text-align: left; }
.auth-card .brand-mark, .auth-card h1, .auth-card > p { text-align: center; }
.auth-field { display: grid; gap: 5px; margin-top: 12px; }
.auth-field label { font-size: 12px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.auth-card .btn { width: 100%; margin-top: 18px; }
.auth-card .btn:disabled { opacity: .6; cursor: wait; }
.auth-msg { min-height: 20px; margin-top: 12px; font-size: 13px; color: var(--ok); text-align: center; }
.auth-msg.err { color: var(--bad); }
.auth-links { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.auth-links button { padding: 0; border: 0; background: none; color: var(--navy-600); font-size: 13px; cursor: pointer; text-decoration: underline; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Sync-Anzeige */
.sync { display: flex; align-items: center; gap: 8px; padding: 6px 12px; font-size: 12px; color: #9fb0c5; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: #3fbf7f; box-shadow: 0 0 0 3px rgba(63,191,127,.18); }
.sync[data-state="saving"] i { background: var(--steel); box-shadow: 0 0 0 3px rgba(143,179,220,.2); animation: pulse 1s ease-in-out infinite; }
.sync[data-state="error"] i { background: #e5484d; box-shadow: 0 0 0 3px rgba(229,72,77,.2); }
@keyframes pulse { 50% { opacity: .35; } }
.account { padding: 0 12px; font-size: 12px; color: #7f92aa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account:empty { display: none; }

/* Responsiv */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .doc-layout { grid-template-columns: 1fr; }
  .side-stack { position: static; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 100; left: 0; width: 270px; transform: translateX(-100%); transition: transform .3s; }
  .nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(7,20,38,.5); }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 14px 16px; }
  .topbar h1 { font-size: 24px; }
  .content { padding: 18px 16px 50px; }
  .grid-2 { grid-template-columns: 1fr; }
  .f, .f.s3, .f.s4, .f.s8, .f.s2 { grid-column: span 12; }
  .cal .day { min-height: 74px; }
  .cal .ev { font-size: 0; height: 6px; padding: 0; border-left: 0; background: var(--navy-600); }
  .items thead { display: none; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .items td { border: 0; padding: 0; }
  .items td.pos { display: none; }
  .items td.desc { grid-column: 1 / -1; }
  .items td.sum { padding-top: 10px; }
  .items .w-qty, .items .w-unit, .items .w-price, .items .w-vat { width: auto; }
}
@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
  .topbar-actions .btn span { display: none; }
}
@media print { .sidebar, .topbar, .toast { display: none !important; } .app { display: block; } }
