/* ===========================================================================
   CARDES Workspace · Gestaltung
   Dunkles CARDES-Design (wie cardes.at): Nachtblau + Gold.
   Mobil zuerst, grosse Bedienelemente, wenig Schnickschnack.
   =========================================================================== */

:root {
  --bg:      #101019;
  --bg-2:    #14141f;
  --card:    #1F1F30;
  --card-2:  #262638;
  --ink:     #F3F1FA;
  --muted:   #9C99B3;
  --line:    rgba(243, 241, 250, .09);
  --line-2:  rgba(243, 241, 250, .16);

  --accent:      #D4A24E;
  --accent-ink:  #1a1206;
  --accent-soft: rgba(212, 162, 78, .13);
  --accent-line: rgba(212, 162, 78, .38);

  --ok:      #4ADE80;  --ok-bg:   rgba(74, 222, 128, .14);
  --warn:    #FBBF24;  --warn-bg: rgba(251, 191, 36, .14);
  --err:     #F87171;  --err-bg:  rgba(248, 113, 113, .14);
  --info:    #7DD3FC;  --info-bg: rgba(125, 211, 252, .14);

  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4);
  --shadow-2: 0 6px 18px rgba(0,0,0,.35);
  --shadow-3: 0 20px 50px rgba(0,0,0,.5);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wrap: 1100px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(212,162,78,.07), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.55;
  min-height: 100svh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.7rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.ic { display: inline-block; vertical-align: -.18em; }

/* --- Grundgeruest --------------------------------------------------------- */
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px 60px; }
.wrap-narrow { max-width: 660px; }

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(16, 16, 25, .86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: var(--wrap); margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 12px; min-height: 58px;
}
.brand {
  display: flex; align-items: baseline; gap: 8px;
  font-weight: 800; letter-spacing: .14em; font-size: 1.02rem;
  color: var(--ink); white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand .b-sub {
  letter-spacing: .02em; font-weight: 500; color: var(--muted); font-size: .92rem;
}
.brand .b-dot { color: var(--accent); }
.topbar-sp { flex: 1; }

/* --- Karten --------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: 14px; }
.card h2 { display: flex; align-items: center; gap: 8px; }

/* Modul-Kacheln der Startseite */
.modules { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 18px; }
@media (min-width: 720px) { .modules { grid-template-columns: 1fr 1fr; } }

.module-card {
  display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(160deg, var(--card) 0%, var(--card-2) 100%);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 24px 22px;
  color: var(--ink);
  box-shadow: var(--shadow-2);
  transition: transform .14s ease, border-color .14s ease;
  min-height: 150px;
}
.module-card:hover { transform: translateY(-2px); border-color: var(--accent-line); text-decoration: none; }
.module-card:active { transform: translateY(0); }
.module-card .m-icon {
  width: 46px; height: 46px; border-radius: 13px;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.module-card .m-title { font-size: 1.22rem; font-weight: 750; letter-spacing: .01em; }
.module-card .m-desc { color: var(--muted); font-size: .95rem; }
.module-card.placeholder {
  border-style: dashed; box-shadow: none; background: transparent;
  align-items: center; justify-content: center; text-align: center;
  color: var(--muted);
}

/* --- Knoepfe -------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 650; font-size: .98rem;
  padding: 12px 18px; border-radius: var(--r);
  border: 1px solid var(--line-2);
  background: var(--card-2); color: var(--ink);
  cursor: pointer; user-select: none;
  transition: filter .12s ease, transform .06s ease;
  min-height: 46px;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-danger  { background: var(--err-bg); border-color: rgba(248,113,113,.4); color: var(--err); }
.btn-ok      { background: var(--ok-bg); border-color: rgba(74,222,128,.4); color: var(--ok); }
.btn-ghost   { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }
.btn-sm { padding: 8px 12px; min-height: 38px; font-size: .9rem; border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; min-width: 46px; }

/* --- Formulare ------------------------------------------------------------ */
label.fld { display: block; margin-bottom: 14px; }
label.fld > span, .fld-label {
  display: block; font-size: .86rem; font-weight: 650; color: var(--muted);
  margin-bottom: 6px; letter-spacing: .02em;
}
.req::after { content: " *"; color: var(--accent); }

input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=number], input[type=date], input[type=time], input[type=url],
select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--bg-2); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); padding: 12px 13px; min-height: 48px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: rgba(156,153,179,.6); }
textarea { resize: vertical; min-height: 72px; }
select { appearance: none; -webkit-appearance: none; background-image:
  url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239C99B3' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px; }

input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; }
input::-webkit-calendar-picker-indicator { filter: invert(.75) sepia(.3) saturate(2) hue-rotate(5deg); cursor: pointer; }

