:root {
  color-scheme: dark;
  --bg: #07090c;
  --panel: #0c1015;
  --panel-2: #11161d;
  --line: #242b35;
  --line-strong: #384252;
  --text: #f7f9fc;
  --muted: #8f9aa9;
  --subtle: #606b7a;
  --green: #4ade80;
  --blue: #60a5fa;
  --amber: #fbbf24;
  --orange: #fb923c;
  --red: #f05252;
  --radius: 12px;
  --shadow: 0 20px 70px rgb(0 0 0 / .48);
  font-family: "Segoe UI", Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--blue); }
img { display: block; }
code, kbd { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 7px; color: var(--muted); font-size: .72rem; font-weight: 750; letter-spacing: .15em; }

/* Anmeldung und Setup */
.auth-body { display: grid; place-items: center; min-height: 100dvh; padding: 28px; background: #07090c; }
.auth-shell { width: min(470px, 100%); }
.setup-shell { width: min(660px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 16px; margin: 0 0 28px; }
.auth-brand strong { display: block; font-size: 1.65rem; letter-spacing: .08em; }
.auth-brand span { display: block; margin-top: 2px; color: var(--muted); }
.auth-card { padding: 34px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); box-shadow: var(--shadow); }
.auth-card h1 { margin: 0 0 12px; font-size: 2rem; letter-spacing: -.03em; }
.security-note { margin: 22px 0 0; color: var(--subtle); font-size: .82rem; line-height: 1.5; }
.stack-form { display: grid; gap: 17px; margin-top: 26px; }
.stack-form label, .form-grid label, .admin-form label { display: grid; gap: 7px; color: #bdc6d2; font-size: .84rem; font-weight: 650; }
input, textarea, select { width: 100%; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 8px; outline: none; background: #080b10; color: var(--text); padding: 10px 12px; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(96 165 250 / .13); }
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--green); padding: 0; }
.check-label { display: flex !important; align-items: center; gap: 10px !important; cursor: pointer; }
.form-grid { display: grid; gap: 15px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.alert { border: 1px solid; border-radius: 8px; padding: 12px 14px; margin: 17px 0; line-height: 1.45; font-size: .9rem; }
.alert-error { border-color: rgb(240 82 82 / .45); background: rgb(240 82 82 / .08); color: #fecaca; }
.alert-success { border-color: rgb(74 222 128 / .4); background: rgb(74 222 128 / .08); color: #bbf7d0; }

.primary-button, .secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 44px; border: 1px solid transparent; border-radius: 8px; padding: 10px 17px; cursor: pointer; font-weight: 750; text-decoration: none; transition: background-color .12s ease, border-color .12s ease, transform .12s ease; }
.primary-button { background: var(--text); color: #080a0d; }
.primary-button:hover { background: #dfe5ed; }
.primary-button:active, .secondary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .4; cursor: not-allowed; }
.secondary-button { border-color: var(--line-strong); background: #10151c; color: var(--text); }
.secondary-button:hover { border-color: #586477; background: #151b23; }
.danger-button { border-color: rgb(240 82 82 / .5); background: rgb(240 82 82 / .08); color: #fecaca; }

/* 1080p Dashboard */
.dashboard-body { height: 100dvh; overflow: hidden; }
.dashboard-shell { display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; gap: 14px; height: 100dvh; min-height: 680px; padding: 22px 28px 15px; }
.dashboard-header { display: flex; align-items: flex-start; justify-content: space-between; min-height: 84px; }
.brand-block { display: flex; align-items: center; gap: 36px; }
.brand-line { display: flex; align-items: center; gap: 13px; }
.brand-line strong { font-size: 1.55rem; letter-spacing: .12em; }
.clock-line { display: flex; align-items: baseline; gap: 18px; border-left: 1px solid var(--line); padding-left: 35px; }
#clock { font-size: clamp(2.55rem, 3.1vw, 3.65rem); font-variant-numeric: tabular-nums; font-weight: 720; line-height: 1; letter-spacing: -.045em; }
#date { color: #b3bdca; font-size: 1.12rem; text-transform: capitalize; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.source-statuses { display: flex; align-items: center; gap: 19px; margin-right: 12px; min-height: 42px; }
.source-status { display: flex; align-items: center; gap: 8px; color: #aeb8c5; font-size: .84rem; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgb(251 191 36 / .1); flex: 0 0 auto; }
.ok .status-dot, .status-dot.ok { background: var(--green); box-shadow: 0 0 0 3px rgb(74 222 128 / .1); }
.error .status-dot, .status-dot.error { background: var(--red); box-shadow: 0 0 0 3px rgb(240 82 82 / .1); }
.icon-button { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); cursor: pointer; }
.icon-button:hover { border-color: var(--line-strong); background: var(--panel-2); }
.sync-strip { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; background: #0a0d11; color: #b8c1cc; text-align: left; cursor: pointer; font-size: .88rem; }
.sync-strip.problem { border-color: rgb(240 82 82 / .36); background: rgb(240 82 82 / .05); color: #fecaca; }
#sync-age { margin-left: auto; color: var(--subtle); font-size: .82rem; }
.view-tabs { display: flex; align-items: center; gap: 4px; min-height: 44px; border-bottom: 1px solid var(--line); }
.view-tabs > button { align-self: stretch; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); padding: 0 17px; cursor: pointer; font-size: .88rem; font-weight: 700; }
.view-tabs > button:hover { color: var(--text); }
.view-tabs > button.active { border-bottom-color: var(--text); color: var(--text); }
.search-field { width: 240px; margin-left: auto; }
.search-field input { min-height: 36px; height: 36px; border: 0; border-radius: 6px; background: #0d1116; font-size: .88rem; }
.dashboard-main { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr); gap: 20px; min-height: 0; }
.todo-panel, .overview-panel { min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.todo-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); padding: 22px 22px 13px; }
.overview-panel { padding: 25px 24px 21px; overflow: auto; }
.section-heading { display: flex; align-items: end; justify-content: space-between; padding: 0 5px 18px; }
.section-heading h1, .overview-panel h2 { margin: 0; font-size: 1.72rem; letter-spacing: .03em; }
#open-label { color: var(--muted); font-size: .82rem; letter-spacing: .1em; }
.todo-list { min-height: 0; overflow-y: auto; scrollbar-color: #303846 transparent; scrollbar-width: thin; padding-right: 6px; }
.todo-row { position: relative; display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 15px; min-height: 100px; border-top: 1px solid var(--line); padding: 14px 13px 14px 6px; cursor: pointer; }
.todo-row:first-child { border-top-color: var(--line-strong); }
.todo-row:hover { background: #10151b; }
.todo-row.overdue { box-shadow: inset 3px 0 0 var(--red); }
.todo-row.urgent { box-shadow: inset 3px 0 0 var(--red); }
.todo-row.high:not(.overdue) { box-shadow: inset 3px 0 0 var(--amber); }
.todo-check { display: grid; place-items: center; width: 40px; height: 40px; border: 2px solid #6b7686; border-radius: 10px; background: transparent; cursor: pointer; }
.todo-check:hover { border-color: var(--green); background: rgb(74 222 128 / .07); }
.todo-check::after { content: ""; width: 15px; height: 8px; border-left: 2px solid transparent; border-bottom: 2px solid transparent; transform: rotate(-45deg) translateY(-2px); }
.todo-check:hover::after { border-color: var(--green); }
.todo-content { min-width: 0; }
.todo-topline { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.source-badge { display: inline-flex; align-items: center; min-height: 24px; border: 1px solid #3a4553; border-radius: 5px; padding: 3px 8px; color: #cad2dc; font-size: .7rem; font-weight: 800; letter-spacing: .075em; text-transform: uppercase; }
.source-badge.zammad { border-color: rgb(96 165 250 / .45); background: rgb(96 165 250 / .08); color: #bfdbfe; }
.source-badge.email { border-color: rgb(167 139 250 / .38); color: #ddd6fe; }
.source-badge.recurring { border-color: rgb(74 222 128 / .35); color: #bbf7d0; }
.review-badge { color: var(--amber); font-size: .76rem; font-weight: 700; }
.todo-title { overflow: hidden; color: var(--text); font-size: 1.25rem; font-weight: 650; line-height: 1.28; text-overflow: ellipsis; white-space: nowrap; }
.todo-meta { display: flex; flex-wrap: wrap; gap: 8px 15px; color: var(--muted); font-size: .84rem; }
.todo-meta span { display: inline-flex; align-items: center; }
.todo-meta span + span::before { content: "·"; margin-right: 13px; color: #424b58; }
.todo-due { min-width: 140px; text-align: right; }
.todo-due strong { display: block; font-size: .96rem; font-variant-numeric: tabular-nums; }
.todo-due span { display: block; margin-top: 5px; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.todo-row.overdue .todo-due strong, .todo-row.urgent .priority-label { color: var(--red); }
.todo-row.high .priority-label { color: var(--amber); }
.empty-state, .loading-state { display: grid; place-items: center; min-height: 180px; color: var(--muted); text-align: center; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 24px 0; }
.metric-grid > div { min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 16px 10px; background: #090c10; }
.metric-grid strong { display: block; font-size: clamp(1.5rem, 2.1vw, 2.25rem); line-height: 1; font-variant-numeric: tabular-nums; }
.metric-grid span { display: block; margin-top: 8px; color: var(--muted); font-size: .75rem; }
.urgent-metric strong { color: var(--red); }
.source-counts { display: grid; gap: 2px; margin: 0 0 24px; }
.source-count { display: flex; justify-content: space-between; border-bottom: 1px solid #1d232c; padding: 11px 2px; color: #bac3ce; font-size: .9rem; }
.source-count strong { color: var(--text); }
.add-button { width: 100%; min-height: 58px; font-size: 1rem; }
.add-button kbd { margin-left: auto; border: 1px solid #aeb5bf; border-radius: 4px; padding: 1px 6px; color: #4b5563; font-size: .7rem; }
.sound-button { width: 100%; min-height: 48px; margin-top: 9px; color: var(--muted); }
.activity-footer { display: flex; align-items: center; gap: 10px; min-height: 30px; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.activity-pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.footer-spacer { flex: 1; }
#speaker-status { border-left: 1px solid var(--line); padding-left: 12px; }
.mobile-add { display: none; }

/* Dialoge und Toast */
.modal { width: min(680px, calc(100vw - 30px)); max-height: calc(100dvh - 30px); border: 0; padding: 0; background: transparent; color: var(--text); }
.modal::backdrop { background: rgb(0 0 0 / .72); backdrop-filter: none; }
.modal-card { display: grid; gap: 20px; max-height: calc(100dvh - 30px); overflow: auto; border: 1px solid var(--line-strong); border-radius: 14px; padding: 25px; background: #0d1117; box-shadow: var(--shadow); }
.modal-card > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.modal-card h2 { margin: 0; font-size: 1.45rem; }
.modal-card > footer { display: flex; justify-content: flex-end; gap: 10px; }
.close-button { width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; font-size: 1.6rem; line-height: 1; }
.hero-input textarea { font-size: 1.15rem; }
.multiline-option { margin-top: -8px; }
details { border-top: 1px solid var(--line); padding-top: 13px; }
summary { color: #bdc6d2; cursor: pointer; font-weight: 650; }
details[open] summary { margin-bottom: 16px; }
.detail-description { margin: 0; color: #c2cad5; line-height: 1.6; white-space: pre-wrap; }
.detail-meta { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.detail-meta dt { color: var(--muted); }
.detail-meta dd { margin: 0; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.quick-actions button { border: 1px solid var(--line); border-radius: 7px; background: #111721; padding: 8px 11px; cursor: pointer; color: #c8d0db; }
.quick-actions input { min-height: 37px; width: auto; }
.detail-footer span { flex: 1; }
.compact-card { min-height: 220px; }
.status-list { display: grid; gap: 8px; }
.status-list > div { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 10px; border-bottom: 1px solid var(--line); padding: 9px 0; }
.status-list small { display: block; margin-top: 3px; color: var(--muted); }
.toast-region { position: fixed; z-index: 20; top: 18px; right: 18px; display: grid; gap: 9px; width: min(370px, calc(100vw - 36px)); pointer-events: none; }
.toast { border: 1px solid var(--line-strong); border-left: 3px solid var(--green); border-radius: 9px; padding: 13px 15px; background: #11161d; box-shadow: 0 15px 40px rgb(0 0 0 / .4); animation: toast-in .18s ease-out; pointer-events: auto; }
.toast.error { border-left-color: var(--red); }
.toast strong { display: block; margin-bottom: 3px; }
.toast span { color: var(--muted); font-size: .83rem; }
.toast button { float: right; border: 0; background: transparent; color: var(--green); cursor: pointer; font-weight: 750; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

.error-page { display: grid; place-items: center; min-height: 100dvh; text-align: center; }
.dashboard-body.quiet-dimmed .dashboard-shell { filter: brightness(.58); }

/* Admin */
.admin-body { min-height: 100dvh; }
.admin-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100dvh; }
.admin-sidebar { position: sticky; top: 0; align-self: start; height: 100dvh; border-right: 1px solid var(--line); padding: 25px 18px; background: #090c10; }
.admin-logo { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; font-weight: 800; letter-spacing: .08em; }
.admin-nav { display: grid; gap: 3px; margin-top: 30px; }
.admin-nav a { border-radius: 7px; padding: 9px 11px; color: var(--muted); text-decoration: none; font-size: .86rem; }
.admin-nav a:hover { background: var(--panel-2); color: var(--text); }
.admin-sidebar footer { position: absolute; bottom: 20px; left: 18px; right: 18px; }
.admin-sidebar form button { width: 100%; }
.admin-main { min-width: 0; padding: 28px clamp(22px, 3vw, 52px) 70px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.admin-header h1 { margin: 0; font-size: 2rem; }
.admin-header p { margin: 5px 0 0; color: var(--muted); }
.admin-section { scroll-margin-top: 20px; margin: 0 0 35px; }
.admin-section > h2 { margin: 0 0 15px; font-size: 1.25rem; }
.admin-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.admin-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.admin-card { min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 18px; background: var(--panel); }
.admin-card h3 { margin: 0 0 12px; font-size: 1rem; }
.admin-card p { color: var(--muted); }
.big-number { font-size: 2.3rem; font-weight: 720; }
.admin-form { display: grid; gap: 14px; }
.admin-form .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.admin-form textarea { min-height: 95px; }
.connection-card { margin-top: 12px; }
.connection-head { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
.connection-head h3 { margin: 0; }
.connection-head .status-dot { margin-left: auto; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 3px 8px; color: var(--muted); font-size: .68rem; }
.diagnostic-list { display: grid; gap: 0; }
.diagnostic-row { display: grid; grid-template-columns: 12px minmax(140px, .7fr) minmax(160px, 1fr) minmax(200px, 1.4fr); align-items: center; gap: 10px; border-bottom: 1px solid var(--line); padding: 10px 0; font-size: .82rem; }
.diagnostic-row .hint { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 8px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 650; }
.inline-form { display: inline-flex; gap: 6px; }
.code-box { display: block; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 7px; padding: 10px; background: #07090c; color: #bdc6d2; font-size: .75rem; }

@media (max-width: 1100px) {
  .dashboard-main { grid-template-columns: minmax(0, 1fr) 290px; }
  #date { display: none; }
  .source-statuses { gap: 10px; }
  .source-status span { display: none; }
  .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .auth-body { align-items: start; padding: 18px; }
  .auth-card { padding: 23px 19px; }
  .form-grid.two { grid-template-columns: 1fr; }
  .dashboard-body { height: auto; min-height: 100dvh; overflow: auto; }
  .dashboard-shell { display: block; height: auto; min-height: 100dvh; padding: 16px 14px 90px; }
  .dashboard-header { align-items: center; min-height: auto; margin-bottom: 14px; }
  .brand-block { gap: 0; }
  .brand-line strong { font-size: 1.15rem; }
  .brand-line img { width: 31px; height: 31px; }
  .clock-line { border: 0; padding-left: 16px; }
  #clock { font-size: 1.7rem; }
  #date, .source-statuses, #fullscreen-button { display: none; }
  .sync-strip { margin-bottom: 11px; }
  .view-tabs { overflow-x: auto; margin-bottom: 13px; }
  .view-tabs > button { flex: 0 0 auto; min-height: 42px; padding: 0 11px; }
  .search-field { display: none; }
  .dashboard-main { display: block; }
  .todo-panel { min-height: 55dvh; padding: 17px 11px 9px; }
  .overview-panel { margin-top: 13px; padding: 19px 17px; }
  .todo-list { overflow: visible; }
  .todo-row { grid-template-columns: 48px minmax(0, 1fr); gap: 11px; min-height: 106px; padding: 14px 4px 14px 3px; }
  .todo-due { grid-column: 2; min-width: 0; text-align: left; margin-top: -5px; }
  .todo-due strong, .todo-due span { display: inline; margin: 0 8px 0 0; }
  .todo-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .activity-footer { display: none; }
  .mobile-add { position: fixed; z-index: 15; right: 19px; bottom: calc(19px + env(safe-area-inset-bottom)); display: grid; place-items: center; width: 62px; height: 62px; border: 0; border-radius: 50%; background: var(--text); color: #07090c; box-shadow: 0 12px 35px rgb(0 0 0 / .55); }
  .modal-card { padding: 20px 16px; border-radius: 12px; }
  .detail-footer { flex-wrap: wrap; }
  .detail-footer span { display: none; }
  .detail-footer button { flex: 1 1 100px; }
  .admin-shell { display: block; }
  .admin-sidebar { position: static; width: 100%; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-nav { display: flex; overflow-x: auto; margin-top: 17px; }
  .admin-nav a { flex: 0 0 auto; }
  .admin-sidebar footer { position: static; margin-top: 15px; }
  .admin-main { padding: 22px 14px 60px; }
  .admin-grid, .admin-grid.two { grid-template-columns: 1fr; }
  .diagnostic-row { grid-template-columns: 12px 1fr; }
  .diagnostic-row .value, .diagnostic-row .hint { grid-column: 2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
