* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --slate: #0f1419;
    --deep: #1a1f2e;
    --stone: #2a2f3e;
    --sand: #c8a97e;
    --sand-light: #dcc5a0;
    --sand-dim: rgba(200, 169, 126, 0.15);
    --warm: #f5efe6;
    --ghost: #8a8f9e;
    --white: #fafaf8;
    --red: #e05555;
    --green: #55b08a;
    --yellow: #e0b055;
    --orange: #e07a35;
    --border: rgba(200, 169, 126, 0.1);
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--slate);
    color: var(--white);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.grain {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 1000;
}

/* NAV */
.app-nav {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    z-index: 100;
    background: rgba(15, 20, 25, 0.9);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.nav-logo {
    text-decoration: none;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--sand);
}

.logo-sub {
    font-size: 0.65rem;
    color: var(--ghost);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--ghost);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    transition: all 0.15s;
    margin-left: auto;
}

.nav-link:hover {
    color: var(--white);
    background: rgba(255,255,255,0.05);
}

/* MAIN CONTENT */
main {
    padding: 5rem 2rem 3rem;
    max-width: 1100px;
    margin: 0 auto;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.4rem;
    border: none;
    border-radius: 4px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--sand);
    color: var(--slate);
}

.btn-primary:hover {
    background: var(--sand-light);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--stone);
    color: var(--white);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(200,169,126,0.12);
    border-color: rgba(200,169,126,0.2);
}

.btn-danger {
    background: rgba(224,85,85,0.1);
    color: var(--red);
    border: 1px solid rgba(224,85,85,0.2);
}

.btn-danger:hover {
    background: rgba(224,85,85,0.2);
}

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 0.85rem 2rem;
    font-size: 0.95rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* PAGE HEADER */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-header .subtitle {
    color: var(--ghost);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* CARDS */
.card {
    background: var(--deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.5rem;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: rgba(200,169,126,0.2);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
}

/* ASSESSMENT LIST */
.assessment-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.assessment-card {
    cursor: pointer;
}

.assessment-card .meta {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.assessment-card .meta-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: var(--ghost);
}

.assessment-card .meta-item svg {
    width: 14px;
    height: 14px;
    opacity: 0.6;
}

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.badge-draft { background: rgba(138,143,158,0.15); color: var(--ghost); }
.badge-analyzing { background: rgba(200,169,126,0.15); color: var(--sand); }
.badge-completed { background: rgba(85,176,138,0.15); color: var(--green); }
.badge-failed { background: rgba(224,85,85,0.15); color: var(--red); }

.badge-severity-low { background: rgba(85,176,138,0.15); color: var(--green); }
.badge-severity-moderate { background: rgba(224,176,85,0.15); color: var(--yellow); }
.badge-severity-high { background: rgba(224,122,53,0.15); color: var(--orange); }
.badge-severity-critical { background: rgba(224,85,85,0.15); color: var(--red); }

/* FORM */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ghost);
    margin-bottom: 0.5rem;
}

.form-input, .form-select {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--stone);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--white);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
    transition: border-color 0.2s;
    outline: none;
}

.form-input:focus, .form-select:focus {
    border-color: var(--sand);
}

.form-input::placeholder {
    color: rgba(138,143,158,0.5);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* DROP ZONE */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    background: rgba(26,31,46,0.5);
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--sand);
    background: rgba(200,169,126,0.05);
}

.drop-zone-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    color: var(--sand);
    opacity: 0.6;
}

.drop-zone h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.drop-zone p {
    color: var(--ghost);
    font-size: 0.85rem;
}

.drop-zone input[type="file"] {
    display: none;
}

/* PHOTO GRID */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.photo-card {
    position: relative;
    border-radius: 6px;
    overflow: hidden;
    background: var(--stone);
    aspect-ratio: 4/3;
}

.photo-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-card .photo-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(transparent 50%, rgba(0,0,0,0.7));
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: flex-end;
    padding: 0.75rem;
}

.photo-card:hover .photo-overlay {
    opacity: 1;
}

.photo-card .photo-name {
    font-size: 0.75rem;
    color: white;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-card .photo-delete {
    background: rgba(224,85,85,0.8);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.photo-card .photo-delete:hover {
    background: var(--red);
}

/* LOADING */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15,20,25,0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 500;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--stone);
    border-top-color: var(--sand);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    color: var(--sand-light);
    margin-bottom: 0.5rem;
}

.loading-sub {
    color: var(--ghost);
    font-size: 0.85rem;
}

/* REPORT VIEW */
.report-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.report-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.6rem;
    font-weight: 700;
}

.report-meta {
    color: var(--ghost);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.report-actions {
    display: flex;
    gap: 0.75rem;
}

/* STAT CARDS */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1.25rem;
}

.stat-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--ghost);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--sand-light);
}

.stat-value.condition-good { color: var(--green); }
.stat-value.condition-fair { color: var(--yellow); }
.stat-value.condition-poor { color: var(--orange); }
.stat-value.condition-critical { color: var(--red); }

/* DEFECT TABLE */
.defect-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.defect-table th {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ghost);
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: rgba(42,47,62,0.5);
}

.defect-table td {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(200,169,126,0.05);
    vertical-align: top;
}

.defect-table tr:hover td {
    background: rgba(200,169,126,0.03);
}

.severity-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.4rem;
    vertical-align: middle;
}

.severity-dot.low { background: var(--green); }
.severity-dot.moderate { background: var(--yellow); }
.severity-dot.high { background: var(--orange); }
.severity-dot.critical { background: var(--red); }

