/* HTSpro Kundenportal 2 */
:root {
    --accent: #f28c28;
    --accent-dark: #d96e0c;
    --dark: #111315;
    --text: #252a2e;
    --muted: #687078;
    --line: #e3e6e9;
    --bg: #f5f6f7;
    --ok: #1f7a3d;
    --error: #b4232d;
    --radius: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--accent-dark); }
h1, h2, h3, h4 { color: var(--dark); line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; margin-top: 1.2em; }
h4 { font-size: .95rem; margin-top: 1em; }
p { margin: 0 0 .8em; }

.top {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 22px;
    padding: 12px clamp(16px, 4vw, 40px);
    color: #fff;
    background: var(--dark);
}
.brand { color: #fff; font-weight: 900; font-size: 1.35rem; text-decoration: none; letter-spacing: .02em; }
.brand span { color: var(--accent); }
.top-link { margin-left: auto; color: #fff; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.nav a { padding: 8px 14px; border-radius: 999px; color: #e5e7e9; text-decoration: none; font-weight: 600; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { color: var(--dark); background: var(--accent); }
.logout { margin-left: auto; }
.top .btn-link { color: #fff; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px clamp(14px, 3vw, 32px) 48px; }
.hero { margin: 8px 0 22px; }
.eyebrow { margin: 0 0 4px; color: var(--accent-dark); font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; }
.card {
    margin-bottom: 18px;
    padding: clamp(18px, 3vw, 28px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 6px 22px rgba(17, 19, 21, .05);
}
.grid .card { margin-bottom: 0; }
.big { font-size: 1.35rem; font-weight: 800; color: var(--dark); }
.muted { color: var(--muted); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 8px 32px; }
.object-head { border-bottom: 1px solid var(--line); margin-bottom: 8px; padding-bottom: 8px; }

.contact { padding: 10px 12px; margin: 6px 0; border: 1px solid var(--line); border-radius: 12px; }
.contact.primary { border-color: var(--accent); background: #fff8f1; }
.device { padding: 10px 0; border-bottom: 1px solid var(--line); }
.device:last-child { border-bottom: 0; }
.device dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 4px 16px; margin: 8px 0 0; }
.device dt { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.device dd { margin: 0; }

.orders, .files { list-style: none; margin: 0; padding: 0; }
.orders li, .files li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.orders li:last-child, .files li:last-child { border-bottom: 0; }
.orders p { margin: 4px 0 0; }
.files li { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }

.tag { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; color: #3f454b; background: #eceef0; }
.tag.ok { color: #14532d; background: #dcfce7; }

.notice { margin: 0 0 14px; padding: 12px 16px; border-radius: 12px; background: #eef3f8; border: 1px solid #d3e0ec; }
.notice.success { background: #ecfbf1; border-color: #bfe8cd; }
.notice.error { color: #7a1018; background: #fdeeee; border-color: #f2c4c7; }
.notice.admin { background: #fff4e5; border-color: #f6cf9d; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 18px; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.full { grid-column: 1 / -1; }
label { font-weight: 600; font-size: .92rem; }
input[type="text"], input[type="email"], input[type="tel"], input[type="number"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cfd4d8;
    border-radius: 10px;
    font: inherit;
    background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(242, 140, 40, .3); border-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; }
.check input { margin-top: 4px; width: 18px; height: 18px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn, button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 20px;
    border: 1px solid var(--accent);
    border-radius: 999px;
    color: #fff;
    background: var(--accent);
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--accent-dark); }
.btn.secondary { color: var(--dark); background: #fff; }
.btn:disabled { opacity: .6; cursor: wait; }
.btn-link { padding: 0; border: 0; background: none; color: var(--accent-dark); font: inherit; text-decoration: underline; cursor: pointer; }
.btn-link.danger { color: var(--error); }

details.contact-edit { margin: 6px 0; }
details.contact-edit > summary { list-style: none; cursor: pointer; }
details.contact-edit > summary::-webkit-details-marker { display: none; }
details.contact-edit[open] { padding: 0 0 12px; border-bottom: 1px solid var(--line); }
details.contact-new { margin-top: 14px; }
details.contact-new > summary { list-style: none; }
details.contact-new > summary::-webkit-details-marker { display: none; }
form.remove { margin-top: 8px; }

.pending { border-color: #f6cf9d; background: #fffaf3; }
.request { padding: 8px 0; border-bottom: 1px solid #f3e3cc; }
.request:last-child { border-bottom: 0; }
.request ul { margin: 4px 0 0; padding-left: 20px; }

.login-wrap { display: grid; place-items: center; min-height: calc(100vh - 70px); padding: 24px; }
.login-card { width: min(520px, 100%); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.foot { display: flex; gap: 18px; justify-content: center; padding: 24px; color: var(--muted); }
.foot a { color: var(--muted); }

@media (max-width: 760px) {
    .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
    .nav a { white-space: nowrap; }
}

/* ---------- Dokumente mit Vorschau ---------- */
.tiles { list-style: none; margin: 8px 0 18px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.tiles.small { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.tile { display: flex; flex-direction: column; gap: 6px; }
.tile-link { display: flex; flex-direction: column; gap: 8px; color: var(--text); text-decoration: none; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; transition: box-shadow .15s, border-color .15s; height: 100%; }
.tile-link:hover, .tile-link:focus-visible { border-color: var(--accent); box-shadow: 0 6px 18px rgba(17,19,21,.1); }
.thumb { position: relative; display: block; aspect-ratio: 4 / 3; background: #f0f2f4; overflow: hidden; }
.thumb::before { content: attr(data-icon); position: absolute; inset: 0; display: grid; place-items: center; color: #8a9097; font-weight: 900; font-size: 1.1rem; letter-spacing: .08em; }
.thumb img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; object-position: top; background: #fff; }
.tile-text { display: flex; flex-direction: column; padding: 0 10px 10px; min-width: 0; }
.tile-text strong { font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-text small { color: var(--muted); font-size: .78rem; }
.tiles.small .tile-text small { display: none; }

/* ---------- Überlagerung ---------- */
html.viewer-open { overflow: hidden; }
.viewer { position: fixed; inset: 0; z-index: 10000; display: grid; grid-template-rows: auto 1fr; grid-template-columns: 56px 1fr 56px; background: rgba(9, 11, 13, .92); }
.viewer[hidden] { display: none; }
.viewer-bar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 10px 14px; color: #fff; background: rgba(0,0,0,.35); }
.viewer-title { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.viewer-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-title small { color: #c5cacf; }
.viewer-count { color: #c5cacf; font-variant-numeric: tabular-nums; white-space: nowrap; }
.viewer-btn { display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; color: #fff; background: rgba(255,255,255,.08); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap; }
.viewer-btn:hover { background: rgba(255,255,255,.18); }
.viewer-close { width: 42px; justify-content: center; padding: 0; font-size: 1.6rem; line-height: 1; }
.viewer-stage { grid-column: 2; display: grid; place-items: center; min-height: 0; padding: 14px 0; }
.viewer-stage img { max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; border-radius: 6px; background: #fff; }
.viewer-stage iframe { width: min(1000px, 100%); height: calc(100vh - 100px); border: 0; border-radius: 6px; background: #fff; }
.viewer-empty { padding: 28px; border-radius: 14px; background: #fff; text-align: center; }
.viewer-nav { align-self: center; justify-self: center; width: 46px; height: 46px; border: 0; border-radius: 50%; color: #fff; background: rgba(255,255,255,.12); font-size: 2rem; line-height: 1; cursor: pointer; }
.viewer-nav:hover { background: rgba(255,255,255,.25); }
.viewer-nav[hidden] { visibility: hidden; }
.viewer-nav.prev { grid-column: 1; grid-row: 2; }
.viewer-nav.next { grid-column: 3; grid-row: 2; }

@media (max-width: 700px) {
    .viewer { grid-template-columns: 0 1fr 0; }
    .viewer-nav { position: fixed; bottom: 18px; z-index: 2; }
    .viewer-nav.prev { left: 18px; }
    .viewer-nav.next { right: 18px; }
    .viewer-bar [data-v="tab"] { display: none; }
    .viewer-stage { padding: 6px; }
    .viewer-stage iframe { height: calc(100vh - 80px); }
}

/* ---------- Filter Objektseite (28.3.0) ---------- */
.filter { display: flex; flex-direction: column; gap: 10px; position: sticky; top: 64px; z-index: 10; }
.filter-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.seg { display: inline-flex; border: 1px solid #cfd4d8; border-radius: 999px; overflow: hidden; background: #fff; }
.seg button { padding: 7px 14px; border: 0; border-right: 1px solid #e3e6e9; background: transparent; font: inherit; font-weight: 600; cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.active { color: #fff; background: var(--dark); }
.filter-result { margin-left: auto; font-size: .9rem; }
.object-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px; align-items: flex-start; }
.plant-numbers { margin: 4px 0 0; padding: 6px 12px; border-radius: 10px; background: #fff8f1; border: 1px solid #f6d7b5; }
.plant-numbers span { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; margin-right: 4px; }
[data-order][hidden], [data-object][hidden] { display: none; }
@media (max-width: 760px) { .filter { position: static; } .filter-result { margin-left: 0; } }

/* ---------- 28.5.0: Aufträge, Material, Termine ---------- */
.order-card .orders li { border-bottom: 0; padding-bottom: 4px; }
.order-card .eyebrow { margin-bottom: 2px; }
.termin { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 8px; padding: 8px 12px; border-radius: 10px; background: #f3f7fb; }
.btn.small, a.btn.small { min-height: 34px; padding: 6px 14px; font-size: .88rem; }
.table-wrap { overflow-x: auto; }
table.material { width: 100%; border-collapse: collapse; font-size: .94rem; }
table.material th { padding: 8px 10px; color: var(--muted); font-size: .76rem; letter-spacing: .05em; text-align: left; text-transform: uppercase; border-bottom: 2px solid var(--line); white-space: nowrap; }
table.material td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.material tr.expired td { color: #8a9097; }
table.material tr.expired strong { color: #6b7177; font-weight: 600; }
table.material tr[hidden], [data-material-group][hidden] { display: none; }
.hint { display: inline-block; margin-top: 3px; padding: 2px 8px; border-radius: 8px; color: #6b4a00; background: #fff4d6; }
.docs { margin-top: 6px; }
.device h4 { margin: 12px 0 4px; }
@media (max-width: 700px) {
    table.material thead { display: none; }
    table.material tr { display: grid; grid-template-columns: 1fr 1fr; padding: 8px 0; border-bottom: 1px solid var(--line); }
    table.material td { border: 0; padding: 2px 6px; }
    table.material td:nth-child(2) { grid-column: 1 / -1; order: -1; }
}

/* ---------- Admin-Vorschau: Dateiaktionen (28.8.0) ---------- */
.file-admin { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px; border-radius: 10px; background: #eceef0; }
.file-admin.is-released { background: #e7f8ec; }
.file-admin.is-blocked { background: #fdeeee; }
.file-admin.is-changed { outline: 2px solid var(--accent); }
.file-state { font-size: .78rem; font-weight: 800; }
.file-admin.is-released .file-state { color: #14532d; }
.file-admin.is-blocked .file-state { color: #8a1c24; }
.file-admin select { padding: 6px 8px; font-size: .86rem; border-radius: 8px; }
.file-admin-footer { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 18px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 -6px 18px rgba(17,19,21,.08); }
.file-admin-form.has-changes .file-admin-footer { border-color: var(--accent); background: #fff8f1; }
.file-admin-form .order-card { margin-bottom: 18px; }
.file-duplicate { display: inline-block; padding: 2px 8px; border-radius: 8px; color: #7a3d00; background: #ffe2c2; font-size: .76rem; font-weight: 700; }
.file-admin.is-duplicate { box-shadow: inset 0 0 0 2px #f6b26b; }
.file-admin-footer [data-file-duplicates] { margin-left: auto; }
