/* =========================================================================
   CCC Secure Data Room — Design-System
   Konzept: "Sicherer Tresor / Audit-Ledger". CCC-CI: Signalrot #DC0021 sparsam,
   Anthrazit als Fundament. System-Fonts (DSGVO: keine externen Fonts).
   ========================================================================= */

:root {
  /* Farben */
  --ink:        #15181b;   /* Headings, Primärtext */
  --ink-2:      #4e5456;   /* CCC-Anthrazit, Sekundärtext */
  --ink-3:      #868d94;   /* Labels, Muted */
  --paper:      #f5f6f8;   /* App-Hintergrund */
  --surface:    #ffffff;   /* Karten */
  --surface-2:  #f1f3f5;   /* dezente Füllung */
  --line:       #e5e8eb;   /* Haarlinie */
  --line-2:     #d6dadf;

  --red:        #dc0021;   /* CCC-Signal */
  --red-ink:    #a8001a;
  --red-tint:   #fdeaed;

  --ok:    #0e7a53;  --ok-tint:   #e6f4ee;
  --warn:  #9a5b00;  --warn-tint: #fbefd9;
  --danger:#c0142b;  --danger-tint:#fce9ec;

  --sidebar:    #16191c;   /* dunkles Control-Panel */
  --sidebar-2:  #20262b;
  --sidebar-tx: #c9ced3;
  --sidebar-mut:#7f878f;

  /* Typografie */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", "Segoe UI Mono", Consolas, "Roboto Mono", monospace;

  /* Form */
  --r-sm: 7px;  --r: 11px;  --r-lg: 16px;
  --sh-1: 0 1px 2px rgba(21,24,27,.05), 0 1px 1px rgba(21,24,27,.04);
  --sh-2: 0 10px 30px rgba(21,24,27,.08), 0 2px 8px rgba(21,24,27,.05);
  --sh-pop: 0 18px 50px rgba(21,24,27,.18);
  --ring: 0 0 0 3px rgba(220,0,33,.16);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; color: var(--ink); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.12rem; }
p  { margin: 0; }
a  { color: var(--red-ink); text-decoration: none; }

/* Mono-Signatur: Eyebrows, IDs, Codes, Daten ------------------------------ */
.eyebrow {
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* =========================================================================
   Externe Seiten (zentriert) — Login / OTP / Upload / Download
   ========================================================================= */
.shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background:
    radial-gradient(120% 80% at 50% -10%, #ffffff 0%, var(--paper) 60%);
}
.shell-top {
  display: flex; align-items: center; gap: .8rem;
  padding: 1.4rem 1.6rem;
}
.shell-top .mark { height: 30px; width: auto; display: block; }
.shell-top .wordmark {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink-3);
  border-left: 1px solid var(--line-2); padding-left: .8rem;
}
.shell-main { display: flex; align-items: flex-start; justify-content: center; padding: 2rem 1.25rem 3rem; }
.shell-foot {
  text-align: center; color: var(--ink-3); font-size: .8rem;
  padding: 1.4rem; border-top: 1px solid var(--line);
}

.auth-card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
  overflow: hidden;
  animation: rise .5s cubic-bezier(.16,.84,.44,1) both;
}
.auth-card.wide { max-width: 560px; }
/* roter Siegel-Strich oben */
.auth-card::before {
  content: ""; display: block; height: 3px;
  background: linear-gradient(90deg, var(--red) 0%, var(--red) 38%, transparent 38%);
}
.auth-body { padding: 2.2rem 2.2rem 2rem; }
.auth-body .eyebrow { display: block; margin-bottom: .7rem; }
.auth-body h1 { font-size: 1.45rem; }
.auth-body .lead { color: var(--ink-2); margin-top: .55rem; font-size: .95rem; }

/* Sicherheits-Hinweiszeile */
.secure-note {
  display: flex; align-items: center; gap: .5rem;
  margin-top: 1.4rem; padding-top: 1.1rem; border-top: 1px solid var(--line);
  font-size: .8rem; color: var(--ink-3);
}
.secure-note .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-tint); }

/* =========================================================================
   Formularelemente
   ========================================================================= */
.field { display: block; margin-bottom: 1.05rem; }
.field > span { display: block; font-size: .82rem; font-weight: 550; color: var(--ink-2); margin-bottom: .4rem; }
.field .hint { font-weight: 400; color: var(--ink-3); }