.row2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 560px) { .row2 { grid-template-columns: 1fr 1fr; } }
.row3 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 560px) { .row3 { grid-template-columns: 1fr 1fr 1fr; } }

.hint { font-size: .84rem; color: var(--muted); margin-top: -8px; margin-bottom: 14px; }

/* --- Status-Abzeichen ----------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .8rem; font-weight: 700; letter-spacing: .02em;
  padding: 4px 11px; border-radius: 999px; white-space: nowrap;
}
.badge-muted { background: rgba(156,153,179,.14); color: var(--muted); }
.badge-info  { background: var(--info-bg); color: var(--info); }
.badge-warn  { background: var(--warn-bg); color: var(--warn); }
.badge-ok    { background: var(--ok-bg); color: var(--ok); }
.badge-err   { background: var(--err-bg); color: var(--err); }
.badge-gold  { background: var(--accent-soft); color: var(--accent); }

/* --- Listenzeilen --------------------------------------------------------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px 16px;
  display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center;
  cursor: pointer; transition: border-color .12s ease;
  color: var(--ink); text-align: left; width: 100%; font: inherit;
}
.list-item:hover { border-color: var(--accent-line); }
.li-main { flex: 1 1 220px; min-width: 0; }
.li-title { font-weight: 700; }
.li-sub { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.li-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.group-head {
  display: flex; align-items: center; gap: 10px;
  margin: 26px 0 10px; color: var(--muted);
  font-size: .85rem; font-weight: 750; letter-spacing: .09em; text-transform: uppercase;
}
.group-head::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.group-head .cnt { background: var(--card-2); border-radius: 999px; padding: 1px 9px; font-size: .78rem; }

/* --- Reiter --------------------------------------------------------------- */
.tabs {
  display: flex; gap: 6px; margin: 16px 0 20px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); padding: 5px; overflow-x: auto;
}
.tab {
  flex: 1 0 auto; text-align: center; font: inherit; font-weight: 650; font-size: .94rem;
  padding: 10px 14px; border-radius: var(--r-sm); border: 0;
  background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap;
  min-height: 42px;
}
.tab.on { background: var(--accent); color: var(--accent-ink); }
.tab:not(.on):hover { color: var(--ink); }

/* --- Dialoge -------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(6, 6, 12, .7);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
@media (min-width: 640px) { .overlay { align-items: center; padding: 24px; } }
.modal {
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%; max-width: 620px; max-height: 92svh; overflow: auto;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-3);
  -webkit-overflow-scrolling: touch;
}
@media (min-width: 640px) { .modal { border-radius: var(--r-lg); padding: 26px; } }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-x { margin-left: auto; }

/* --- Toast ---------------------------------------------------------------- */
#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  background: var(--card-2); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r);
  padding: 12px 20px; font-weight: 650; font-size: .95rem;
  box-shadow: var(--shadow-3); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 400; max-width: min(92vw, 480px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: rgba(248,113,113,.5); color: var(--err); }

/* --- Definitionslisten (Detailansicht) ------------------------------------ */
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .kv { grid-template-columns: 108px 1fr; } }

