:root {
    --bg: #f7f8fb;
    --surface: #ffffff;
    --surface-soft: #f5f7fb;
    --surface-tint: #f9fafb;
    --text: #111827;
    --muted: #667085;
    --muted-2: #98a2b3;
    --line: #e6e8ef;
    --line-strong: #d0d5dd;
    --brand: #2563eb;
    --brand-strong: #1d4ed8;
    --brand-soft: #eff6ff;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --shadow-border: 0 0 0 1px rgba(17, 24, 39, 0.08);
    --shadow-card: 0 0 0 1px rgba(17, 24, 39, 0.08), 0 12px 30px rgba(17, 24, 39, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 32rem),
        linear-gradient(180deg, #ffffff 0%, var(--bg) 26rem, var(--bg) 100%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.dashboard-shell {
    padding-bottom: 3rem;
}

.topbar {
    padding: 1rem 0 0.75rem;
}

.topbar .navbar {
    background: rgba(255, 255, 255, 0.86) !important;
    border-radius: 18px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(18px);
}

.brand-mark {
    width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: #ffffff;
    background: linear-gradient(135deg, #111827, #2563eb);
}

.navbar-brand {
    color: var(--text) !important;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.navbar-toggler {
    color: var(--text);
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.08;
}

.brand-copy small {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 500;
}

.nav-pills-wrap {
    display: flex;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: 999px;
    background: #f2f4f7;
    box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.06);
}

.nav-link {
    border-radius: 999px;
    color: var(--muted) !important;
    font-weight: 600;
    padding: 0.68rem 0.95rem !important;
    transition: 160ms ease;
}

.nav-link:hover {
    color: var(--text) !important;
    background: rgba(255, 255, 255, 0.72);
}

.nav-link.active {
    color: var(--text) !important;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.08), 0 0 0 1px rgba(17, 24, 39, 0.06);
}

.portfolio-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    min-height: 2.45rem;
    padding: 0.62rem 0.9rem;
    border-radius: 999px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow-border);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    transition: 160ms ease;
}

.portfolio-link:hover {
    color: var(--brand-strong);
    background: #ffffff;
    transform: translateY(-1px);
}

.account-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem 0.45rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    box-shadow: var(--shadow-border);
    color: var(--muted);
    font-size: 0.82rem;
    max-width: 18rem;
}

.account-pill strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    font-weight: 700;
}

.account-pill a {
    flex: 0 0 auto;
    border-radius: 999px;
    padding: 0.36rem 0.62rem;
    background: var(--text);
    color: #fff;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
}

.account-pill a.secondary {
    background: #f3f4f6;
    color: var(--text);
    box-shadow: var(--shadow-border);
}

.hero-panel,
.dashboard-card,
.summary-card,
.result-card,
.preview-item,
.preview-box {
    background: var(--surface);
    box-shadow: var(--shadow-card);
}

.hero-panel {
    position: relative;
    overflow: hidden;
    border-radius: 26px;
    padding: 2rem;
}

.hero-panel::after {
    content: "";
    position: absolute;
    right: -8rem;
    bottom: -10rem;
    width: 22rem;
    height: 22rem;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(37, 99, 235, 0.10), transparent 68%);
    pointer-events: none;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.38rem 0.7rem;
    border-radius: 999px;
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-size: 0.82rem;
    font-weight: 700;
}

.hero-title {
    max-width: 42rem;
    font-size: clamp(1.75rem, 3vw, 2.35rem);
    line-height: 1.16;
    letter-spacing: -0.035em;
    margin: 0.85rem 0 0.75rem;
}

.hero-copy {
    max-width: 46rem;
    color: var(--muted);
    margin-bottom: 0;
    line-height: 1.72;
}

.hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.hero-metric {
    border-radius: 18px;
    padding: 1rem;
    background: var(--surface-tint);
    box-shadow: var(--shadow-border);
}

.hero-metric-label {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-bottom: 0.35rem;
}