input[type=text], input[type=email], input[type=password],
select, textarea {
  width: 100%; padding: .68rem .8rem;
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--red); box-shadow: var(--ring);
}
input::placeholder { color: #b6bcc2; }

/* OTP / Code-Eingabe */
.code-input {
  font-family: var(--font-mono); font-size: 1.5rem; letter-spacing: .5em;
  text-align: center; padding-left: .5em;
}

/* Buttons ----------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .68rem 1.25rem; font: inherit; font-weight: 600; line-height: 1;
  border: 1px solid transparent; border-radius: var(--r-sm);
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-ink); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--ink-3); background: var(--surface-2); }
.btn-sm { padding: .42rem .8rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Status / Inline-Meldungen ----------------------------------------------- */
.status { margin-top: 1rem; font-size: .9rem; min-height: 1.2em; }
.status.pending { color: var(--ink-3); }
.status.ok { color: var(--ok); font-weight: 600; }
.status.error { color: var(--danger); font-weight: 600; }

/* Siegel / Badges --------------------------------------------------------- */
.seal {
  display: inline-flex; align-items: center; gap: .35rem;
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .04em;
  text-transform: uppercase; font-weight: 500;
  padding: .22rem .5rem; border-radius: 999px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line-2);
}
.seal::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.seal.ok    { background: var(--ok-tint);    color: var(--ok);    border-color: transparent; }
.seal.warn  { background: var(--warn-tint);  color: var(--warn);  border-color: transparent; }
.seal.danger{ background: var(--danger-tint);color: var(--danger);border-color: transparent; }

/* Dropzone ---------------------------------------------------------------- */
.dropzone {
  margin-top: 1.4rem; padding: 2.2rem 1.4rem; text-align: center;
  border: 1.5px dashed var(--line-2); border-radius: var(--r);
  background: var(--surface-2);
  transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--red); background: var(--red-tint); }
.dropzone .dz-title { font-weight: 600; }
.dropzone .dz-sub { color: var(--ink-3); font-size: .85rem; margin-top: .3rem; }
.dropzone input[type=file] { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin: 1rem 0 1.3rem; }
.chip {
  font-family: var(--font-mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-2); background: var(--surface); border: 1px solid var(--line);
  padding: .22rem .5rem; border-radius: var(--r-sm);
}
.filename { margin-top: .9rem; font-family: var(--font-mono); font-size: .85rem; color: var(--ink-2); word-break: break-all; }

/* Dateiliste (Download) --------------------------------------------------- */
.filelist { list-style: none; padding: 0; margin: 1.4rem 0 0; display: grid; gap: .6rem; }
.filelist li {
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-1);
}
.filelist .f-name { font-weight: 550; word-break: break-all; flex: 1; }
.filelist .f-size { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-3); }
.empty { color: var(--ink-3); text-align: center; padding: 1.5rem 0; }

/* =========================================================================
   Admin-Dashboard — App-Shell mit Sidebar
   ========================================================================= */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }

.side {
  background: var(--sidebar); color: var(--sidebar-tx);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: .7rem; padding: 1.3rem 1.3rem 1.1rem; }
.side-brand img { height: 26px; }
.side-brand .t { font-size: .82rem; line-height: 1.25; }
.side-brand .t b { display: block; color: #fff; font-weight: 600; }
.side-brand .t span { font-family: var(--font-mono); font-size: .62rem; letter-spacing: .16em; text-transform: uppercase; color: var(--sidebar-mut); }

.side-nav { padding: .6rem .7rem; display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.nav-label { font-family: var(--font-mono); font-size: .6rem; letter-spacing: .18em; text-transform: uppercase; color: var(--sidebar-mut); padding: .9rem .7rem .35rem; }
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .6rem .75rem; border-radius: var(--r-sm);
  color: var(--sidebar-tx); font-weight: 500; font-size: .92rem;
  cursor: pointer; border-left: 2px solid transparent;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--sidebar-2); color: #fff; border-left-color: var(--red); }
.nav-item .ic { width: 17px; height: 17px; flex: none; opacity: .9; }

.side-foot { border-top: 1px solid rgba(255,255,255,.08); padding: .9rem 1rem; }
.side-foot .who { font-size: .82rem; color: #fff; font-weight: 550; word-break: break-all; }
.side-foot .role { font-family: var(--font-mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--sidebar-mut); margin-top: .1rem; }
.side-foot .btn { margin-top: .7rem; width: 100%; background: transparent; color: var(--sidebar-tx); border-color: rgba(255,255,255,.16); }
.side-foot .btn:hover { background: var(--sidebar-2); color: #fff; }

/* Hauptbereich */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.15rem 1.8rem; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.85); backdrop-filter: saturate(1.4) blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.topbar .pagetitle { font-size: 1.15rem; font-weight: 650; }
.topbar .channel { display: flex; align-items: center; gap: .45rem; font-family: var(--font-mono); font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.topbar .channel .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-tint); }
.content { padding: 1.8rem; max-width: 1080px; width: 100%; }
.view { animation: rise .35s ease both; }

/* Stat-Kacheln (Übersicht) */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 1.05rem 1.1rem; box-shadow: var(--sh-1); position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--line-2); }
.stat.accent::before { background: var(--red); }
.stat.flag::before { background: var(--warn); }
.stat .k { font-family: var(--font-mono); font-size: .64rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.stat .v { font-family: var(--font-mono); font-size: 1.9rem; font-weight: 600; line-height: 1.1; margin-top: .35rem; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: .78rem; color: var(--ink-3); margin-top: .2rem; }

/* Karten / Panels */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh-1); }
.card-h { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: 1rem; }
.card-b { padding: 1.2rem; }
.section-gap { margin-top: 1.5rem; }

