/* Toolbase – Oberfläche
 * Gestaltung angelehnt an cybox-marketing.de: Anthrazit, Orange als Akzent,
 * fette Großbuchstaben-Überschriften, pillenförmige Buttons.
 */
:root {
  --ink: #1e2a33;          /* Anthrazit: Kopfzeile, dunkle Flächen, Überschriften */
  --ink-2: #2c3a45;
  --ink-3: #46555f;
  --accent: #f39200;       /* Orange */
  --accent-2: #f7b32b;
  --accent-soft: #fff3e0;
  --bg: #f3f4f5;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --text: #1e2a33;
  --muted: #6a737b;
  --line: #e1e4e7;
  --link: #c97600;
  --ok: #2f7d4f;
  --ok-bg: #e7f4ec;
  --off: #a2410f;
  --off-bg: #fdeee4;
  --danger: #b4231b;
  --warning-bg: #fff5e3;
  --warning-line: #f6c97a;
  --info-bg: #eef2f5;
  --info-line: #c9d3db;
  --error-bg: #fdeceb;
  --error-line: #f2bab6;
  --success-bg: #e7f4ec;
  --success-line: #b5dcc3;
  --radius: 10px;
  --sidebar: 272px;
  --topbar: 56px;
  --font: "Ubuntu", "Open Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.55 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; }
h1 { font-size: 1.6rem; font-weight: 800; text-transform: uppercase; letter-spacing: .01em; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; margin: 0 0 .9rem; }
h3 { font-size: 1rem; font-weight: 700; margin: 1.5rem 0 .5rem; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--surface-2); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); }
code.secret { font-size: 1.05rem; padding: 3px 8px; user-select: all; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
::selection { background: var(--accent); color: #fff; }

/* Orangefarbene Unterstreichung wie bei "ERREICHEN." */
.marker {
  background: linear-gradient(transparent 68%, var(--accent) 68%, var(--accent-2) 92%, transparent 92%);
  padding: 0 .08em; border-radius: 2px;
}
.accent-text { color: var(--accent); }

/* Kopfzeile */
.topbar {
  height: var(--topbar); display: flex; align-items: center; gap: 28px;
  padding: 0 24px; color: #fff;
  background: linear-gradient(90deg, #17222a, var(--ink) 55%, var(--ink-2));
  border-bottom: 2px solid var(--accent);
  position: sticky; top: 0; z-index: 20;
}
.topbar a { color: rgba(255, 255, 255, .85); }
.topbar a:hover { color: #fff; text-decoration: none; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff !important; }
.brand-mark { display: none; }
.brand-name { font-weight: 500; font-size: 1.15rem; letter-spacing: .32em; text-transform: uppercase; }
.topnav { display: flex; gap: 4px; }
.topnav a { padding: 6px 12px; font-size: .88rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 400; }
.topnav a[aria-current="page"] { color: var(--accent); }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: 18px; font-size: .9rem; }
.topbar-user a[aria-current="page"] { color: var(--accent); }
.topbar .link { color: rgba(255, 255, 255, .85); text-transform: uppercase; font-size: .82rem; letter-spacing: .04em; }
.topbar .link:hover { color: var(--accent); text-decoration: none; }

/* Seiten */
.page { max-width: 1100px; margin: 0 auto; padding: 32px 24px 64px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(30, 42, 51, .04); }
.card.flush { padding: 0; overflow-x: auto; }
.card.narrow { max-width: 560px; margin: 40px auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
.head-actions { display: flex; gap: 16px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.grid-2 > .card { margin-bottom: 0; }

/* Anmeldung: dunkle Fläche mit weichen Wellen */
body.bare {
  background:
    radial-gradient(ellipse 70% 45% at 22% 62%, rgba(255, 255, 255, .07), transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 42%, rgba(255, 255, 255, .06), transparent 70%),
    radial-gradient(ellipse 90% 60% at 85% 10%, rgba(120, 140, 150, .25), transparent 60%),
    linear-gradient(160deg, #141e25 0%, var(--ink) 45%, #3c4a54 100%);
  border-top: 3px solid var(--accent);
}
.bare-main { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; padding: 32px; border: 0; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.auth-card h1 { font-size: 1.7rem; margin-bottom: 1.2rem; }
.auth-brand { display: block; margin-bottom: 22px; font-weight: 500; font-size: 1.05rem; letter-spacing: .32em; text-transform: uppercase; color: var(--ink); }
.auth-brand .brand-mark { display: none; }

/* Administration */
.admin-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - var(--topbar)); }
.admin-nav { background: var(--surface); border-right: 1px solid var(--line); padding: 24px 12px; display: flex; flex-direction: column; gap: 2px; }
.admin-nav a { position: relative; padding: 9px 14px; border-radius: 8px; color: var(--text); text-transform: uppercase; font-size: .82rem; letter-spacing: .05em; }
.admin-nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.admin-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); font-weight: 700; }
.admin-nav a[aria-current="page"]::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--accent); }
.admin-main { padding: 32px 32px 64px; max-width: 1180px; }
@media (max-width: 760px) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .admin-nav { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; }
  .admin-main { padding: 20px 16px 40px; }
}