.hero-metric-value {
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.dashboard-card {
    border-radius: 24px;
    padding: 1.5rem;
}

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.section-heading h2,
.section-heading h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.section-heading p {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.section-icon {
    width: 2.6rem;
    height: 2.6rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    color: var(--brand);
    background: var(--brand-soft);
}

.upload-zone {
    border: 1.5px dashed #b9c2d0;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
    border-radius: 22px;
    padding: 2.15rem 1.4rem;
    text-align: center;
    cursor: pointer;
    transition: 160ms ease;
}

.upload-zone:hover,
.upload-zone.dragover {
    transform: translateY(-1px);
    border-color: var(--brand);
    background: #f8fbff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.08);
}

.upload-zone .upload-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 1.2rem;
    color: var(--brand);
    background: var(--brand-soft);
    font-size: 1.9rem;
}

.upload-zone h5 {
    font-size: 1.12rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.upload-zone p {
    color: var(--muted);
}

.hint-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-top: 1rem;
}

.hint-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.42rem;
    padding: 0.45rem 0.75rem;
    border-radius: 999px;
    color: #344054;
    background: #ffffff;
    box-shadow: var(--shadow-border);
    font-size: 0.82rem;
    font-weight: 600;
}

.form-panel {
    height: 100%;
    border-radius: 22px;
    padding: 1.35rem;
    background: #fbfcfe;
    box-shadow: var(--shadow-border);
}

.form-label,
.form-text,
.text-muted,
.small {
    color: var(--muted) !important;
}

.form-label {
    font-weight: 700;
    margin-bottom: 0.55rem;
}

.form-control,
.form-select {
    min-height: 3rem;
    color: var(--text);
    background-color: #ffffff;
    border-color: var(--line);
    border-radius: 12px;
}

.form-control::placeholder {
    color: var(--muted-2);
}

.form-control:focus,
.form-select:focus {
    color: var(--text);
    background-color: #ffffff;
    border-color: var(--brand);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.12);
}

.form-select:disabled {
    color: var(--muted-2);
    background-color: #f2f4f7;
}

.form-range {
    height: 2rem;
}

.form-range::-webkit-slider-runnable-track {
    height: 0.45rem;
    border-radius: 999px;
    background: linear-gradient(90deg, #93c5fd, #2563eb);
}

.form-range::-webkit-slider-thumb {
    width: 1rem;
    height: 1rem;
    margin-top: -0.28rem;
    border: 0;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(17, 24, 39, 0.12), 0 0 0 6px rgba(37, 99, 235, 0.12);
}

.form-range::-moz-range-track {
    height: 0.45rem;
    border-radius: 999px;
    background: linear-gradient(90deg, #93c5fd, #2563eb);
}

.form-range::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
    border: 0;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 0 1px rgba(17, 24, 39, 0.12), 0 0 0 6px rgba(37, 99, 235, 0.12);
}

.range-meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.82rem;
    color: var(--muted);
}

.btn {
    border-radius: 12px;
    font-weight: 700;
}

.btn-primary {
    border: 0;
    color: #ffffff;
    background: #111827;
    box-shadow: 0 8px 18px rgba(17, 24, 39, 0.14);
}

.btn-primary:hover,
.btn-primary:focus {
    color: #ffffff;
    background: #1f2937;
}

.btn-primary:disabled {
    color: #ffffff;
    background: #98a2b3;
    box-shadow: none;
}

.btn-outline-light,
.btn-outline-secondary {
    color: var(--text);
    border-color: var(--line);
    background: #ffffff;
}

.btn-outline-light:hover,
.btn-outline-light:focus,
.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    color: var(--text);
    border-color: var(--line-strong);
    background: #f9fafb;
}

.model-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.62rem 0.86rem;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 700;
    white-space: nowrap;
}

.model-status.loading {
    color: #92400e;
    background: #fffbeb;
    box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.20);
}

.model-status.loaded {
    color: #166534;
    background: #f0fdf4;
    box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.18);
}

.model-status.not-loaded {
    color: #991b1b;
    background: #fef2f2;
    box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.18);
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}

.preview-item {
    position: relative;
    overflow: hidden;
    border-radius: 18px;
}

.preview-item img {
    width: 100%;
    height: 136px;
    object-fit: cover;
}