/* DEFECT DETAIL CARDS */
.defect-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.defect-card {
    background: var(--deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.defect-card-bar {
    height: 4px;
}

.defect-card-bar.low { background: var(--green); }
.defect-card-bar.moderate { background: var(--yellow); }
.defect-card-bar.high { background: var(--orange); }
.defect-card-bar.critical { background: var(--red); }

.defect-card-body {
    padding: 1.25rem;
}

.defect-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.defect-card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
}

.defect-card-detail {
    margin-bottom: 0.75rem;
}

.defect-card-detail-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ghost);
    margin-bottom: 0.2rem;
}

.defect-card-detail-value {
    font-size: 0.9rem;
    line-height: 1.5;
    color: rgba(250,250,248,0.85);
}

/* RESTORATION SPECIFICATION CARDS */
.spec-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.spec-card {
    background: var(--deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.spec-card:hover {
    border-color: rgba(200,169,126,0.25);
}

.spec-card-bar {
    height: 4px;
}

.spec-card-bar.low { background: var(--green); }
.spec-card-bar.moderate { background: var(--yellow); }
.spec-card-bar.high { background: var(--orange); }
.spec-card-bar.critical { background: var(--red); }

.spec-card-body {
    padding: 1.25rem;
}

.spec-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.spec-num {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--sand);
    display: block;
    margin-bottom: 0.25rem;
}

.spec-card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--white);
}

.spec-urgency {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.6rem;
    border-radius: 3px;
    white-space: nowrap;
}

.spec-urgency-critical {
    background: rgba(224,85,85,0.15);
    color: var(--red);
}

.spec-urgency-high {
    background: rgba(224,122,53,0.15);
    color: var(--orange);
}

.spec-urgency-moderate {
    background: rgba(224,176,85,0.15);
    color: var(--yellow);
}

.spec-urgency-low {
    background: rgba(85,176,138,0.15);
    color: var(--green);
}

.spec-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.spec-meta-item {
    font-size: 0.75rem;
    color: var(--ghost);
    font-family: 'Space Grotesk', sans-serif;
}

.spec-section {
    margin-bottom: 0.75rem;
}

.spec-section-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sand);
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.spec-section-value {
    font-size: 0.88rem;
    line-height: 1.6;
    color: rgba(250,250,248,0.85);
}

.spec-acceptance {
    padding: 0.6rem 0.85rem;
    background: rgba(85,176,138,0.06);
    border-left: 3px solid var(--green);
    border-radius: 0 4px 4px 0;
    font-size: 0.85rem;
}

.spec-list {
    list-style: none;
    padding: 0;
}

.spec-list li {
    position: relative;
    padding: 0.3rem 0 0.3rem 1rem;
    font-size: 0.85rem;
    color: rgba(250,250,248,0.85);
    line-height: 1.5;
}

.spec-list li::before {
    content: '\2022';
    color: var(--sand);
    position: absolute;
    left: 0;
}

.spec-method-list {
    list-style: none;
    padding: 0;
    counter-reset: spec-step;
}

.spec-method-list li {
    position: relative;
    padding: 0.35rem 0 0.35rem 2rem;
    font-size: 0.85rem;
    color: rgba(250,250,248,0.85);
    line-height: 1.5;
    counter-increment: spec-step;
}

.spec-method-list li::before {
    content: counter(spec-step) '.';
    position: absolute;
    left: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: var(--sand);
    width: 1.5rem;
    text-align: right;
}

.spec-expand-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(200,169,126,0.08);
    border: 1px solid rgba(200,169,126,0.15);
    border-radius: 4px;
    color: var(--sand);
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
    margin-top: 0.5rem;
}

.spec-expand-btn:hover {
    background: rgba(200,169,126,0.15);
    border-color: rgba(200,169,126,0.3);
}

.spec-expand-btn.expanded {
    border-color: var(--sand);
}

.spec-expand-icon {
    width: 14px;
    height: 14px;
    transition: transform 0.2s;
    margin-left: auto;
}

.spec-expand-btn.expanded .spec-expand-icon {
    transform: rotate(180deg);
}

.spec-expand-content {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

/* SECTION HEADERS */
.section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.section-label {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--sand);
    margin-bottom: 0.75rem;
}

/* RECOMMENDATIONS */
.rec-list {
    list-style: none;
}

.rec-list li {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(200,169,126,0.05);
    font-size: 0.9rem;
    line-height: 1.5;
}

.rec-list li .rec-num {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    color: var(--sand);
    flex-shrink: 0;
    width: 24px;
}

/* EMPTY STATE */
.empty-state {
    text-align: center;
    padding: 5rem 2rem;
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    color: var(--ghost);
    opacity: 0.3;
}

.empty-state h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--ghost);
    font-size: 0.9rem;
    margin-bottom: 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

/* BREADCRUMB */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--ghost);
    margin-bottom: 1.5rem;
}

.breadcrumb a {
    color: var(--sand);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--sand-light);
}

.breadcrumb svg {
    width: 12px;
    height: 12px;
    opacity: 0.4;
}

/* TOAST */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.85rem 1.5rem;
    background: var(--deep);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    z-index: 999;
    animation: slideUp 0.3s ease;
    max-width: 400px;
}

.toast.success { border-color: rgba(85,176,138,0.3); color: var(--green); }
.toast.error { border-color: rgba(224,85,85,0.3); color: var(--red); }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* RESPONSIVE */
@media (max-width: 768px) {
    main { padding: 4.5rem 1rem 2rem; }
    .app-nav { padding: 0.75rem 1rem; }
    .logo-sub { display: none; }
    .form-row { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .photo-grid { grid-template-columns: repeat(2, 1fr); }
    .report-header { flex-direction: column; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .defect-table { font-size: 0.8rem; }
    .defect-table th, .defect-table td { padding: 0.5rem; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .photo-grid { grid-template-columns: 1fr; }
}
