:root {
    --mw-blue: #0d6efd;
    --mw-blue-dark: #0a2f66;
    --mw-black: #111827;
    --mw-soft: #f4f8ff;
    --mw-border: #d9e4f2;
}

* {
    letter-spacing: 0;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--mw-black);
    background: linear-gradient(180deg, #ffffff 0%, #edf5ff 100%);
    font-family: "Segoe UI", Arial, sans-serif;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    width: 286px;
    height: 100vh;
    padding: 22px;
    color: #fff;
    background: #07172f;
    border-right: 1px solid rgba(255, 255, 255, .08);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 0 22px;
    color: #fff;
    text-decoration: none;
}

.brand-logo-wrap {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 72px;
    height: 52px;
    padding: 5px;
    background: #fff;
    border: 1px solid rgba(255, 255, 255, .7);
    border-radius: 8px;
}

.brand-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    color: #a9bdd6;
    font-size: .78rem;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    color: #bfd0e5;
    border-radius: 8px;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #fff;
    background: rgba(13, 110, 253, .22);
}

.nav-submenu {
    display: grid;
    gap: 2px;
    margin: -2px 0 4px 18px;
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, .12);
}

.sidebar .nav-sublink {
    min-height: 34px;
    padding: 6px 10px;
    font-size: .9rem;
}

.sidebar .nav-sublink i {
    font-size: .9rem;
}

.sidebar .nav-sublink.active {
    background: rgba(13, 110, 253, .32);
}

.sidebar-card {
    position: absolute;
    right: 22px;
    bottom: 22px;
    left: 22px;
    padding: 16px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 8px;
}

.sidebar-card small,
.sidebar-card span {
    display: block;
    color: #a9bdd6;
}

.main-panel {
    flex: 1;
    min-width: 0;
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(1.6rem, 2vw, 2.35rem);
    font-weight: 800;
    color: var(--mw-blue-dark);
}

.topbar p {
    margin: 4px 0 0;
    color: #5d6b7b;
}

.eyebrow {
    margin: 0 0 6px !important;
    font-size: .76rem;
    font-weight: 800;
    color: var(--mw-blue) !important;
    text-transform: uppercase;
}

.topbar-actions,
.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.content-card,
.stat-card,
.login-card {
    background: rgba(255, 255, 255, .92);
    border: 1px solid var(--mw-border);
    border-radius: 8px;
    box-shadow: 0 20px 48px rgba(11, 47, 102, .08);
}

.content-card {
    padding: 18px;
    margin-bottom: 18px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
}

.stat-icon {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 8px;
}

.stat-card small {
    display: block;
    color: #6b7280;
}

.stat-card strong {
    display: block;
    font-size: 1.55rem;
    line-height: 1.15;
}

.toolbar {
    justify-content: flex-end;
    margin-bottom: 16px;
}

.search-box {
    max-width: 330px;
}

.table {
    margin-bottom: 0;
}

.table th {
    color: #304053;
    font-size: .8rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.machine-thumb {
    width: 58px;
    height: 42px;
    object-fit: cover;
    border-radius: 6px;
}

.machine-photo-cell {
    position: relative;
    width: 72px;
}

.machine-photo-button {
    display: inline-grid;
    place-items: center;
    padding: 0;
    background: transparent;
    border: 0;
}

.machine-photo-button:focus-visible {
    outline: 3px solid rgba(13, 110, 253, .35);
    outline-offset: 3px;
    border-radius: 8px;
}

.photo-count-badge {
    position: absolute;
    right: 6px;
    bottom: 7px;
    min-width: 20px;
    padding: 1px 6px;
    color: #fff;
    background: #0a2f66;
    border: 2px solid #fff;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
}

.modal-subtitle {
    margin: 3px 0 0;
    color: #64748b;
    font-size: .9rem;
}

.machine-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.machine-gallery-item {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: #e9f0f8;
    border: 1px solid var(--mw-border);
    border-radius: 8px;
}

.machine-gallery-link {
    display: block;
    width: 100%;
    height: 100%;
}

.machine-gallery-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .18s ease;
}