/* --- Unterschrift --------------------------------------------------------- */
.sigwrap {
  background: #fdfcf9; border: 1.5px dashed var(--accent-line);
  border-radius: var(--r); position: relative; overflow: hidden;
  touch-action: none;
}
.sigwrap canvas { display: block; width: 100%; height: 190px; touch-action: none; cursor: crosshair; }
.sigwrap .sig-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #b3ab98; font-size: .95rem; pointer-events: none;
}
.sig-img { background: #fdfcf9; border-radius: var(--r); padding: 6px; max-width: 380px; }
.sig-img img { display: block; width: 100%; }

/* --- Kalender ------------------------------------------------------------- */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-title { font-weight: 750; font-size: 1.05rem; flex: 1; text-transform: capitalize; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--line); border-radius: var(--r);
  overflow: hidden; background: var(--line);
  gap: 1px;
}
.cal-dow {
  background: var(--card-2); color: var(--muted); font-size: .74rem; font-weight: 750;
  text-transform: uppercase; letter-spacing: .06em; text-align: center; padding: 7px 2px;
}
.cal-day { background: var(--card); min-height: 86px; padding: 5px; font-size: .8rem; position: relative; }
.cal-day.out { opacity: .38; }
.cal-day.today .d-num { background: var(--accent); color: var(--accent-ink); }
.d-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 8px; font-weight: 700; margin-bottom: 3px;
}
.d-ev {
  display: block; width: 100%; text-align: left; border: 0; font: inherit; cursor: pointer;
  font-size: .72rem; font-weight: 650; line-height: 1.3;
  border-radius: 6px; padding: 2px 6px; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.d-ev.ev-urlaub { background: var(--ok-bg); color: var(--ok); }
.d-ev.ev-nv     { background: var(--warn-bg); color: var(--warn); }
.d-ev.ev-offen  { background: var(--info-bg); color: var(--info); border: 1px dashed rgba(125,211,252,.5); }
.cal-week .cal-day { min-height: 150px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: .82rem; color: var(--muted); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* --- Leihnehmer-Seite (r.html) -------------------------------------------- */
.steps { counter-reset: step; }
.step { margin-bottom: 22px; }
.step-h {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
  font-weight: 750; font-size: 1.05rem;
}
.step-h::before {
  counter-increment: step; content: counter(step);
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 9px; flex: 0 0 auto;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  color: var(--accent); font-size: .9rem; font-weight: 800;
}

.video-box { border-radius: var(--r); overflow: hidden; background: #000; }
.video-box video, .video-box iframe { display: block; width: 100%; aspect-ratio: 16/9; border: 0; }

.items-view { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex; gap: 10px; align-items: baseline;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 13px;
}
.item-row .qty { font-weight: 800; color: var(--accent); white-space: nowrap; }
.item-row .nm { font-weight: 650; }
.item-row .nt { color: var(--muted); font-size: .86rem; }

.fee-box {
  display: flex; align-items: baseline; gap: 10px;
  background: var(--accent-soft); border: 1px solid var(--accent-line);
  border-radius: var(--r); padding: 14px 16px; font-weight: 700;
}
.fee-box .amount { font-size: 1.45rem; color: var(--accent); font-weight: 800; margin-left: auto; }

/* --- Diverses ------------------------------------------------------------- */
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hstack { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 16px; }
.mb0 { margin-bottom: 0; }

.empty {
  text-align: center; color: var(--muted); padding: 34px 16px;
  border: 1.5px dashed var(--line-2); border-radius: var(--r);
}

.bigload { text-align: center; padding: 70px 0; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  display: inline-block; width: 26px; height: 26px;
  border: 3px solid var(--line-2); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite; margin-bottom: 10px;
}

.demo-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 500;
  background: #4a3517; color: #ffd58a; text-align: center;
  font-size: .82rem; font-weight: 650; padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
}
/* Der Vorschau-Balken darf nie Knöpfe oder Meldungen verdecken */
body.demo-mode { padding-bottom: 84px; }
body.demo-mode #toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
body.demo-mode .overlay { padding-bottom: 60px; }

/* Fehlende Pflichtfelder */
input.invalid, textarea.invalid, select.invalid {
  border-color: var(--err) !important;
  background: rgba(248, 113, 113, .06);
}

/* Item-Editor (Vermietung anlegen) */
.item-edit { display: grid; grid-template-columns: 1fr 72px 44px; gap: 8px; margin-bottom: 8px; align-items: start; }
.item-edit .note-in { grid-column: 1 / -1; margin-top: -2px; }
@media (min-width: 560px) {
  .item-edit { grid-template-columns: 1.4fr 72px 1fr 44px; }
  .item-edit .note-in { grid-column: auto; margin-top: 0; }
}

/* Login */
.auth-hero { text-align: center; padding: 46px 0 8px; }
.auth-hero .logo {
  font-size: 1.9rem; font-weight: 850; letter-spacing: .22em; margin-bottom: 2px;
}
.auth-hero .logo .b-dot { color: var(--accent); }
.auth-hero p { color: var(--muted); }
