:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #1a2433;
    --muted: #64748b;
    --border: #dce3ee;
    --primary: #1d4ed8;
    --primary-dark: #163fae;
    --secondary: #eef2ff;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-header__inner {
    max-width: 920px;
    margin: 0 auto;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    font-weight: 700;
    font-size: 1.1rem;
}

.site-header__right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-nav {
    display: flex;
    gap: 14px;
    font-size: 0.95rem;
    align-items: center;
}

.header-logo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.header-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--border);
    padding: 2px;
}

.page-shell {
    max-width: 920px;
    margin: 0 auto;
    padding: 16px;
}

.page-heading {
    margin-bottom: 16px;
}

.split-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.muted {
    color: var(--muted);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 6px 18px rgba(20, 30, 50, 0.04);
}

.card + .card { margin-top: 12px; }

.card-list {
    display: grid;
    gap: 12px;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.stack-form label {
    display: grid;
    gap: 8px;
    font-weight: 600;
}

input, textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 1rem;
    background: #fff;
}

textarea { resize: vertical; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border-radius: 12px;
    padding: 13px 16px;
    font-weight: 700;
    border: 1px solid transparent;
}

.button-inline {
    width: auto;
}

.button-primary {
    background: var(--primary);
    color: #fff;
}

.button-primary:hover { background: var(--primary-dark); }

.button-secondary {
    background: var(--secondary);
    border-color: #c7d2fe;
    color: #1e3a8a;
}

.button[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.action-stack,
.button-row {
    display: grid;
    gap: 10px;
}

.stats-grid {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    text-align: center;
}

.stat-label {
    font-size: 0.95rem;
    color: var(--muted);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    margin-top: 6px;
}

.project-card h2,
.project-card h3,
.defect-card h3 { margin-top: 0; }

.defect-card {
    display: grid;
    gap: 14px;
}

.defect-card__media img,
.review-image {
    border-radius: 12px;
    border: 1px solid var(--border);
    width: 100%;
    height: auto;
}

.image-placeholder,
.image-preview {
    min-height: 180px;
    display: grid;
    place-items: center;
    background: #edf2f7;
    border: 1px dashed var(--border);
    border-radius: 12px;
    color: var(--muted);
}

.image-preview img {
    border-radius: 12px;
}

.hidden { display: none; }

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 14px;
}

.alert-error {
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: #991b1b;
}

.auth-card {
    max-width: 480px;
    margin: 48px auto 0;
}

.login-logo-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.login-logo {
    width: 180px;
    max-width: 70%;
    height: auto;
    object-fit: contain;
}

.detail-card p,
.defect-review-card p,
.project-card p,
.defect-card p {
    margin: 0 0 8px;
}

.annotation-meta {
    margin-bottom: 12px;
}

.annotation-meta p {
    margin: 0 0 8px;
}

.annotation-stage {
    display: grid;
    gap: 10px;
}

.annotation-canvas-wrap {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: #e8eef7;
    touch-action: none;
    cursor: crosshair;
}

.annotation-panzoom-layer {
    position: relative;
    transform-origin: 0 0;
    will-change: transform;
}

.annotation-image {
    width: 100%;
    height: auto;
    display: block;
    touch-action: none;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.annotation-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: none;
    pointer-events: none;
}

.annotation-help {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.annotation-tools {
    display: flex;
    justify-content: flex-end;
}

.report-heading-actions {
    grid-template-columns: 1fr;
}

.report-summary-card h2,
.report-summary-card h3 {
    margin-top: 0;
}

.report-text-block {
    margin: 0 0 16px;
    white-space: pre-wrap;
    font: inherit;
    color: inherit;
}

.severity-grid {
    display: grid;
    gap: 12px;
    margin: 16px 0;
}

.action-stack--triple {
    grid-template-columns: 1fr;
}

@media (min-width: 700px) {
    .card-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .severity-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .report-heading-actions {
        grid-template-columns: repeat(2, auto);
        justify-content: end;
    }
}
