/* Globale Styles der Shell. Modul-Styles gehören in modules/<id>/public/style.css
   und sollten mit .m-<id> präfixiert sein. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ee;
  --text: #17212b;
  --muted: #64748b;
  --accent: #0f766e;
  --accent-2: #115e59;
  --accent-soft: #e6f4f2;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --ok: #15803d;
  --ok-soft: #e8f6ec;
  --sidebar: #13232e;
  --sidebar-text: #c9d6df;
  --sidebar-muted: #7f95a3;
  --sidebar-hover: #1d3441;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.18);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 15px; font-weight: 600; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Layout */
.layout { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 650; font-size: 15px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand small { display: block; font-weight: 400; color: var(--sidebar-muted); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 6px 10px; }
.nav-top { flex: 1; overflow-y: auto; }
.nav-bottom { border-top: 1px solid rgba(255,255,255,.07); padding-top: 8px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-muted); padding: 12px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--sidebar-text); text-decoration: none; }
.nav a:hover { background: var(--sidebar-hover); color: #fff; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a .err { margin-left: auto; color: #fca5a5; font-size: 12px; }
.user-box { display: flex; align-items: center; gap: 10px; padding: 12px 16px 16px; font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--sidebar-hover); display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 12px; }
.user-box .who { flex: 1; min-width: 0; }
.user-box .who div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-box .who small { color: var(--sidebar-muted); }
.icon-btn { background: none; border: 0; color: inherit; padding: 6px; border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--sidebar-hover); }
.main { overflow-y: auto; min-width: 0; }
.content { padding: 28px 32px 48px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head p { margin: 0; color: var(--muted); }
.mobile-bar { display: none; }

/* Bausteine */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.muted { color: var(--muted); }
.btn { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 550; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); border-color: var(--accent); }
label { display: block; font-weight: 550; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.empty { text-align: center; padding: 28px; color: var(--muted); }
.error-box { background: var(--danger-soft); color: var(--danger); padding: 12px 14px; border-radius: 8px; }

/* Kontextmenü */
.ctx-menu { position: fixed; z-index: 1000; min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; }
.ctx-menu button { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: 0; padding: 8px 10px; border-radius: 6px; font: inherit; color: var(--text); cursor: pointer; text-align: left; }
.ctx-menu button:hover { background: var(--accent-soft); color: var(--accent-2); }
.ctx-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }
.ctx-highlight { outline: 2px dashed var(--accent) !important; outline-offset: 2px; }

/* Dialog */
dialog.modal { border: 0; border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--text); }
dialog.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal-head { padding: 18px 22px 0; }
.modal-head p { margin: 4px 0 0; color: var(--muted); }
.modal-body { padding: 16px 22px; }
.modal-foot { padding: 14px 22px 18px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--border); }
.scope { display: flex; gap: 8px; flex-wrap: wrap; }
.scope label { flex: 1; min-width: 200px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; cursor: pointer; font-weight: 400; }
.scope label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.scope input { width: auto; margin-top: 3px; }
.scope b { display: block; font-weight: 600; }
.element-chip { font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-family: ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; }

/* Bilder im Bearbeiten-Dialog */
.dropzone { display: flex; align-items: center; gap: 10px; border: 1.5px dashed var(--border); border-radius: 9px; padding: 12px 14px; color: var(--muted); cursor: pointer; background: var(--surface-2); }
.dropzone:hover, .dropzone:focus, .dropzone.over { border-color: var(--accent); color: var(--accent-2); background: var(--accent-soft); outline: none; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; margin: 0; width: 96px; }
.thumb img { width: 96px; height: 72px; object-fit: cover; border-radius: 7px; border: 1px solid var(--border); display: block; }
.thumb figcaption { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(15,23,42,.75); color: #fff; display: grid; place-items: center; cursor: pointer; padding: 0; }
.thumb button .icon { width: 12px; height: 12px; }
.job-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.job-thumbs img { width: 56px; height: 42px; object-fit: cover; border-radius: 5px; border: 1px solid var(--border); }

/* KI-Job-Panel */
.job-panel { position: fixed; right: 20px; bottom: 20px; z-index: 900; width: min(440px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.job-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.job-head b { flex: 1; }
.job-log { max-height: 260px; overflow-y: auto; padding: 8px 14px; font-size: 12.5px; }
.job-log div { padding: 3px 0; border-bottom: 1px dashed var(--border); word-break: break-word; }
.job-log div:last-child { border: 0; }
.job-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface-2); }
.job-panel.collapsed .job-log, .job-panel.collapsed .job-foot { display: none; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toasts */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 1100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 380px; }
.toast.error { background: var(--danger); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #13232e 0%, #1c3a44 55%, #0f766e 140%); }
.login-card { width: min(400px, 100%); background: var(--surface); border-radius: 14px; padding: 30px; box-shadow: var(--shadow-lg); }
.login-card .brand { color: var(--text); padding: 0 0 18px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 950; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .mobile-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--sidebar); color: #fff; }
  .content { padding: 20px 16px 40px; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