/* Formulare */
form.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: 15px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: .92rem; color: var(--ink); }
label .muted { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=file], select, textarea {
  font: inherit; font-weight: 400; color: var(--text); background: #fff;
  border: 1px solid #ccd2d7; border-radius: 8px; padding: 9px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input[type=file] { padding: 7px; background: var(--surface-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(243, 146, 0, .18); }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px 14px; margin: 0; }
legend { font-weight: 700; padding: 0 6px; text-transform: uppercase; font-size: .8rem; letter-spacing: .05em; color: var(--ink); }
label.check { flex-direction: row; align-items: center; gap: 9px; font-weight: 400; margin: 4px 0; }
label.check input { width: 17px; height: 17px; margin: 0; flex: none; accent-color: var(--accent); }
label.check.disabled { color: var(--muted); }
.check-row { display: flex; gap: 24px; flex-wrap: wrap; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.inline-form label { flex: 1 1 280px; }
.narrow-col { width: 110px; }

/* Buttons: Pillenform, Großbuchstaben */
.button, button.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; font-size: .82rem; line-height: 1.2; text-transform: uppercase; letter-spacing: .06em;
  padding: 10px 20px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
  transition: background .15s, color .15s, border-color .15s;
}
.button:hover { background: var(--ink); color: #fff; text-decoration: none; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.button.primary:hover { background: #db8300; border-color: #db8300; color: #fff; }
.button.danger { border-color: var(--danger); color: var(--danger); }
.button.danger:hover { background: var(--danger); color: #fff; }
.button.small { padding: 6px 14px; font-size: .74rem; }
button.link { font: inherit; background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; }
button.link:hover { color: var(--accent); text-decoration: underline; }
button.link.danger { color: var(--danger); }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: #fff; font-weight: 500; background: var(--ink); }
.table tbody tr:hover td { background: #fbfaf7; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td { padding: 5px 8px; vertical-align: middle; }
.table.compact label.check { margin: 0; }
.card:not(.flush) .table { margin-top: 8px; }
.card:not(.flush) .table th { background: var(--surface-2); color: var(--muted); }
td.actions { white-space: nowrap; text-align: right; }
td.actions form + form { margin-left: 12px; }

/* Hinweise und Badges */
.alert { border: 1px solid; border-left-width: 4px; border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; }
.alert-success { background: var(--success-bg); border-color: var(--success-line); border-left-color: var(--ok); }
.alert-error { background: var(--error-bg); border-color: var(--error-line); border-left-color: var(--danger); }
.alert-info { background: var(--info-bg); border-color: var(--info-line); border-left-color: var(--ink-3); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-line); border-left-color: var(--accent); }
.badge { display: inline-block; font-size: .68rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eceff1; color: var(--ink-2); vertical-align: middle; text-transform: uppercase; letter-spacing: .05em; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: var(--off-bg); color: var(--off); }
.badge.dark { background: var(--ink); color: #fff; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 16px 0 0; font-size: .9rem; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }
.pager { display: flex; gap: 20px; align-items: center; justify-content: center; }

/* Arbeitsbereich */
body.is-workspace { height: 100vh; overflow: hidden; }
.workspace { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); height: calc(100vh - var(--topbar)); transition: grid-template-columns .15s ease; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; padding: 0 12px 24px; }
.sidebar-rail { display: flex; justify-content: flex-end; padding: 10px 0 6px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.sidebar-toggle {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid transparent; background: none; color: var(--muted); cursor: pointer;
}
.sidebar-toggle:hover { background: var(--accent-soft); color: var(--ink); border-color: #f5d9ad; }
.sidebar-search { padding: 0 0 12px; position: sticky; top: 48px; background: var(--surface); z-index: 1; }
.sidebar-search input { border-radius: 999px; padding-left: 16px; background: var(--surface-2); }
.sidebar-empty { color: var(--muted); font-size: .88rem; padding: 8px 10px; }
.menu-group { margin-bottom: 6px; }
.menu-group-toggle {
  width: 100%; display: flex; align-items: center; gap: 8px; font: inherit; font-size: .74rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3);
  background: none; border: 0; padding: 8px 8px 6px; cursor: pointer; border-radius: 6px; text-align: left;
}
.menu-group-toggle:hover { color: var(--ink); }
.menu-group[data-group="all"] .menu-group-name, .menu-group[data-group="rest"] .menu-group-name { color: var(--accent); }
.menu-group-name { flex: 1; }
.menu-count { font-weight: 700; font-size: .68rem; color: #a5adb3; }
.chevron { width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: 0 3px 3px 1px; transition: transform .15s; flex: none; }
.menu-group.collapsed .chevron { transform: rotate(-45deg); margin-bottom: 0; }
.menu-group.collapsed .menu-list { display: none; }
.menu-list { list-style: none; margin: 0 0 6px; padding: 0; }
.menu-list a { position: relative; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); }
.menu-list a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.menu-list a[aria-current="page"] { background: var(--ink); color: #fff; }
.menu-list a[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 4px; border-radius: 0 3px 3px 0; background: var(--accent); }
.menu-list a[aria-current="page"] .menu-icon { background: rgba(255, 255, 255, .12); color: #fff; }
.menu-icon {
  display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 8px;
  background: var(--bg); font-size: .9rem; font-weight: 700; color: var(--ink-3);
}
.menu-group-toggle .menu-icon { width: auto; height: auto; background: none; font-size: .85rem; }
.menu-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-collapsed { grid-template-columns: 52px minmax(0, 1fr); }
.sidebar-collapsed .sidebar { padding: 0 8px; overflow: hidden; }
.sidebar-collapsed .sidebar-rail { justify-content: center; }
.sidebar-collapsed .sidebar-content { display: none; }

.workspace-main { min-width: 0; overflow-y: auto; }
.workspace-main.welcome { padding: 40px 44px 64px; }
.welcome h1 { font-size: 2.2rem; margin-bottom: .6rem; }
.welcome > p { color: var(--muted); }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-top: 26px; max-width: 1120px; }
.tool-card {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--text);
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.tool-card:hover { border-color: var(--accent); text-decoration: none; color: var(--text); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(30, 42, 51, .08); }
.tool-card-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 700; font-size: 1.15rem; }
.tool-card-name { font-weight: 700; color: var(--ink); }
.tool-card-desc { font-size: .86rem; color: var(--muted); }
.tool-card .badge { position: absolute; top: 18px; right: 18px; background: var(--accent-soft); color: #b56a00; }

.tool-view { display: flex; flex-direction: column; overflow: hidden; }
.tool-bar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tool-title { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex: 1; }
.tool-title h1 { font-size: 1rem; margin: 0; white-space: nowrap; letter-spacing: .04em; }
.tool-title .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-actions { display: flex; gap: 8px; flex: none; }
.tool-notice { margin: 12px 20px; }
.tool-frame-wrap { position: relative; flex: 1; min-height: 0; }
.tool-frame-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.tool-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: var(--bg); z-index: 1; text-transform: uppercase; letter-spacing: .08em; font-size: .82rem; }
.tool-loading.done { display: none; }

@media (max-width: 760px) {
  .workspace, .workspace.sidebar-collapsed { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .sidebar { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-collapsed .sidebar { max-height: none; }
  .sidebar-collapsed .sidebar-rail { justify-content: flex-start; }
  .topbar { gap: 12px; padding: 0 12px; }
  .brand-name { font-size: .95rem; letter-spacing: .2em; }
  .nav-home { display: none; }
  .topnav a { padding: 6px 6px; font-size: .8rem; }
  .topbar-user { gap: 10px; font-size: .82rem; white-space: nowrap; }
  .topbar-user > a { max-width: 80px; overflow: hidden; text-overflow: ellipsis; }
  .tool-bar { padding: 8px 12px; gap: 8px; }
  .tool-title h1 { overflow: hidden; text-overflow: ellipsis; }
  .tool-title .muted { display: none; }
  .workspace-main.welcome { padding: 24px 18px 40px; }
  .welcome h1 { font-size: 1.6rem; }
}

/* Unternehmen zu einem Tool */
.company { display: inline-block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #b56a00; background: var(--accent-soft); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
h1 .company { font-size: .7rem; margin-left: 4px; }
.table td .company { margin-left: 6px; }
.tool-card .company { align-self: flex-start; }
.menu-label { display: flex; flex-direction: column; line-height: 1.25; }
.menu-company { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; }
.menu-list a[aria-current="page"] .menu-company { color: rgba(255, 255, 255, .7); }
