:root {
    --bg: #f3f6fa;
    --surface: #ffffff;
    --surface-2: #eef3f8;
    --text: #182433;
    --muted: #68778a;
    --border: #d8e0e9;
    --primary: #1267d6;
    --primary-strong: #0a4da6;
    --accent: #00a8a8;
    --danger: #c93939;
    --warning: #b56a00;
    --success: #16805b;
    --shadow: 0 12px 32px rgba(24, 36, 51, .09);
    --radius: 14px;
    --header: #101b2a;
    --header-text: #f7fbff;
}

:root[data-theme="dark"] {
    --bg: #0d141e;
    --surface: #151f2c;
    --surface-2: #1c2938;
    --text: #e9f0f8;
    --muted: #9fb0c2;
    --border: #2b3b4d;
    --primary: #5aa0ff;
    --primary-strong: #8bbcff;
    --accent: #3fd0c9;
    --danger: #ff7777;
    --warning: #ffc05b;
    --success: #54d5a8;
    --shadow: 0 16px 36px rgba(0, 0, 0, .25);
    --header: #09111b;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 72px;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 28px;
    padding: 10px clamp(16px, 3vw, 44px);
    background: var(--header);
    color: var(--header-text);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .18);
}
.brand { display: flex; align-items: center; gap: 11px; color: inherit; min-width: max-content; }
.brand:hover { text-decoration: none; }
.brand-mark {
    display: grid;
    place-items: center;
    width: 45px;
    height: 45px;
    border-radius: 11px;
    background: linear-gradient(145deg, #2582ed, #00aaa5);
    font-weight: 900;
    letter-spacing: -.04em;
}
.brand strong, .brand small { display: block; }
.brand small { color: #aebccd; font-size: .72rem; }
.main-nav { display: flex; justify-content: center; align-items: center; gap: 6px; }
.main-nav a { color: #dce7f3; padding: 10px 12px; border-radius: 9px; font-weight: 650; font-size: .94rem; }
.main-nav a:hover { background: rgba(255,255,255,.09); text-decoration: none; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.user-chip { max-width: 180px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: #dce7f3; font-weight: 650; }
.menu-toggle { display: none; background: transparent; border: 0; padding: 8px; }
.menu-toggle span { display: block; width: 25px; height: 3px; margin: 4px 0; border-radius: 2px; background: white; }
.icon-btn { border: 1px solid rgba(255,255,255,.2); background: rgba(255,255,255,.06); color: white; border-radius: 9px; width: 38px; height: 38px; cursor: pointer; }

.page { width: min(1500px, calc(100% - 32px)); margin: 28px auto 64px; }
.page-narrow { width: min(920px, calc(100% - 32px)); }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin-bottom: 22px; }
.page-heading h1 { margin: 0; font-size: clamp(1.7rem, 3vw, 2.35rem); letter-spacing: -.035em; }
.page-heading p { margin: 4px 0 0; color: var(--muted); }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-header { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { margin: 0; }
.card-body { padding: 20px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { padding: 18px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); color: var(--primary); font-weight: 900; }
.stat-card strong { display: block; font-size: 1.55rem; line-height: 1.1; }
.stat-card span { color: var(--muted); font-size: .9rem; }

.filter-bar { display: grid; grid-template-columns: minmax(250px, 1fr) repeat(3, minmax(145px, .32fr)) auto; gap: 12px; padding: 16px; margin-bottom: 18px; }
.search-input { position: relative; }
.search-input input { padding-left: 42px; }
.search-input::before { content: "⌕"; position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 1.35rem; }

label { display: block; margin-bottom: 6px; font-size: .87rem; color: var(--muted); font-weight: 700; }
input, select, textarea {
    width: 100%;
    min-height: 43px;
    padding: 9px 12px;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 9px;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
textarea { min-height: 110px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-group-full { grid-column: 1 / -1; }
.form-section { margin-bottom: 20px; overflow: hidden; }
.form-section .card-body { display: grid; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 0 0; }
.help { margin-top: 5px; color: var(--muted); font-size: .82rem; }
.error-list { padding: 14px 18px; border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border)); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); border-radius: 11px; color: var(--danger); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 9px;
    font-weight: 750;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { color: white; background: var(--primary); }
.btn-secondary { color: var(--text); background: var(--surface-2); border-color: var(--border); }
.btn-danger { color: white; background: var(--danger); }
.btn-ghost { color: inherit; border-color: currentColor; background: transparent; }
.btn-small { min-height: 34px; padding: 6px 10px; font-size: .84rem; }
.btn-icon { width: 38px; padding: 0; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .045em; white-space: nowrap; }
tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, var(--surface)); }
.tool-thumb { width: 62px; height: 48px; object-fit: cover; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.tool-number { font-weight: 900; color: var(--primary); }
.tool-name { font-weight: 750; min-width: 240px; }
.actions { display: flex; justify-content: flex-end; gap: 7px; }
.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 9px; font-size: .78rem; font-weight: 800; border: 1px solid color-mix(in srgb, var(--badge-color, var(--primary)) 35%, var(--border)); color: var(--badge-color, var(--primary)); background: color-mix(in srgb, var(--badge-color, var(--primary)) 9%, var(--surface)); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.pagination { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 7px; padding: 18px; }
.pagination a, .pagination span { min-width: 38px; min-height: 38px; display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.pagination .active { color: white; background: var(--primary); border-color: var(--primary); }

.tool-hero { display: grid; grid-template-columns: minmax(280px, 450px) 1fr; gap: 20px; margin-bottom: 20px; }
.tool-image-card { min-height: 320px; display: grid; place-items: center; padding: 16px; overflow: hidden; }
.tool-image-card img { width: 100%; max-height: 430px; object-fit: contain; border-radius: 10px; }
.image-placeholder { color: var(--muted); text-align: center; }
.tool-summary { padding: 24px; }
.tool-summary h1 { margin: 3px 0 8px; font-size: clamp(1.7rem, 3vw, 2.55rem); }
.tool-summary .eyebrow { color: var(--primary); font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 24px; }
.summary-item { padding: 13px; border-radius: 10px; background: var(--surface-2); }
.summary-item span, .parameter-item span { display: block; color: var(--muted); font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.summary-item strong { display: block; margin-top: 3px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.masterdata-wide { grid-column: 1 / -1; }
.parameter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.parameter-item { padding: 11px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); min-height: 64px; }
.parameter-item strong { display: block; margin-top: 4px; overflow-wrap: anywhere; }
.component-row { display: grid; grid-template-columns: 48px 90px 2fr 1fr 1fr 42px; gap: 10px; align-items: end; padding: 12px; border-bottom: 1px solid var(--border); }
.component-position { align-self: center; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); font-weight: 900; }

.timeline { display: grid; gap: 14px; }
.timeline-item { display: grid; grid-template-columns: 14px 1fr; gap: 12px; }
.timeline-dot { width: 10px; height: 10px; margin-top: 7px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent); }
.timeline-item p { margin: 0; }
.timeline-item small { color: var(--muted); }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 20%, rgba(18,103,214,.22), transparent 30%), radial-gradient(circle at 90% 80%, rgba(0,168,168,.18), transparent 32%), var(--bg); }
.login-shell { width: min(980px, 100%); display: grid; grid-template-columns: 1.15fr .85fr; overflow: hidden; border-radius: 22px; box-shadow: 0 24px 70px rgba(0,0,0,.2); }
.login-info { padding: clamp(32px, 6vw, 74px); background: linear-gradient(145deg, #0f2745, #0d5966); color: white; }
.login-info h1 { font-size: clamp(2.2rem, 5vw, 4.5rem); line-height: .98; letter-spacing: -.05em; margin: 20px 0; }
.login-info p { color: #d2e6ed; max-width: 520px; }
.login-panel { padding: clamp(28px, 5vw, 58px); background: var(--surface); display: grid; align-content: center; }
.login-panel h2 { margin: 0 0 4px; }
.login-panel form { display: grid; gap: 16px; margin-top: 24px; }

.flash-stack { position: fixed; z-index: 40; top: 84px; right: 18px; display: grid; gap: 8px; width: min(420px, calc(100% - 36px)); }
.flash { padding: 13px 15px; border-radius: 10px; color: white; box-shadow: var(--shadow); font-weight: 700; }
.flash-success { background: var(--success); }
.flash-error { background: var(--danger); }
.flash-warning { background: var(--warning); }
.flash-info { background: var(--primary); }

.empty-state { padding: 48px 20px; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty-state h1, .empty-state h2 { margin-top: 0; }
.muted { color: var(--muted); }
.app-footer { display: flex; justify-content: space-between; gap: 20px; width: min(1500px, calc(100% - 32px)); margin: 0 auto; padding: 24px 0 32px; color: var(--muted); font-size: .84rem; }

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-bar { grid-template-columns: 1fr 1fr; }
    .filter-bar .search-input { grid-column: 1 / -1; }
    .parameter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .tool-hero { grid-template-columns: minmax(250px, 360px) 1fr; }
    .component-row { grid-template-columns: 42px 80px 1fr 1fr; }
    .component-row > :nth-child(5) { grid-column: 3 / 5; }
}

@media (max-width: 820px) {
    .app-header { grid-template-columns: auto auto 1fr; gap: 12px; }
    .menu-toggle { display: block; }
    .main-nav { display: none; position: absolute; top: 72px; left: 12px; right: 12px; flex-direction: column; align-items: stretch; padding: 10px; border-radius: 12px; background: var(--header); box-shadow: var(--shadow); }
    .main-nav.is-open { display: flex; }
    .header-actions { margin-left: auto; }
    .user-chip { display: none; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .tool-hero, .detail-grid, .login-shell { grid-template-columns: 1fr; }
    .login-info { display: none; }
    .tool-image-card { min-height: 240px; }
    .parameter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid, .form-grid-2 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 580px) {
    .brand span:last-child { display: none; }
    .header-actions .btn { font-size: 0; width: 38px; padding: 0; }
    .header-actions .btn::after { content: "↪"; font-size: 1rem; }
    .page { width: min(100% - 20px, 1500px); margin-top: 18px; }
    .stats-grid, .filter-bar, .summary-grid, .parameter-grid, .form-grid, .form-grid-2 { grid-template-columns: 1fr; }
    .filter-bar .search-input { grid-column: auto; }
    .card-header { align-items: flex-start; flex-direction: column; }
    .component-row { grid-template-columns: 40px 1fr 42px; }
    .component-row > :nth-child(3), .component-row > :nth-child(4), .component-row > :nth-child(5) { grid-column: 1 / -1; }
    .component-row > :last-child { grid-column: 3; grid-row: 1; }
    .hide-mobile { display: none; }
    th, td { padding: 10px 9px; }
    .tool-name { min-width: 180px; }
}

@page {
    size: A4 landscape;
    margin: 5mm;
}

@media print {
    html, body {
        width: 287mm;
        min-height: 200mm;
        margin: 0;
        padding: 0;
        background: #fff !important;
        color: #111 !important;
        font-size: 7pt;
        line-height: 1.1;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .app-header, .app-footer, .heading-actions, .flash-stack, .no-print {
        display: none !important;
    }

    .page,
    .print-sheet {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .print-heading {
        align-items: flex-end;
        margin: 0 0 2mm;
        padding: 0 0 1.8mm;
        border-bottom: .4mm solid #315a88;
    }

    .print-heading h1 {
        margin: 0;
        font-size: 15pt;
        line-height: 1;
        letter-spacing: -.02em;
        color: #12395f !important;
    }

    .print-heading p {
        margin: .7mm 0 0;
        font-size: 6.9pt;
        color: #4f6580 !important;
    }

    .card {
        border: .25mm solid #9fb4c8;
        border-radius: 1.1mm;
        box-shadow: none !important;
        background: #fff !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .print-hero {
        display: grid;
        grid-template-columns: 58mm 1fr;
        gap: 1.8mm;
        height: 40mm;
        margin: 0 0 1.8mm;
    }

    .print-image-card {
        min-height: 0;
        height: 40mm;
        padding: 1.2mm;
        background: #f8fbff !important;
    }

    .print-image-card img {
        width: 100%;
        height: 100%;
        max-height: none;
        object-fit: contain;
        border-radius: .8mm;
        background: #fff !important;
    }

    .print-summary {
        height: 40mm;
        padding: 1.6mm;
        background: #fdfefe !important;
    }

    .print-summary h2 {
        margin: 0 0 1.1mm;
        font-size: 8.4pt;
        color: #12395f !important;
    }

    .print-summary .summary-grid {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 1.2mm;
        margin: 0;
    }

    .print-summary .summary-item {
        min-height: 13.2mm;
        padding: 1.2mm;
        border: .2mm solid #bfd0e0;
        border-radius: .8mm;
        background: #eef5fb !important;
    }

    .print-summary .summary-item:last-child {
        grid-column: 1 / -1;
        min-height: 9mm;
    }

    .summary-item span,
    .parameter-item span {
        font-size: 5.5pt;
        line-height: 1.02;
        color: #516173 !important;
        letter-spacing: .03em;
        text-transform: uppercase;
    }

    .summary-item strong {
        margin-top: .8mm;
        font-size: 6.9pt;
        line-height: 1.08;
        color: #111 !important;
    }

    .print-parameter-groups {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.8mm;
        margin: 0 0 1.8mm;
        align-items: stretch;
    }

    .print-parameter-section {
        width: auto;
        margin: 0;
        overflow: hidden;
    }

    .print-parameter-section .card-header,
    .print-components .card-header {
        min-height: 0;
        padding: 1.1mm 1.5mm;
        border-bottom: .2mm solid #a8bdd2;
        background: #dbe8f4 !important;
    }

    .print-parameter-section .card-header h2,
    .print-components .card-header h2 {
        margin: 0;
        font-size: 7pt;
        line-height: 1;
        color: #12395f !important;
    }

    .print-parameter-section .card-body {
        padding: 1.2mm;
    }

    .print-parameter-section .parameter-grid {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: .9mm;
    }

    .print-parameter-section .parameter-item {
        min-height: 8.8mm;
        padding: 1mm 1.1mm;
        border: .2mm solid #c9d7e5;
        border-radius: .6mm;
        background: #f7fbff !important;
    }

    .print-parameter-section .parameter-item strong {
        display: block;
        margin-top: .65mm;
        font-size: 6.6pt;
        line-height: 1.04;
        color: #111 !important;
    }

    .print-components {
        clear: both;
        margin-top: 0;
        overflow: hidden;
    }

    .print-components .table-wrap {
        overflow: visible;
    }

    .print-components table {
        table-layout: fixed;
        font-size: 6.5pt;
    }

    .print-components th,
    .print-components td {
        padding: 1mm 1.3mm;
        border-bottom: .2mm solid #ccd6e0;
        line-height: 1.03;
        overflow-wrap: anywhere;
    }

    .print-components th {
        font-size: 5.8pt;
        color: #264769 !important;
        background: #eaf2f9 !important;
        text-transform: uppercase;
        letter-spacing: .03em;
    }

    .print-components tbody tr:nth-child(even) td {
        background: #fbfdff !important;
    }

    .print-components th:nth-child(1),
    .print-components td:nth-child(1) { width: 7%; }
    .print-components th:nth-child(2),
    .print-components td:nth-child(2) { width: 7%; }
    .print-components th:nth-child(3),
    .print-components td:nth-child(3) { width: 42%; }
    .print-components th:nth-child(4),
    .print-components td:nth-child(4) { width: 22%; }
    .print-components th:nth-child(5),
    .print-components td:nth-child(5) { width: 22%; }

    .muted {
        color: #5f7082 !important;
    }

    .parameter-item.parameter-empty strong {
        opacity: .45;
    }
}
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; }
code { padding: .15em .38em; border-radius: 5px; background: var(--surface-2); }

.file-name-note { margin-top: 8px; font-size: .88rem; color: var(--text-muted); }
.file-name-note code { display: inline-block; max-width: 100%; font-size: .86rem; overflow-wrap: anywhere; word-break: break-word; }

/* Stammdatenverwaltung: Werkzeugarten bearbeiten und löschen */
.masterdata-subtitle { margin: 3px 0 0; }
.masterdata-form-actions,
.masterdata-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.masterdata-actions form { margin: 0; }
.masterdata-hint { border-top: 1px solid var(--border); }
.masterdata-hint p { margin: 0; }
tr.is-editing { background: color-mix(in srgb, var(--primary) 9%, var(--surface)); }
.btn:disabled { opacity: .48; cursor: not-allowed; filter: none; }

@media (max-width: 580px) {
    .masterdata-actions { min-width: 255px; }
}

/* Version 0.2.7: vollständige technische Parameterliste */
.parameter-item.parameter-empty strong {
    opacity: .55;
    font-weight: 600;
}