.preview-item .filename {
    padding: 0.8rem 0.9rem 0.95rem;
    color: #344054;
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-item .remove-btn {
    position: absolute;
    top: 0.65rem;
    right: 0.65rem;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    color: #ffffff;
    background: rgba(220, 38, 38, 0.92);
}

.preview-box {
    border-radius: 18px;
    padding: 1.15rem;
}

.preview-box .fw-semibold,
.result-card .filename,
.result-card .fw-semibold,
.text-white {
    color: var(--text) !important;
}

.progress-shell {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: var(--shadow-border);
}

.progress {
    height: 0.55rem;
    border-radius: 999px;
    background: #e5e7eb;
}

.progress-bar {
    border-radius: 999px;
    background: linear-gradient(90deg, #60a5fa 0%, #2563eb 100%);
}

.summary-card {
    border-radius: 18px;
    padding: 1.25rem;
    text-align: left;
}

.summary-card .summary-label {
    display: block;
    color: var(--muted);
    font-size: 0.84rem;
    margin-bottom: 0.38rem;
}

.summary-card h3 {
    margin: 0;
    color: var(--text);
    font-size: clamp(1.8rem, 4vw, 2.35rem);
    font-weight: 800;
    letter-spacing: -0.04em;
}

.summary-card.total h3 {
    color: #1d4ed8;
}

.summary-card.success h3 {
    color: #15803d;
}

.summary-card.detected h3 {
    color: #b91c1c;
}

.summary-card.highlight h3 {
    color: #0f766e;
}

.result-card {
    height: 100%;
    overflow: hidden;
    border-radius: 18px;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18), 0 14px 28px rgba(17, 24, 39, 0.08);
}

.result-card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    cursor: pointer;
}

.result-card .info {
    padding: 1rem 1rem 1.15rem;
}

.result-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    color: var(--muted);
    font-size: 0.82rem;
}

.badge-detected,
.badge-empty {
    border-radius: 999px;
    padding: 0.42rem 0.68rem;
    font-weight: 700;
}

.badge-detected {
    color: #991b1b;
    background: #fef2f2;
    box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.16);
}

.badge-empty {
    color: #166534;
    background: #f0fdf4;
    box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.16);
}

.result-error {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    background: #fef2f2;
}

.result-error i {
    font-size: 2.6rem;
}

.modal-content {
    border: 0;
    background: #ffffff;
    box-shadow: var(--shadow-card);
}

.modal-header {
    border-bottom-color: var(--line) !important;
}

.modal-title,
.btn-close {
    color: var(--text);
}

.btn-close-white {
    filter: none !important;
}

.modal-fullscreen-image .modal-body {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #05070c;
}

.modal-fullscreen-image img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.status-stack {
    display: grid;
    gap: 0.85rem;
}

.status-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.95rem 1rem;
    border-radius: 16px;
    background: #ffffff;
    box-shadow: var(--shadow-border);
}

.status-chip strong {
    display: block;
    font-size: 0.92rem;
    color: var(--text);
}

.status-chip span {
    color: var(--muted);
    font-size: 0.82rem;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

@media (max-width: 991.98px) {
    .topbar .navbar {
        border-radius: 18px;
    }

    .nav-pills-wrap {
        width: 100%;
        margin-top: 1rem;
        justify-content: stretch;
    }

    .account-pill {
        width: 100%;
        max-width: none;
        justify-content: flex-end;
        margin-top: 0.25rem;
    }

    .nav-pills-wrap .nav-link {
        flex: 1;
        text-align: center;
    }

    .hero-metrics {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    body {
        overflow-x: hidden;
    }

    .dashboard-shell {
        padding-bottom: 2rem;
    }

    .topbar {
        padding-top: 0.75rem;
    }

    .topbar .container,
    main.container {
        padding-left: 0.85rem;
        padding-right: 0.85rem;
    }

    .topbar .navbar {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .navbar-brand {
        min-width: 0;
        max-width: calc(100% - 3.25rem);
    }

    .brand-copy {
        min-width: 0;
    }

    .brand-copy span,
    .brand-copy small {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .hero-panel,
    .dashboard-card {
        border-radius: 20px;
        padding: 1.2rem;
    }

    .hero-title {
        font-size: clamp(1.55rem, 8vw, 2rem);
    }

    .section-heading {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-icon {
        display: none;
    }

    .upload-zone {
        padding: 1.5rem 1rem;
    }

    .hint-row {
        gap: 0.5rem;
    }

    .hint-chip {
        flex: 1 1 100%;
        justify-content: center;
    }

    .form-panel {
        padding: 1rem;
    }

    .btn {
        min-height: 44px;
    }

    .result-card img,
    .result-error {
        min-height: 0;
        height: 190px;
    }
}

@media (max-width: 420px) {
    .hero-panel,
    .dashboard-card,
    .form-panel {
        padding: 1rem;
    }

    .nav-pills-wrap {
        border-radius: 18px;
        flex-direction: column;
    }

    .hero-metric {
        padding: 0.85rem;
    }
}