.machine-gallery-item:hover .machine-gallery-link img {
    transform: scale(1.03);
}

.gallery-primary-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 3px 8px;
    color: #fff;
    background: rgba(10, 47, 102, .9);
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
}

.gallery-delete-form {
    position: absolute;
    right: 10px;
    top: 10px;
}

.gallery-delete-form .btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, .22);
}

.empty-gallery {
    display: grid;
    place-items: center;
    min-height: 220px;
    color: #64748b;
    text-align: center;
    background: #f8fbff;
    border: 1px dashed #9db7d8;
    border-radius: 8px;
}

.empty-gallery i {
    font-size: 2rem;
}

.empty-gallery p {
    margin: 6px 0 0;
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 6px;
    border-radius: 999px;
}

.form-section {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.span-2 {
    grid-column: span 2;
}

.span-3 {
    grid-column: span 3;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-group form {
    display: inline-flex;
}

.btn-group form .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.thumb-placeholder {
    display: grid;
    place-items: center;
    width: 58px;
    height: 42px;
    color: #64748b;
    background: #e9f0f8;
    border: 1px solid var(--mw-border);
    border-radius: 6px;
}

.photo-dropzone {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 112px;
    padding: 14px;
    cursor: pointer;
    background: #f8fbff;
    border: 1px dashed #9db7d8;
    border-radius: 8px;
    transition: border-color .15s ease, background-color .15s ease;
}

.photo-dropzone:hover,
.photo-dropzone.is-dragging {
    background: #eef6ff;
    border-color: var(--mw-blue);
}

.photo-dropzone input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.photo-dropzone strong,
.photo-dropzone small {
    display: block;
}

.photo-dropzone small {
    margin-top: 3px;
    color: #64748b;
}

.photo-preview {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 96px;
    height: 72px;
    color: #64748b;
    background: #e9f0f8;
    border: 1px solid var(--mw-border);
    border-radius: 6px;
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
}

.photo-preview.is-empty i {
    font-size: 1.7rem;
}

.photo-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.photo-chip {
    display: block;
    width: 74px;
    height: 54px;
    background: #e9f0f8;
    border: 1px solid var(--mw-border);
    border-radius: 6px;
    overflow: hidden;
}

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

.mock-note {
    padding: 12px 14px;
    color: #084298;
    background: #dbeafe;
    border: 1px solid #b6d4fe;
    border-radius: 8px;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(rgba(7, 23, 47, .68), rgba(7, 23, 47, .82)),
        url("https://images.unsplash.com/photo-1581092160607-ee22731c9c5c?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-card {
    width: min(100%, 440px);
    padding: 30px;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.login-logo-wrap {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 116px;
    height: 82px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--mw-border);
    border-radius: 8px;
}

.login-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.login-logo h1 {
    margin: 0;
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--mw-blue-dark);
}

.login-logo p {
    margin: 0;
    color: #667085;
}

.approval-lane {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.lane-title {
    margin-bottom: 12px;
    font-size: .9rem;
    font-weight: 800;
    color: var(--mw-blue-dark);
    text-transform: uppercase;
}

@media (max-width: 1100px) {
    .stat-grid,
    .form-section,
    .approval-lane {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .span-3 {
        grid-column: span 2;
    }
}

@media (max-width: 860px) {
    .app-shell {
        display: block;
    }

    .sidebar {
        position: static;
        width: auto;
        height: auto;
    }

    .sidebar-card {
        position: static;
        margin-top: 18px;
    }

    .topbar,
    .toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions,
    .toolbar,
    .search-box {
        width: 100%;
    }

    .toolbar .btn,
    .topbar-actions .btn {
        width: 100%;
    }
}

@media (max-width: 620px) {
    .main-panel {
        padding: 18px;
    }

    .stat-grid,
    .form-section,
    .approval-lane {
        grid-template-columns: 1fr;
    }

    .span-2,
    .span-3 {
        grid-column: span 1;
    }

    .form-actions {
        flex-direction: column;
    }
}
