/* Maris – Backend / Verwaltung */
:root {
    --a-bg: #f4f5f7; --a-panel: #ffffff; --a-ink: #222; --a-muted: #7a828c;
    --a-line: #e3e6ea; --a-accent: #a8743a; --a-accent-dark: #855b2c;
    --a-danger: #c0392b; --a-radius: 10px; --a-shadow: 0 2px 10px rgba(0,0,0,.06);
    --a-sidew: 232px; --a-toph: 58px;
}
* { box-sizing: border-box; }
body.admin { margin: 0; background: var(--a-bg); color: var(--a-ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px; }
a { color: var(--a-accent-dark); text-decoration: none; }
h1, h2 { font-weight: 650; }

/* ---- Topbar ---- */
.admin-top { position: fixed; top: 0; left: 0; right: 0; height: var(--a-toph); z-index: 50;
    background: #2b2620; color: #fff; display: flex; align-items: center; gap: 1rem; padding: 0 1rem; }
.admin-brand { color: #fff; font-weight: 650; font-size: 1.05rem; }
.admin-top-right { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.admin-top-right a { color: rgba(255,255,255,.85); font-size: .9rem; }
.admin-top-right a:hover { color: #fff; }
.btn-logout { border: 1px solid rgba(255,255,255,.3); padding: .35rem .8rem; border-radius: 999px; }
.admin-burger { display: none; background: none; border: 0; color: #fff; font-size: 1.3rem; cursor: pointer; }

/* ---- Shell ---- */
.admin-shell { display: flex; padding-top: var(--a-toph); min-height: 100vh; }
.admin-side { width: var(--a-sidew); background: var(--a-panel); border-right: 1px solid var(--a-line);
    position: fixed; top: var(--a-toph); bottom: 0; overflow-y: auto; }
.admin-side nav { display: flex; flex-direction: column; padding: 1rem .6rem; gap: .1rem; }
.admin-side a { padding: .65rem .85rem; border-radius: 8px; color: var(--a-ink); font-weight: 500; }
.admin-side a:hover { background: var(--a-bg); }
.admin-side a.active { background: var(--a-accent); color: #fff; }
.admin-main { margin-left: var(--a-sidew); flex: 1; padding: 1.6rem clamp(1rem, 3vw, 2.4rem); width: 100%; }
.admin-head h1 { margin: .2rem 0 1.2rem; }

/* ---- Cards / tables ---- */
.a-card { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius);
    padding: 1.4rem; box-shadow: var(--a-shadow); margin-bottom: 1.4rem; }
.a-card h2 { margin: 0 0 1rem; font-size: 1.15rem; }
.a-card-form { max-width: 820px; }
.a-card-form h2 { margin-top: 1.6rem; border-top: 1px solid var(--a-line); padding-top: 1.2rem; }
.a-card-form h2:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.a-toolbar { margin-bottom: 1rem; display: flex; gap: .6rem; }
.a-toolbar-split { justify-content: space-between; align-items: center; flex-wrap: wrap; }
.a-muted { color: var(--a-muted); }
.a-hint { color: var(--a-muted); margin-top: 0; }

.a-table { width: 100%; border-collapse: collapse; }
.a-table th, .a-table td { text-align: left; padding: .7rem .6rem; border-bottom: 1px solid var(--a-line); vertical-align: middle; }
.a-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--a-muted); }
.a-row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
.a-pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; background: var(--a-bg); font-size: .8rem; color: var(--a-muted); }
.a-pill-on { background: #e3f3e8; color: #2e8b57; }

/* ---- Buttons ---- */
.a-btn { display: inline-flex; align-items: center; gap: .3rem; background: var(--a-panel);
    border: 1px solid var(--a-line); color: var(--a-ink); padding: .55rem 1rem; border-radius: 8px;
    font: inherit; font-weight: 550; cursor: pointer; transition: .15s; }
.a-btn:hover { border-color: var(--a-accent); color: var(--a-accent-dark); }
.a-btn-primary { background: var(--a-accent); border-color: var(--a-accent); color: #fff; }
.a-btn-primary:hover { background: var(--a-accent-dark); color: #fff; }
.a-btn-danger { color: var(--a-danger); }
.a-btn-danger:hover { background: var(--a-danger); border-color: var(--a-danger); color: #fff; }
.a-btn-sm { padding: .35rem .7rem; font-size: .85rem; }
.a-btn-block { width: 100%; justify-content: center; }
.a-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

/* ---- Forms ---- */
.a-field { margin-bottom: 1rem; }
.a-field label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .9rem; }
.a-field input[type=text], .a-field input[type=email], .a-field input[type=url],
.a-field input[type=number], .a-field input[type=password], .a-field select, .a-field textarea {
    width: 100%; padding: .6rem .75rem; border: 1px solid var(--a-line); border-radius: 8px;
    background: #fff; color: var(--a-ink); font: inherit; }
.a-field textarea { resize: vertical; }
.a-field .a-mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .9rem; }
.a-field input:focus, .a-field select:focus, .a-field textarea:focus { outline: 2px solid var(--a-accent); border-color: var(--a-accent); }
.a-field small { display: block; margin-top: .3rem; }
.a-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.2rem; }
.a-check label { font-weight: 500; display: block; margin: .5rem 0; }
.a-check input { margin-right: .4rem; }
.a-filter { display: flex; align-items: center; gap: .5rem; }
.a-filter select { padding: .45rem .6rem; border: 1px solid var(--a-line); border-radius: 8px; }
.a-current-img { display: flex; align-items: center; gap: .8rem; margin-bottom: .5rem; }
.a-current-img img { width: 90px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--a-line); }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1.4rem; }
.stat-card { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius);
    padding: 1.3rem; text-align: center; box-shadow: var(--a-shadow); }
.stat-card:hover { border-color: var(--a-accent); }
.stat-num { display: block; font-size: 2rem; font-weight: 700; color: var(--a-accent-dark); }
.stat-lbl { color: var(--a-muted); font-size: .9rem; }

/* ---- Thumbs (Werke) ---- */
.a-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 1rem; }
.a-thumb { border: 1px solid var(--a-line); border-radius: var(--a-radius); overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.a-thumb-img { position: relative; aspect-ratio: 1/1; background: var(--a-bg); }
.a-thumb-img img { width: 100%; height: 100%; object-fit: cover; }
.a-thumb-ph { display: grid; place-items: center; height: 100%; color: var(--a-muted); font-size: .85rem; }
.a-thumb-flag { position: absolute; top: .4rem; left: .4rem; background: rgba(0,0,0,.6); color: #fff; font-size: .72rem; padding: .1rem .5rem; border-radius: 6px; }
.a-thumb-body { padding: .6rem .7rem; display: flex; flex-direction: column; gap: .1rem; }
.a-thumb-body span { font-size: .82rem; }
.a-thumb-actions { margin-top: auto; padding: .6rem .7rem; display: flex; gap: .4rem; border-top: 1px solid var(--a-line); }
.a-thumb-actions form { flex: 1; }
.a-thumb-actions .a-btn { width: 100%; justify-content: center; }

/* ---- Messages ---- */
.a-messages { display: grid; gap: 1rem; }
.a-message { border: 1px solid var(--a-line); border-radius: 8px; padding: 1rem; }
.a-message header { display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .5rem; }
.a-message time { margin-left: auto; font-size: .85rem; }
.a-msg-subject { font-weight: 600; margin-bottom: .3rem; }
.a-msg-body { white-space: pre-wrap; color: #333; }

/* ---- Flash ---- */
.a-flash { background: #eef7f0; border: 1px solid #cfe6d6; color: #2e6b45; padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1.2rem; }
.a-flash-error { background: #fdecea; border-color: #f5c6c0; color: #a5342a; }

/* ---- Auth page ---- */
.auth-page { display: grid; place-items: center; min-height: 100vh; }
.auth-card { background: var(--a-panel); border: 1px solid var(--a-line); border-radius: 16px;
    padding: 2.2rem; width: min(400px, 92vw); box-shadow: 0 20px 50px rgba(0,0,0,.12); }
.auth-brand { font-family: Georgia, serif; font-size: 1.8rem; font-weight: 700; text-align: center; }
.auth-sub { text-align: center; color: var(--a-muted); letter-spacing: .15em; text-transform: uppercase; font-size: .75rem; margin-bottom: 1.6rem; }

.a-multi-note { background: #fff8ef; border: 1px solid #e8d3b5; color: #7d5433; padding: .8rem 1rem; border-radius: 8px; margin-top: .7rem; font-size: .9rem; line-height: 1.5; }
.a-color { display: flex; align-items: center; gap: .7rem; }
.a-color input[type=color] { width: 54px; height: 38px; padding: 2px; border: 1px solid var(--a-line); border-radius: 8px; background: #fff; cursor: pointer; }
.a-color-hex { font-family: ui-monospace, Consolas, monospace; color: var(--a-muted); font-size: .95rem; }

/* ---- Statistik / Diagramme ---- */
.stat-range { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.chart-head h2 { margin: 0; }
.chart-legend { font-size: .82rem; color: var(--a-muted); display: flex; align-items: center; gap: .4rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-users { background: var(--a-accent); }

.chart { display: flex; align-items: flex-end; gap: 2px; height: 220px; }
.chart-col { flex: 1 1 0; height: 100%; display: flex; align-items: flex-end; min-width: 0; }
.bar { width: 100%; border-radius: 3px 3px 0 0; }
.bar-users { background: linear-gradient(180deg, var(--a-accent), #c79463); min-height: 2px; }
.chart-col:hover .bar { filter: brightness(1.12); }
.chart-axis { position: relative; height: 18px; margin-top: 6px; }
.chart-axis-label { position: absolute; transform: translateX(-50%); font-size: .72rem; color: var(--a-muted); white-space: nowrap; }

.stat-two { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; }

.rank-list { display: flex; flex-direction: column; gap: .75rem; }
.rank-row { display: flex; align-items: center; gap: .8rem; }
.rank-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; background: var(--a-bg); border: 1px solid var(--a-line); flex: none; }
.rank-body { flex: 1; min-width: 0; }
.rank-title { font-size: .9rem; font-weight: 600; margin-bottom: .28rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar-track { height: 8px; background: var(--a-bg); border-radius: 6px; overflow: hidden; }
.rank-bar { height: 100%; background: linear-gradient(90deg, var(--a-accent), #c79463); border-radius: 6px; min-width: 2px; }
.rank-val { font-weight: 700; color: var(--a-accent-dark); min-width: 46px; text-align: right; }

.chart-weekday { height: 170px; gap: .6rem; }
.wd-col { flex-direction: column; justify-content: flex-end; align-items: center; }
.wd-col .bar { width: 68%; }
.wd-label { margin-top: .45rem; font-size: .78rem; color: var(--a-muted); }

/* ---- Responsive ---- */
@media (max-width: 820px) {
    .stat-two { grid-template-columns: 1fr; }
    .admin-burger { display: block; }
    .admin-side { transform: translateX(-100%); transition: transform .25s; z-index: 40; }
    body.side-open .admin-side { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .a-grid-2 { grid-template-columns: 1fr; }
}

/* ---------- KI-Text-Panel ---------- */
.a-ai-panel { max-width: 820px; border-left: 3px solid var(--a-accent, #9a6a43); }
.a-ai-panel > .a-muted { margin-top: -.4rem; }
.a-ai-step { margin-top: 1.1rem; }
.a-ai-step > label { display: block; margin-bottom: .4rem; font-weight: 600; }
.a-ai-prompt, .a-ai-json { width: 100%; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: .82rem; line-height: 1.45; padding: .7rem .8rem; border: 1px solid var(--a-line);
    border-radius: 8px; background: var(--a-bg, #faf9f6); color: inherit; resize: vertical; }
.a-ai-prompt { white-space: pre-wrap; overflow-wrap: anywhere; }
.a-ai-row { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; margin-top: .5rem; }

/* Inline-KI-Widget direkt beim Beschreibungs-Feld */
.a-ai-inline { margin: -.6rem 0 1.5rem; border: 1px dashed color-mix(in srgb, var(--a-accent, #9a6a43) 55%, var(--a-line)); border-radius: 10px; background: var(--a-bg, #faf9f6); }
.a-ai-inline > summary { cursor: pointer; list-style: none; padding: .7rem .9rem; font-weight: 600; color: var(--a-accent, #9a6a43); user-select: none; }
.a-ai-inline > summary::-webkit-details-marker { display: none; }
.a-ai-inline[open] > summary { border-bottom: 1px solid var(--a-line); }
.a-ai-inline-body { padding: .2rem .9rem 1rem; }
.a-ai-inline-body > label { display: block; margin: .9rem 0 .35rem; font-weight: 600; font-size: .9rem; }
.a-ai-inline-body > p.a-muted:first-child { margin: .3rem 0 .2rem; }

/* ---------- Sammel-Aktionen (verschieben/kopieren/löschen) ---------- */
.a-bulkbar { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .8rem;
    background: var(--a-panel); border: 1px solid var(--a-line); border-radius: var(--a-radius);
    padding: .7rem .9rem; margin-bottom: 1rem; box-shadow: var(--a-shadow); }
.a-bulk-all { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; }
.a-bulk-count { font-size: .85rem; color: var(--a-muted, #8a8580); }
.a-bulk-spacer { flex: 1 1 auto; }
.a-bulk-sep { flex-basis: 100%; height: 0; margin: 0; }
.a-bulk-target { display: inline-flex; align-items: center; gap: .4rem; font-size: .88rem; }
.a-bulk-target select { padding: .4rem .6rem; border: 1px solid var(--a-line); border-radius: 8px; background: var(--a-bg, #faf9f6); color: inherit; font: inherit; }
.a-thumb { position: relative; }
.a-thumb-select { position: absolute; top: .5rem; left: .5rem; z-index: 4; display: grid; place-items: center;
    width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,.85); box-shadow: 0 1px 4px rgba(0,0,0,.2); cursor: pointer; }
.a-thumb-select input { width: 17px; height: 17px; cursor: pointer; accent-color: var(--a-accent, #9a6a43); }
.a-thumb:has([data-bulk-item]:checked) { outline: 2px solid var(--a-accent, #9a6a43); outline-offset: 2px; border-radius: 8px; }

/* ---------- Multiselect-Kategoriefilter ---------- */
.a-multiselect { position: relative; }
.a-ms-toggle { display: inline-flex; align-items: center; gap: .45rem; padding: .55rem .85rem;
    border: 1px solid var(--a-line); border-radius: 10px; background: var(--a-panel); color: inherit; font: inherit; cursor: pointer; }
.a-ms-toggle:hover { border-color: var(--a-accent, #9a6a43); }
.a-ms-cap { color: var(--a-muted, #8a8580); font-size: .85rem; }
.a-ms-label { font-weight: 600; }
.a-ms-chev { width: 16px; height: 16px; opacity: .7; }
.a-ms-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 250px; max-height: 340px; overflow-y: auto;
    background: var(--a-panel); border: 1px solid var(--a-line); border-radius: 12px; box-shadow: var(--a-shadow); padding: .4rem; }
.a-ms-opt { display: flex; align-items: center; gap: .55rem; padding: .5rem .6rem; border-radius: 8px; cursor: pointer; font-size: .92rem; }
.a-ms-opt:hover { background: var(--a-bg, #faf9f6); }
.a-ms-opt input { width: 16px; height: 16px; accent-color: var(--a-accent, #9a6a43); flex: none; }
.a-ms-name { flex: 1 1 auto; }
.a-ms-count { color: var(--a-muted, #8a8580); font-size: .78rem; background: var(--a-bg, #faf9f6); border-radius: 999px; padding: .05rem .5rem; }
.a-ms-opt-all { font-weight: 600; border-bottom: 1px solid var(--a-line); border-radius: 0; margin-bottom: .2rem; padding-bottom: .6rem; }
.a-thumbs-empty { padding: 2rem 0; text-align: center; }
@media (max-width: 620px) { .a-ms-menu { right: auto; left: 0; } }

/* ---------- Foto-Verwaltung je Werk ---------- */
.a-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .8rem; margin: .3rem 0 .6rem; }
.a-photo { border: 1px solid var(--a-line); border-radius: 10px; overflow: hidden; background: var(--a-panel); display: flex; flex-direction: column; }
.a-photo.is-main { border-color: var(--a-accent, #9a6a43); box-shadow: 0 0 0 1px var(--a-accent, #9a6a43); }
.a-photo img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; background: var(--a-bg, #faf9f6); }
.a-photo label { display: flex; align-items: center; gap: .4rem; padding: .4rem .55rem; font-size: .82rem; cursor: pointer; }
.a-photo-main { border-top: 1px solid var(--a-line); font-weight: 600; }
.a-photo-del { color: #b5382b; }
.a-photo input { accent-color: var(--a-accent, #9a6a43); }

/* ---------- Klickbare Werk-Kachel (Bearbeiten per Klick) ---------- */
.a-thumb-link { display: block; color: inherit; text-decoration: none; }
.a-thumb-link .a-thumb-img { position: relative; }
.a-thumb-edit { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(20,18,16,.42); color: #fff; font-weight: 600; letter-spacing: .02em; opacity: 0; transition: opacity .2s var(--a-ease, ease); }
.a-thumb-link:hover .a-thumb-edit { opacity: 1; }
.a-thumb-link:hover strong { color: var(--a-accent, #9a6a43); }

/* ---------- Sofort-Upload: Fortschrittsbalken ---------- */
.a-upbar { display: none; position: relative; height: 22px; margin: .5rem 0; border-radius: 999px; background: var(--a-bg, #f0eee9); overflow: hidden; border: 1px solid var(--a-line); }
.a-upbar-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--a-accent, #9a6a43), color-mix(in srgb, var(--a-accent,#9a6a43) 70%, #000)); transition: width .2s ease; }
.a-upbar-txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 600; color: var(--a-ink, #2a2723); }
.a-upbar.is-error { background: #fdece9; border-color: #e0b4ac; }
.a-upbar.is-error .a-upbar-fill { background: #b5382b; }
.a-photo.is-pending { outline: 2px dashed color-mix(in srgb, var(--a-accent,#9a6a43) 60%, var(--a-line)); }
.a-photo-remove { border: 0; background: none; color: #b5382b; cursor: pointer; font: inherit; padding: 0; }

/* ---------- Modal: ungespeicherte Änderungen ---------- */
.a-modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center;
    background: rgba(20,18,16,.55); backdrop-filter: blur(3px); padding: 1.5rem; }
.a-modal[hidden] { display: none; }
.a-modal-box { background: var(--a-panel, #fff); border-radius: 14px; box-shadow: 0 24px 70px rgba(0,0,0,.35);
    max-width: 460px; width: 100%; padding: 1.6rem 1.7rem; }
.a-modal-box h3 { margin: 0 0 .6rem; font-size: 1.25rem; }
.a-modal-box p { margin: 0 0 1.3rem; color: var(--a-ink-soft, #4a443c); line-height: 1.6; }
.a-modal-actions { display: flex; gap: .7rem; flex-wrap: wrap; justify-content: flex-end; }
