:root {
    --bg: #eef3f6;
    --panel: #ffffff;
    --panel-soft: #f8fafb;
    --text: #10202b;
    --muted: #627281;
    --line: #d6e0e7;
    --primary: #126b5f;
    --primary-dark: #0d544b;
    --primary-soft: #e5f4f0;
    --accent: #d98f2b;
    --shadow: 0 18px 45px rgba(20, 37, 50, .09);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #f7fafb 0, var(--bg) 360px);
    color: var(--text);
    font-size: 17px;
}

a { color: inherit; text-decoration: none; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: 14px clamp(16px, 4vw, 48px);
    background: rgba(255, 255, 255, .88);
    border-bottom: 1px solid rgba(214, 224, 231, .82);
    backdrop-filter: blur(18px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.18rem;
    font-weight: 850;
}

.brand::before {
    content: "";
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--primary);
    box-shadow: inset 0 -8px 0 rgba(255, 255, 255, .16);
}

.topbar nav { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar nav a {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    padding: 9px 13px;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 750;
}
.topbar nav a:hover { background: var(--primary-soft); color: var(--primary-dark); }

.install-banner {
    width: min(1120px, calc(100% - 28px));
    margin: 16px auto 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    background: #10202b;
    color: #fff;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.install-banner[hidden] { display: none; }
.install-banner div { display: grid; gap: 3px; }
.install-banner span { color: rgba(255, 255, 255, .78); font-size: .94rem; }
.install-banner .button { width: auto; border-color: rgba(255, 255, 255, .25); }
.install-banner .button.ghost { background: transparent; color: #fff; }

.page {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 34px clamp(14px, 3vw, 36px) 64px;
}

h1 { margin: 0 0 12px; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.05; letter-spacing: 0; }
h2 { margin: 0 0 18px; font-size: 1.2rem; letter-spacing: 0; }
p { line-height: 1.6; color: var(--muted); }

.headline {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 26px;
}

.panel, .auth-panel, .project-card, .defect-row, .report {
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(214, 224, 231, .92);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel, .auth-panel {
    padding: clamp(20px, 3vw, 30px);
    margin-bottom: 22px;
}

.auth-panel {
    max-width: 540px;
    margin: 7vh auto;
}

.form-stack { display: grid; gap: 16px; }
.inline-form { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }

label {
    display: grid;
    gap: 8px;
    color: var(--text);
    font-size: .96rem;
    font-weight: 780;
}

input, textarea, select {
    width: 100%;
    min-height: 52px;
    padding: 12px 14px;
    border: 1px solid #c8d4dc;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(18, 107, 95, .14);
}

textarea { resize: vertical; line-height: 1.45; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 11px 18px;
    border: 1px solid #cbd7de;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: inherit;
    font-weight: 820;
    cursor: pointer;
    transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(16, 32, 43, .09); }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.danger { background: #b42335; border-color: #b42335; color: #fff; }
.button.danger:hover { background: #8f1d2b; }
.button.ghost { background: transparent; }
.button.small { min-height: 38px; padding: 7px 11px; font-size: .9rem; }

.notice {
    padding: 14px 15px;
    background: #fff7e8;
    border: 1px solid #efc986;
    border-radius: 8px;
    color: #4a3410;
}

.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.project-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }

.project-card {
    position: relative;
    display: grid;
    gap: 10px;
    min-height: 124px;
    padding: 20px;
    overflow: hidden;
}

.project-card::after {
    content: "";
    position: absolute;
    right: 18px;
    bottom: 18px;
    width: 42px;
    height: 6px;
    border-radius: 999px;
    background: var(--accent);
}

.project-card:hover, .defect-row:hover { border-color: var(--primary); }
.project-card strong { font-size: 1.2rem; }
.project-card span, small { color: var(--muted); }

.defect-list { display: grid; gap: 12px; }
.defect-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 16px 18px;
    box-shadow: none;
}
.defect-row span { display: grid; gap: 4px; }
.defect-row em {
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: .9rem;
    font-style: normal;
    font-weight: 850;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 14px 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-size: .9rem; font-weight: 850; }

.capture-form { display: grid; gap: 18px; }
.capture-tools {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: end;
}
.photo-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.photo-preview img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; }

.report {
    padding: clamp(22px, 4vw, 46px);
    margin-bottom: 22px;
}
.report-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-bottom: 22px; }
.action-row { display: flex; gap: 12px; flex-wrap: wrap; }
.report-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 30px;
}
.report-meta div { padding: 14px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 8px; }
dt { color: var(--muted); font-size: .9rem; font-weight: 800; }
dd { margin: 5px 0 0; font-weight: 780; }
.description { color: var(--text); white-space: normal; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.photo-grid.compact { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
figure { margin: 0; break-inside: avoid; }
figure img { width: 100%; max-height: 520px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #f1f4f6; cursor: zoom-in; }
figcaption { margin-top: 7px; color: var(--muted); font-size: .9rem; }

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgba(7, 18, 26, .88);
}

.lightbox[hidden] { display: none; }
.lightbox img {
    max-width: min(1100px, 100%);
    max-height: 86vh;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
}

.lightbox-close {
    position: fixed;
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
}

@media (max-width: 760px) {
    body { font-size: 16px; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .headline, .defect-row { flex-direction: column; align-items: stretch; }
    .admin-grid, .report-meta { grid-template-columns: 1fr; }
    .capture-tools { grid-template-columns: 1fr; }
    .button { width: 100%; }
    .install-banner { flex-direction: column; align-items: stretch; }
    .inline-form { display: grid; }
}

@media print {
    body { background: #fff; font-size: 12pt; }
    .topbar, .no-print { display: none !important; }
    .page { width: 100%; padding: 0; }
    .report { border: 0; padding: 0; box-shadow: none; }
    .photo-grid { grid-template-columns: repeat(2, 1fr); }
}
