/* Groupware.Connector – angelehnt an das LotzApp-Redesign (Orange → Rot). Dark Mode folgt dem Browser. */

@font-face { font-family: 'Source Sans 3'; src: url('../fonts/SourceSans3-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Source Sans 3'; src: url('../fonts/SourceSans3-Semibold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Source Sans 3'; src: url('../fonts/SourceSans3-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Poppins'; src: url('../fonts/Poppins-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Poppins'; src: url('../fonts/Poppins-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  color-scheme: light dark;
  --brand: #E7501C;
  --brand-2: #C01C1E;
  --brand-gradient: linear-gradient(100deg, #E7501C 0%, #E7501C 20%, #C01C1E 100%);
  --accent: #C63F2A;
  --accent-hover: #A9321F;
  --accent-text: #C63F2A;
  --accent-soft: #FDE8DD;
  --accent-tint: #fdf6f2;

  --bg: #f3f3f4;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eef0f2;
  --hover: #fbefe8;
  --border: #dcdfe3;
  --border-strong: #c9ccd1;
  --input-border: #a5a9b0;
  --text: #1d1d1b;
  --text-muted: #5f5f66;
  --text-soft: #7a7a82;

  --side-bg: #24262b;
  --side-text: #c9ccd2;
  --side-text-strong: #ffffff;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(231, 80, 28, .16);

  --ok: #2a7a2a;      --ok-bg: #ddf6dd;      --ok-border: #9fd39f;
  --err: #b8330f;     --err-bg: #fdeceb;     --err-border: #e8b2a4;
  --warn: #7a5c00;    --warn-bg: #fff6dc;    --warn-border: #e2c65a;
  --info: #1e56ad;    --info-bg: #e3edfb;    --info-border: #a9c3ea;
  --mute: #5f5f66;    --mute-bg: #eceef1;    --mute-border: #d2d6db;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 4px 14px -6px rgba(20, 20, 20, .12);
  --shadow-lg: 0 12px 40px -12px rgba(20, 20, 20, .28);
  --font: 'Source Sans 3', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-ui: 'Poppins', var(--font);
  --mono: ui-monospace, 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
  --side-w: 248px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #E25A33;
    --accent-hover: #F2794F;
    --accent-text: #F2794F;
    --accent-soft: #4A2F25;
    --accent-tint: #2c221e;

    --bg: #16191d;
    --surface: #1f2328;
    --surface-2: #262b31;
    --surface-3: #2c3239;
    --hover: #33261f;
    --border: #343b43;
    --border-strong: #46505a;
    --input-border: #5a646f;
    --text: #e8eaed;
    --text-muted: #a9b1ba;
    --text-soft: #858e98;

    --side-bg: #111316;
    --side-text: #a9b1ba;
    --side-hover: rgba(255, 255, 255, .05);
    --side-active: rgba(242, 121, 79, .14);

    --ok: #7fd18b;      --ok-bg: #1f3a27;      --ok-border: #2f5a3b;
    --err: #ff8f6b;     --err-bg: #3f2320;     --err-border: #6a3328;
    --warn: #f0cf6a;    --warn-bg: #37321f;    --warn-border: #5f5426;
    --info: #8db8f2;    --info-bg: #1e2c40;    --info-border: #2f4767;
    --mute: #a9b1ba;    --mute-bg: #2a2f36;    --mute-border: #3a4149;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px -6px rgba(0, 0, 0, .5);
    --shadow-lg: 0 12px 40px -12px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-ui); font-weight: 600; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .95rem; }
code, pre, .mono { font-family: var(--mono); font-size: .86em; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }
[hidden] { display: none !important; }
.minw0 { min-width: 0; }
.op75 { opacity: .75; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.mt16 { margin-top: 16px; }
.narrow { max-width: 560px; }
.err-title { margin: 12px 0 6px; }
.copied { color: var(--ok) !important; border-color: var(--ok) !important; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.stat .value.small-value { font-size: 1.15rem; margin-top: 10px; }
details { display: inline-block; position: relative; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.user-edit { position: absolute; right: 0; top: calc(100% + 6px); width: 280px; z-index: 20; text-align: left; box-shadow: var(--shadow-lg); }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side {
  background: var(--side-bg); color: var(--side-text); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; border-right: 1px solid rgba(255, 255, 255, .04);
}
.side::before { content: ""; height: 4px; background: var(--brand-gradient); flex: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; color: var(--side-text-strong); }
.brand img { height: 34px; width: auto; }
.brand b { font-family: var(--font-ui); font-weight: 600; font-size: 1.02rem; display: block; line-height: 1.15; }
.brand span { font-size: .78rem; color: var(--side-text); letter-spacing: .04em; text-transform: uppercase; }
.brand:hover { text-decoration: none; }
.nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-soft); padding: 16px 12px 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 8px; color: var(--side-text);
  font-weight: 600; font-size: .95rem; position: relative;
}
.nav a:hover { background: var(--side-hover); color: var(--side-text-strong); text-decoration: none; }
.nav a.active { background: var(--side-active); color: var(--side-text-strong); }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-gradient); }
.nav a.active .icon { color: var(--brand); }
.side-foot { margin-top: auto; padding: 14px 16px 18px; border-top: 1px solid rgba(255, 255, 255, .06); }
.me { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-gradient); color: #fff; flex: none;
  display: grid; place-items: center; font-family: var(--font-ui); font-weight: 600; font-size: .85rem;
}
.me-name { color: var(--side-text-strong); font-weight: 600; font-size: .92rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { font-size: .78rem; }
.me form { margin-left: auto; }
.icon-btn {
  background: transparent; border: 0; color: inherit; padding: 6px; border-radius: 6px; cursor: pointer; display: inline-grid; place-items: center;
}
.icon-btn:hover { background: var(--side-hover); color: var(--side-text-strong); }
.version { font-size: .74rem; color: var(--text-soft); margin-top: 10px; }

.main { min-width: 0; padding: 28px 36px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .grow p { margin: 4px 0 0; }
.crumbs { font-size: .85rem; color: var(--text-muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.crumbs a { color: var(--text-muted); }

/* ---------- Karten ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { flex: 1; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }

.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat .label { color: var(--text-muted); font-size: .85rem; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.stat .value { font-family: var(--font-ui); font-size: 1.9rem; font-weight: 600; margin-top: 4px; line-height: 1.1; }
.stat.ok .value { color: var(--ok); }
.stat.err .value { color: var(--err); }
.stat.brand::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--brand-gradient); }

.job-card { display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; transition: border-color .15s, transform .15s; color: inherit; }
.job-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.job-card .top { display: flex; gap: 10px; align-items: flex-start; }
.job-card h3 { font-size: 1rem; flex: 1; }
.job-card .meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--text-muted); }
.job-card .meta span { display: inline-flex; gap: 5px; align-items: center; }
.job-card .meta .icon { width: 15px; height: 15px; }
.spark { display: flex; gap: 6px; }

.type-tile { display: flex; gap: 14px; padding: 18px; align-items: flex-start; color: inherit; }
.type-tile:hover { border-color: var(--accent); text-decoration: none; }
.type-tile .ico { width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; flex: none; }
.type-tile p { margin: 4px 0 0; color: var(--text-muted); font-size: .92rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: .78rem;
  font-weight: 600; border: 1px solid var(--mute-border); background: var(--mute-bg); color: var(--mute); white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.success, .badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.badge.failed, .badge.err { background: var(--err-bg); color: var(--err); border-color: var(--err-border); }
.badge.skipped { background: var(--mute-bg); color: var(--mute); }
.badge.running, .badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.badge.running::before { animation: pulse 1.2s ease-in-out infinite; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.badge.brand { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
@keyframes pulse { 50% { opacity: .25; } }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--mute-border); flex: none; }
.dot.ok { background: var(--ok); } .dot.err { background: var(--err); } .dot.off { background: var(--text-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--radius-sm); font: inherit;
  font-weight: 600; font-size: .92rem; cursor: pointer; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); text-decoration: none; line-height: 1.2; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--hover); border-color: var(--accent); text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--brand-gradient); border-color: transparent; color: #fff; box-shadow: 0 2px 8px -3px rgba(192, 28, 30, .55); }
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; filter: brightness(1.05); }
.btn-danger { color: var(--err); border-color: var(--err-border); }
.btn-danger:hover { background: var(--err-bg); border-color: var(--err); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: .84rem; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }
form.inline { display: inline; }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 600; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--hover); }
td .sub { display: block; font-size: .84rem; color: var(--text-muted); }
.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); }
.empty .icon { width: 36px; height: 36px; color: var(--text-soft); margin-bottom: 8px; }

/* ---------- Formulare ---------- */
.form-section { padding: 18px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; }
.form-section > h3 { margin-bottom: 14px; color: var(--accent-text); font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label, .field > .label { font-weight: 600; font-size: .9rem; }
.field .help { font-size: .82rem; color: var(--text-muted); }
.req { color: var(--accent-text); }
input[type=text], input[type=url], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--input-border);
  border-radius: var(--radius-sm); padding: 8px 10px; min-height: 38px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled { opacity: .6; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-weight: 600; font-size: .92rem; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.check .help { font-weight: 400; display: block; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; }
.switch input { appearance: none; width: 40px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked { background: var(--brand-gradient); }
.switch input:checked::after { transform: translateX(18px); }
.secret-state { font-size: .82rem; display: flex; gap: 12px; align-items: center; }
.lookup { display: flex; gap: 6px; }
.lookup > select, .lookup > input { flex: 1; min-width: 0; }
.lookup .icon-btn { color: var(--text-muted); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); width: 38px; }
.lookup .icon-btn:hover { color: var(--accent-text); background: var(--hover); }
.lookup-msg { font-size: .8rem; color: var(--err); }
.pairs table { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.pairs th, .pairs td { padding: 6px 8px; }
.pairs td:last-child, .pairs th:last-child { width: 44px; text-align: center; }
.pairs .arrow { width: 26px; text-align: center; color: var(--text-soft); }
.form-actions { display: flex; gap: 10px; padding: 16px 18px; background: var(--surface-2); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); position: sticky; bottom: 0; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg label { padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: .9rem; border-right: 1px solid var(--border-strong); }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--accent-soft); color: var(--accent-text); }

/* ---------- Meldungen ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid; display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-border); }
.alert.error { background: var(--err-bg); color: var(--err); border-color: var(--err-border); }
.alert.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.alert.info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.alert ul { margin: 0; padding-left: 18px; }

/* ---------- Webhook-URLs ---------- */
.hook { display: flex; flex-direction: column; gap: 4px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.hook:last-child { border-bottom: 0; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-family: var(--mono); font-size: .82rem; background: var(--surface-2); }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
dl.kv dt { color: var(--text-muted); font-size: .9rem; }
dl.kv dd { margin: 0; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }

/* ---------- Filter / Pagination ---------- */
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: .85rem; font-weight: 600; color: var(--text-muted); background: var(--surface); }
.chip:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.chip.active { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); font-size: .9rem; }

/* ---------- Log-Viewer ---------- */
.log { font-family: var(--mono); font-size: .83rem; background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); max-height: 70vh; overflow: auto; }
.log-line { display: grid; grid-template-columns: 92px 70px 1fr; gap: 12px; padding: 5px 16px; border-bottom: 1px solid var(--border); align-items: baseline; }
.log-line:last-child { border-bottom: 0; }
.log-line .ts { color: var(--text-soft); }
.log-line .lvl { font-weight: 700; font-size: .74rem; letter-spacing: .04em; }
.log-line .msg { white-space: pre-wrap; overflow-wrap: anywhere; }
.log-line.DEBUG { color: var(--text-muted); }
.log-line.DEBUG .lvl { color: var(--text-soft); }
.log-line.INFO .lvl { color: var(--info); }
.log-line.WARNING { background: var(--warn-bg); }
.log-line.WARNING .lvl { color: var(--warn); }
.log-line.ERROR { background: var(--err-bg); }
.log-line.ERROR .lvl, .log-line.ERROR .msg { color: var(--err); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-art { background: var(--brand-gradient); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(255, 255, 255, .08); }
.login-art h1 { font-size: 2.3rem; max-width: 12ch; }
.login-art p { opacity: .9; max-width: 38ch; font-size: 1.05rem; }
.login-art .logo { height: 72px; width: auto; align-self: flex-start; filter: brightness(0) invert(1); }
.login-box { display: grid; place-items: center; padding: 40px 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 1.5rem; margin-bottom: 6px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-soft); font-size: .85rem; margin: 20px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.btn-block { width: 100%; justify-content: center; padding: 11px 14px; }

/* ---------- Responsiv ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label { display: none; }
  .side-foot { display: none; }
  .main { padding: 20px 16px 40px; }
  .fields, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .log-line { grid-template-columns: 1fr; gap: 2px; }
}