/* Ledger (Aktivitäts-Log) */
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li { display: grid; grid-template-columns: 92px 1fr auto; gap: 1rem; align-items: baseline; padding: .6rem 0; border-bottom: 1px dashed var(--line); }
.ledger li:last-child { border-bottom: 0; }
.ledger .t { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); }
.ledger .act { font-size: .9rem; }
.ledger .act b { font-weight: 600; }
.ledger .who { font-family: var(--font-mono); font-size: .72rem; color: var(--ink-3); }

/* Tabellen */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: left; font-family: var(--font-mono); font-size: .64rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 500;
  padding: .6rem .7rem; border-bottom: 1px solid var(--line);
}
.tbl td { padding: .75rem .7rem; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: var(--surface-2); }
.tbl .muted { color: var(--ink-3); }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }

/* Link-Box (erzeugter Mandanten-Link / Temp-Passwort) */
.linkbox {
  margin-top: 1rem; padding: .85rem 1rem; border-radius: var(--r-sm);
  background: var(--ink); color: #eef0f2; box-shadow: var(--sh-1);
}
.linkbox .lb-k { font-family: var(--font-mono); font-size: .6rem; letter-spacing: .14em; text-transform: uppercase; color: #9aa1a8; }
.linkbox .lb-row { display: flex; align-items: center; gap: .6rem; margin-top: .35rem; }
.linkbox code { font-family: var(--font-mono); font-size: .82rem; word-break: break-all; flex: 1; }
.linkbox .btn { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.2); }
.linkbox .btn:hover { background: rgba(255,255,255,.2); }

/* Recovery-Codes */
.codes { font-family: var(--font-mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 1rem 1.2rem; line-height: 2; column-count: 2; }

/* QR */
.qrwrap { display: flex; gap: 1.3rem; align-items: flex-start; flex-wrap: wrap; }
.qrwrap img { width: 168px; height: 168px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.grow { flex: 1; }

/* =========================================================================
   Slide-over Panel + Backdrop
   ========================================================================= */
.backdrop {
  position: fixed; inset: 0; background: rgba(21,24,27,.42);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40;
}
.backdrop.show { opacity: 1; pointer-events: auto; }
.slideover {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(460px, 92vw);
  background: var(--surface); box-shadow: var(--sh-pop); z-index: 41;
  transform: translateX(100%); transition: transform .26s cubic-bezier(.16,.84,.44,1);
  display: flex; flex-direction: column;
}
.slideover.show { transform: none; }
.so-h { display: flex; align-items: center; justify-content: space-between; padding: 1.2rem 1.4rem; border-bottom: 1px solid var(--line); }
.so-b { padding: 1.4rem; overflow-y: auto; }
.so-close { background: none; border: 0; font-size: 1.3rem; line-height: 1; color: var(--ink-3); cursor: pointer; padding: .2rem .4rem; border-radius: var(--r-sm); }
.so-close:hover { background: var(--surface-2); color: var(--ink); }

/* =========================================================================
   Toasts
   ========================================================================= */
.toasts { position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 60; display: flex; flex-direction: column; gap: .55rem; }
.toast {
  min-width: 240px; max-width: 360px;
  background: var(--ink); color: #f3f4f6; border-radius: var(--r-sm);
  padding: .7rem .9rem; font-size: .88rem; box-shadow: var(--sh-pop);
  border-left: 3px solid var(--ink-3);
  animation: toastin .26s cubic-bezier(.16,.84,.44,1) both;
}
.toast.ok { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }

/* =========================================================================
   Animationen
   ========================================================================= */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastin { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* =========================================================================
   Responsive
   ========================================================================= */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .side-nav { flex-direction: row; flex: 1 1 100%; overflow-x: auto; padding: .4rem .6rem; }
  .nav-label { display: none; }
  .nav-item { border-left: 0; border-bottom: 2px solid transparent; white-space: nowrap; }
  .nav-item.active { border-left: 0; border-bottom-color: var(--red); }
  .side-foot { border-top: 0; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 1.1rem; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: 1fr; }
  .ledger li { grid-template-columns: 1fr; gap: .15rem; }
  .codes { column-count: 1; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
