/* ================================================================
   QuarterMaster — Design System
   ================================================================ */

/* ---- Design Tokens ---- */
:root {
    /* Brand / Primary */
    --primary: #1e3a5f;
    --primary-dark: #152d4a;
    --primary-light: #2a4d7a;
    --primary-subtle: #e8eef5;

    /* Accent (interactive) */
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-subtle: #eff6ff;
    --accent-border: #dbeafe;

    /* Surfaces */
    --bg: #f0f4f8;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;

    /* Borders */
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --border-strong: #cbd5e1;

    /* Text */
    --text: #0f172a;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    --text-faint: #9ca3af;

    /* Status */
    --success-bg: #dcfce7;
    --success-text: #166534;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --warning-bg: #fef9c3;
    --warning-text: #854d0e;
    --neutral-bg: #f3f4f6;
    --neutral-text: #6b7280;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, .1), 0 2px 4px rgba(0, 0, 0, .05);
    --shadow-lg: 0 10px 32px rgba(0, 0, 0, .14), 0 4px 8px rgba(0, 0, 0, .06);
    --shadow-card-hover: 0 8px 24px rgba(37, 99, 235, .12), 0 2px 6px rgba(0, 0, 0, .06);

    /* Radii */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-xl: 14px;

    /* Transitions */
    --t-fast: .12s ease;
    --t-base: .18s ease;
    --t-slow: .28s ease;
}

/* ---- Animations ---- */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRow {
    from {
        opacity: 0;
        transform: translateX(-4px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes cardReveal {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

@keyframes shimmer {
    0% {
        background-position: -400px 0;
    }

    100% {
        background-position: 400px 0;
    }
}

@keyframes pulseIn {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(.97);
    }

    100% {
        transform: scale(1);
    }
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ---- Navbar ---- */
.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 1.75rem;
    height: 58px;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .22), 0 1px 3px rgba(0, 0, 0, .12);
    border-bottom: 3px solid var(--accent);
}

.nav-brand a {
    color: white;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: .2px;
    transition: opacity var(--t-fast);
}

.nav-brand a:hover {
    opacity: .85;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: .15rem;
    flex: 1;
}

.nav-links a {
    color: rgba(255, 255, 255, .75);
    padding: .42rem .85rem;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    transition: background var(--t-fast), color var(--t-fast);
    position: relative;
}

.nav-links a:hover {
    background: rgba(255, 255, 255, .14);
    color: white;
    text-decoration: none;
}

.nav-links a.nav-active {
    background: rgba(255, 255, 255, .18);
    color: white;
    font-weight: 600;
}

.nav-links a.nav-active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: .5rem;
    right: .5rem;
    height: 3px;
    background: white;
    border-radius: 2px 2px 0 0;
}

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

.nav-user a {
    color: rgba(255, 255, 255, .7);
    transition: color var(--t-fast);
}

.nav-user a:hover {
    color: white;
    text-decoration: none;
}

.nav-user span {
    color: rgba(255, 255, 255, .9);
}

/* ---- Container ---- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.75rem 1.75rem;
}

/* ---- Page Header ---- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
    animation: fadeSlideIn var(--t-slow) both;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.section-header {
    margin: 2rem 0 .85rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: .6rem;
}

.section-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    line-height: 1;
    transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.btn:hover {
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px) scale(.98);
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .3);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border-color: var(--border-strong);
}

.btn-secondary:hover {
    background: var(--surface-2);
    box-shadow: var(--shadow-xs);
    color: var(--text-secondary);
}

.btn-danger {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

.btn-danger:hover {
    background: #b91c1c;
    color: white;
}

.btn-sm {
    padding: .32rem .65rem;
    font-size: 13px;
}

.btn-full {
    width: 100%;
    justify-content: center;
}

.btn-group {
    display: flex;
    gap: .5rem;
}

/* View switcher */
.view-switcher {
    display: flex;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.view-switcher button {
    background: var(--surface);
    border: none;
    padding: .38rem .65rem;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-muted);
    transition: background var(--t-fast), color var(--t-fast);
    line-height: 1;
}

.view-switcher button:hover {
    background: var(--surface-3);
    color: var(--text-secondary);
}

.view-switcher button.vs-active {
    background: var(--primary);
    color: white;
}

/* ---- Alerts ---- */
.alert {
    padding: .85rem 1.1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.1rem;
    font-size: 14px;
    animation: fadeSlideIn var(--t-base) both;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

/* ---- Tables ---- */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.table th {
    background: var(--surface-2);
    text-align: left;
    padding: .75rem 1.1rem;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background var(--t-fast);
}

.table tbody tr:hover td {
    background: #fafbff;
}

/* Staggered row slide-in */
.table tbody tr:nth-child(1) {
    animation: slideInRow var(--t-slow) .03s both;
}

.table tbody tr:nth-child(2) {
    animation: slideInRow var(--t-slow) .06s both;
}

.table tbody tr:nth-child(3) {
    animation: slideInRow var(--t-slow) .09s both;
}

.table tbody tr:nth-child(4) {
    animation: slideInRow var(--t-slow) .12s both;
}

.table tbody tr:nth-child(5) {
    animation: slideInRow var(--t-slow) .15s both;
}

.table tbody tr:nth-child(6) {
    animation: slideInRow var(--t-slow) .18s both;
}

.table tbody tr:nth-child(7) {
    animation: slideInRow var(--t-slow) .21s both;
}

.table tbody tr:nth-child(8) {
    animation: slideInRow var(--t-slow) .24s both;
}

.table tbody tr:nth-child(n+9) {
    animation: slideInRow var(--t-slow) .27s both;
}

.deleted-row td {
    color: var(--text-faint);
}

.actions {
    display: flex;
    gap: .5rem;
}

.nowrap {
    white-space: nowrap;
}

.mono {
    font-family: 'SFMono-Regular', Consolas, monospace;
    font-size: 13px;
}

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

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

/* ---- Badges & Status ---- */
.badge {
    display: inline-block;
    padding: .18rem .55rem;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    background: var(--neutral-bg);
    color: var(--neutral-text);
    text-transform: uppercase;
    letter-spacing: .3px;
}

.badge-green {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-red {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .25rem .7rem;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-active {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-active::before {
    background: #22c55e;
}

.status-inactive {
    background: var(--neutral-bg);
    color: var(--neutral-text);
}

.status-inactive::before {
    background: #9ca3af;
}

.status-lost {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.status-lost::before {
    background: #f59e0b;
}

.status-damaged {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.status-damaged::before {
    background: #ef4444;
}

.role-badge {
    display: inline-block;
    padding: .18rem .55rem;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
}

.role-admin {
    background: #fef3c7;
    color: #92400e;
}

.role-editor {
    background: #dbeafe;
    color: #1e40af;
}

.role-readonly {
    background: var(--neutral-bg);
    color: var(--neutral-text);
}

/* ---- Forms ---- */
.form-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    box-shadow: var(--shadow-sm);
}

.form-narrow {
    max-width: 540px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    flex: 1;
    margin-bottom: 1.4rem;
}

.form-group label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.4rem;
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
    padding: .6rem .85rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-family: inherit;
    width: 100%;
    background: var(--surface);
    color: var(--text);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    gap: .85rem;
    padding-top: 1.1rem;
    border-top: 1px solid var(--border-light);
    margin-top: .6rem;
}

.field-hint {
    font-size: 13px;
    color: var(--text-faint);
    margin-top: .3rem;
}

.req {
    color: #dc2626;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    font-weight: normal !important;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

/* ---- Detail View ---- */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.75rem;
    margin-bottom: 2.25rem;
}

.detail-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    box-shadow: var(--shadow-sm);
}

.detail-card h3 {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 1.1rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

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

.card-header h3 {
    margin: 0;
}

.detail-list {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: .45rem .85rem;
}

.detail-list dt {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .3px;
    align-self: start;
    padding-top: .1rem;
}

.detail-list dd {
    font-size: 15px;
    color: var(--text);
}

/* ---- Dashboard ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.1rem;
    margin-bottom: 2.25rem;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.4rem 1.6rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: box-shadow var(--t-base), transform var(--t-base);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-muted .stat-num {
    color: var(--text-faint);
}

.stat-num {
    font-size: 2.1rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: .4rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.quick-actions {
    display: flex;
    gap: .85rem;
    margin-bottom: 2.25rem;
    flex-wrap: wrap;
}

/* ---- Search ---- */
.search-bar {
    margin-bottom: 1.75rem;
}

.search-bar input {
    max-width: 600px;
    font-size: 16px;
    padding: .7rem 1.1rem;
}

/* ---- HTMX Loading Indicators ---- */
.htmx-indicator {
    display: none;
    opacity: 0;
    transition: opacity var(--t-base);
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-flex;
    opacity: 1;
}

.search-spinner {
    position: absolute;
    right: .9rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    pointer-events: none;
}

/* Skeleton shimmer */
.skeleton-rows {
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    padding: .5rem 0;
}

.skeleton-row {
    display: flex;
    gap: 1rem;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--border-light);
}

.skeleton-row:last-child {
    border-bottom: none;
}

.skeleton-cell {
    height: 14px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--border-light) 50%, var(--surface-3) 75%);
    background-size: 400px 100%;
    animation: shimmer 1.4s infinite;
}

/* ---- Auth ---- */
.auth-wrap {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-box {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 2.75rem;
    width: 380px;
    box-shadow: var(--shadow-lg);
}

.auth-box h1 {
    text-align: center;
    margin-bottom: .3rem;
    color: var(--primary);
    font-size: 1.6rem;
}

.auth-sub {
    text-align: center;
    color: var(--text-faint);
    margin-bottom: 2.25rem;
    font-size: 15px;
}

/* ---- Assign Form ---- */
.assign-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
}

.assign-form .form-row {
    margin-bottom: .75rem;
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 2.25rem;
    max-width: 460px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: fadeSlideIn var(--t-base) both;
}

.modal h3 {
    margin-bottom: 1.1rem;
    color: #dc2626;
}

/* ---- Inventory ---- */
.inventory-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.75rem;
    margin-top: 1.1rem;
}

.inv-option {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.4rem;
}

.inv-option h4 {
    margin-bottom: .5rem;
    color: var(--primary);
}

.inv-option select {
    margin: .75rem 0;
}

.inv-print-controls {
    margin-bottom: 1.75rem;
    display: flex;
    gap: .85rem;
}

.print-doc {
    background: var(--surface);
    padding: 2.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.print-header {
    border-bottom: 2px solid var(--primary);
    padding-bottom: 1.1rem;
    margin-bottom: 1.75rem;
}

.print-header h2 {
    font-size: 1.35rem;
    color: var(--primary);
}

.print-meta {
    display: flex;
    gap: 2rem;
    margin-top: .6rem;
    font-size: 14px;
    color: var(--text-muted);
}

.print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.print-table th {
    background: var(--surface-2);
    padding: .6rem .85rem;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 2px solid var(--border);
}

.print-table td {
    padding: .65rem .85rem;
    border-bottom: 1px solid var(--border-light);
}

.check-cell {
    text-align: center;
}

.checkbox-print {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--text-muted);
    border-radius: 3px;
}

.print-footer {
    margin-top: 2.75rem;
    padding-top: 1.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 3rem;
}

.sig-line {
    font-size: 14px;
    color: var(--text-muted);
    padding-bottom: .85rem;
    border-bottom: 1px solid var(--border-strong);
    min-width: 200px;
}

.help-text {
    margin-top: 1.1rem;
    font-size: 14px;
    color: var(--text-muted);
    background: var(--surface-2);
    padding: .85rem 1.1rem;
    border-radius: var(--radius-md);
}

/* ---- Print ---- */
@media print {

    .no-print,
    .navbar,
    .btn,
    .quick-actions {
        display: none !important;
    }

    body {
        background: white;
        font-size: 12px;
    }

    .container {
        padding: 0;
        max-width: 100%;
    }

    .print-doc {
        box-shadow: none;
        padding: 0;
    }

    .print-table td,
    .print-table th {
        padding: .4rem .5rem;
    }

    .checkbox-print {
        border: 1.5px solid black;
    }

    a {
        color: inherit;
    }

    .print-footer {
        margin-top: 2rem;
    }
}

/* ---- Table scroll wrapper ---- */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
}

.table-wrap .table {
    border-radius: 0;
}

/* ---- Assets Page ---- */
.assets-header {
    margin-bottom: 2rem;
    animation: fadeSlideIn var(--t-slow) both;
}

.assets-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.4rem;
}

.assets-title-row h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.assets-actions {
    display: flex;
    gap: .6rem;
    align-items: center;
}

.assets-search-wrap {
    position: relative;
}

.assets-search-inner {
    position: relative;
}

.search-icon {
    position: absolute;
    left: .9rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
    color: var(--text-faint);
    pointer-events: none;
}

.assets-search-inner input {
    width: 100%;
    padding: .7rem 2.6rem .7rem 2.6rem;
    font-size: 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.assets-search-inner input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
    outline: none;
}

.search-results-section {
    margin-bottom: 1.75rem;
}

.search-results-header {
    padding: .7rem 0;
    margin-bottom: .85rem;
    font-size: 14px;
    color: var(--text-muted);
}

.search-no-results {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 3.25rem 2.25rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.search-no-results .empty-icon {
    font-size: 2.1rem;
    margin-bottom: .85rem;
    display: block;
}

.search-no-results p {
    font-size: 15px;
    color: var(--text-faint);
}

/* ---- Type Cards Grid ---- */
.type-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.1rem;
}

.type-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1.5px solid var(--border);
    overflow: hidden;
    transition: box-shadow var(--t-base), border-color var(--t-base), transform var(--t-base);
    text-decoration: none;
    display: block;
    color: inherit;
}

.type-card:nth-child(1) {
    animation: cardReveal var(--t-slow) .04s both;
}

.type-card:nth-child(2) {
    animation: cardReveal var(--t-slow) .08s both;
}

.type-card:nth-child(3) {
    animation: cardReveal var(--t-slow) .12s both;
}

.type-card:nth-child(4) {
    animation: cardReveal var(--t-slow) .16s both;
}

.type-card:nth-child(5) {
    animation: cardReveal var(--t-slow) .20s both;
}

.type-card:nth-child(n+6) {
    animation: cardReveal var(--t-slow) .24s both;
}

.type-card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: var(--accent-border);
    transform: translateY(-3px);
    text-decoration: none;
    color: inherit;
}

.type-card-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.4rem 1.6rem;
    gap: 1rem;
}

.type-card-info {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.type-card-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

.type-card-count {
    font-size: 13px;
    color: var(--text-faint);
}

.type-card-meta {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-shrink: 0;
}

.type-pill {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    background: var(--accent-subtle);
    color: var(--accent);
    padding: .22rem .55rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent-border);
}

.type-arrow {
    font-size: 1.2rem;
    color: #c7d2fe;
    transition: transform var(--t-base), color var(--t-base);
}

.type-card:hover .type-arrow {
    transform: translateX(4px);
    color: var(--accent);
}

/* ---- Empty States ---- */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4.25rem 2.25rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-strong);
    animation: fadeSlideIn var(--t-slow) .1s both;
}

.empty-icon {
    font-size: 3.1rem;
    margin-bottom: 1.1rem;
    display: block;
}

.empty-state h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .6rem;
}

.empty-state p {
    color: var(--text-faint);
    margin-bottom: 1.75rem;
    font-size: 15px;
    max-width: 340px;
    margin-left: auto;
    margin-right: auto;
}

/* Entity type page empty state */
.empty-state-page {
    text-align: center;
    padding: 4.25rem 2.25rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-strong);
    margin-top: .6rem;
    animation: fadeSlideIn var(--t-slow) .1s both;
}

.empty-state-page .empty-icon {
    font-size: 2.85rem;
    margin-bottom: 1.1rem;
    display: block;
}

.empty-state-page h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .6rem;
}

.empty-state-page p {
    color: var(--text-faint);
    margin-bottom: 1.75rem;
    font-size: 14px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

/* ---- Entity Card View (asset type page) ---- */
.entity-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.entity-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--border);
    padding: 1.4rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--t-base), border-color var(--t-base), transform var(--t-base);
    display: block;
    text-decoration: none;
    color: inherit;
}

.entity-card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: var(--accent-border);
    transform: translateY(-2px);
    text-decoration: none;
    color: inherit;
}

.entity-card:nth-child(1) {
    animation: cardReveal var(--t-slow) .04s both;
}

.entity-card:nth-child(2) {
    animation: cardReveal var(--t-slow) .08s both;
}

.entity-card:nth-child(3) {
    animation: cardReveal var(--t-slow) .12s both;
}

.entity-card:nth-child(4) {
    animation: cardReveal var(--t-slow) .16s both;
}

.entity-card:nth-child(n+5) {
    animation: cardReveal var(--t-slow) .20s both;
}

.entity-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .75rem;
}

.entity-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    line-height: 1.3;
}

.entity-card-fields {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.entity-card-field {
    display: flex;
    gap: .5rem;
    align-items: baseline;
    font-size: 13px;
}

.entity-card-label {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .3px;
    font-size: 11px;
    color: var(--text-faint);
    min-width: 52px;
    flex-shrink: 0;
}

.entity-card-val {
    color: var(--text-secondary);
}

.entity-card-footer {
    margin-top: 1rem;
    padding-top: .85rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* View mode toggle helpers */
.view-table {}

.view-cards {
    display: none;
}

.in-card-view .view-table {
    display: none;
}

.in-card-view .view-cards {
    display: grid;
}

/* ---- Breadcrumb ---- */
.breadcrumb {
    font-size: 13px;
    color: var(--text-faint);
    margin-bottom: .35rem;
}

.breadcrumb a {
    color: var(--text-muted);
}

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

.breadcrumb span {
    margin: 0 .3rem;
}

/* ---- Import assign tag ---- */
.assign-tag {
    background: var(--accent-subtle);
    color: #1e40af;
    border: 1px solid var(--accent-border);
    border-radius: var(--radius-sm);
    padding: .12rem .45rem;
    font-size: 13px;
    white-space: nowrap;
}

.warn-note {
    color: #b45309;
    font-size: 13px;
}

/* ---- Sortable Table Headers ---- */
th.sortable {
    white-space: nowrap;
    user-select: none;
}

th.sortable a {
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .3rem;
}

th.sortable a:hover {
    color: var(--primary);
}

th.sort-active a {
    color: var(--primary);
}

.sort-idle {
    opacity: .35;
    font-size: 11px;
}

/* ---- Import ---- */
.badge-experimental {
    background: #fdf4ff;
    color: #7c3aed;
    border: 1px solid #e9d5ff;
}

.badge-yellow {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.import-intro {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-sm);
}

.import-intro p {
    margin-bottom: 1.1rem;
    color: var(--text-secondary);
}

.import-steps {
    list-style: none;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.import-steps li {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: 14px;
    color: var(--text-muted);
}

.step-num {
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.ai-summary {
    background: #fdf4ff;
    border: 1px solid #e9d5ff;
    border-radius: var(--radius-md);
    padding: 1.1rem 1.4rem;
    margin-bottom: 1.75rem;
    font-size: 15px;
    color: var(--text-secondary);
}

.ai-badge {
    background: #7c3aed;
    color: white;
    border-radius: var(--radius-sm);
    padding: .12rem .45rem;
    font-size: 12px;
    font-weight: 600;
    margin-right: .5rem;
}

.review-section {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-sm);
}

.review-section h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: .6rem;
}

.review-section>p {
    margin-bottom: 1.1rem;
    font-size: 14px;
    color: var(--text-muted);
}

.mapping-table select,
.mapping-table input[type="text"] {
    font-size: 14px;
    padding: .35rem .55rem;
}

.preview-stats {
    display: flex;
    gap: .85rem;
    margin-bottom: 1.1rem;
}

.preview-scroll {
    max-height: 400px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.preview-table {
    font-size: 13px;
}

.preview-table th {
    position: sticky;
    top: 0;
    z-index: 1;
}

.row-error td {
    color: var(--text-faint);
    background: #fef2f2 !important;
}

.import-actions {
    align-items: center;
}

.import-result-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.1rem;
    margin-bottom: 2.25rem;
}

.result-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 1.75rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.result-success .stat-num {
    color: var(--success-text);
}

.result-warn .stat-num {
    color: var(--warning-text);
}

.result-error .stat-num {
    color: var(--danger-text);
}

/* ---- Hamburger button ---- */
.nav-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: .5rem;
    margin-left: auto;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
}

.nav-hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: white;
    border-radius: 2px;
    transition: transform var(--t-base), opacity var(--t-base);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 0 1rem;
        gap: 0;
    }

    .nav-brand {
        padding: .75rem 0;
        flex: 1;
    }

    .nav-hamburger {
        display: flex;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        padding: .5rem 0 .75rem;
        gap: 0;
        border-top: 1px solid rgba(255, 255, 255, .12);
    }

    .nav-links.nav-open {
        display: flex;
    }

    .nav-links a {
        padding: .75rem .5rem;
        font-size: 14px;
        border-radius: var(--radius-sm);
    }

    .nav-links a.nav-active::after {
        display: none;
    }

    .nav-user {
        display: none;
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        padding: .5rem 0 .75rem;
        gap: .5rem;
        border-top: 1px solid rgba(255, 255, 255, .12);
        font-size: 13px;
        align-items: center;
    }

    .nav-user.nav-open {
        display: flex;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: .75rem;
    }

    .btn-group {
        flex-wrap: wrap;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        flex-direction: column;
        gap: .75rem;
    }

    .form-card {
        padding: 1.25rem;
    }

    .form-actions {
        flex-wrap: wrap;
    }

    .auth-box {
        width: 100%;
        max-width: 360px;
        padding: 1.75rem 1.25rem;
    }

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

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

    .quick-actions .btn {
        width: 100%;
        justify-content: center;
    }

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

    .assets-title-row {
        flex-direction: column;
        align-items: flex-start;
        gap: .75rem;
    }

    .assets-actions {
        flex-wrap: wrap;
    }

    .type-cards-grid {
        grid-template-columns: 1fr;
    }

    .entity-cards-grid {
        grid-template-columns: 1fr;
    }

    .btn {
        min-height: 40px;
    }

    .nav-links a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .inventory-options {
        grid-template-columns: 1fr;
    }
}

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

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

    .preview-stats {
        flex-wrap: wrap;
    }

    .table .hide-xs {
        display: none;
    }

    .form-actions .btn {
        flex: 1;
        justify-content: center;
    }

    .detail-list {
        grid-template-columns: 100px 1fr;
    }
}

/* ---- Location Cards ---- */
.location-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.1rem;
}

.location-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 1.4rem 1.6rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: inherit;
    transition: box-shadow var(--t-base), border-color var(--t-base), transform var(--t-base);
}

.location-card:nth-child(1) {
    animation: cardReveal var(--t-slow) .04s both;
}

.location-card:nth-child(2) {
    animation: cardReveal var(--t-slow) .08s both;
}

.location-card:nth-child(3) {
    animation: cardReveal var(--t-slow) .12s both;
}

.location-card:nth-child(4) {
    animation: cardReveal var(--t-slow) .16s both;
}

.location-card:nth-child(5) {
    animation: cardReveal var(--t-slow) .20s both;
}

.location-card:nth-child(n+6) {
    animation: cardReveal var(--t-slow) .24s both;
}

.location-card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: var(--accent-border);
    transform: translateY(-3px);
    text-decoration: none;
    color: inherit;
}

.location-card-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    line-height: 1;
}

.location-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
}

.location-card-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-card-count {
    font-size: 13px;
    color: var(--text-faint);
}

.location-card-arrow {
    font-size: 1.2rem;
    color: #c7d2fe;
    flex-shrink: 0;
    transition: transform var(--t-base), color var(--t-base);
}

.location-card:hover .location-card-arrow {
    transform: translateX(4px);
    color: var(--accent);
}

/* ---- Assets search row (search + location filter side-by-side) ---- */
.assets-search-row {
    display: flex;
    gap: .85rem;
    align-items: center;
}

.assets-search-row .assets-search-inner {
    flex: 1;
    max-width: 580px;
    position: relative;
}

.location-filter-select {
    width: auto;
    min-width: 170px;
    max-width: 230px;
    flex-shrink: 0;
    padding: .65rem .8rem;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-md);
    font-size: 14px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.location-filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

@media (max-width: 600px) {
    .assets-search-row {
        flex-direction: column;
        align-items: stretch;
    }

    .assets-search-row .assets-search-inner {
        max-width: 100%;
    }

    .location-filter-select {
        max-width: 100%;
    }
}

/* ---- Location List ---- */
.location-list {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
    border: 1.5px solid var(--border);
    overflow: hidden;
}

.location-item {
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border-light);
    transition: background .1s;
}

.location-item:last-child {
    border-bottom: none;
}

.location-item:hover {
    background: #f8faff;
}

.location-item-pinned {
    background: #fffbeb;
}

.location-item-pinned:hover {
    background: #fef3c7;
}

.location-item-main {
    display: flex;
    align-items: center;
    gap: .9rem;
    flex: 1;
    padding: .85rem 1.25rem;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}

.location-item-main:hover {
    text-decoration: none;
    color: inherit;
}

.location-item-icon {
    font-size: 1rem;
    flex-shrink: 0;
    opacity: .6;
}

.location-item-body {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    flex: 1;
    min-width: 0;
}

.location-item-name {
    font-size: .9rem;
    font-weight: 600;
    color: var(--primary);
}

.location-item-desc {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location-item-count {
    font-size: 12px;
    color: var(--text-faint);
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0 .75rem;
}

.location-item-arrow {
    font-size: 1rem;
    color: #c7d2fe;
    transition: transform .15s, color .15s;
    flex-shrink: 0;
}

.location-item-main:hover .location-item-arrow {
    transform: translateX(3px);
    color: var(--accent);
}

/* Actions column — always present, width collapses to zero when empty */
.location-item-actions {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: 0 .9rem 0 0;
    flex-shrink: 0;
    border-left: 1px solid var(--border-light);
}

.location-item-actions:empty {
    border-left: none;
    padding: 0;
}

/* Star pin button */
.pin-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: #d1d5db;
    padding: .35rem .45rem;
    border-radius: 4px;
    line-height: 1;
    transition: color .15s, transform .15s;
}

.pin-btn:hover {
    color: #f59e0b;
    transform: scale(1.15);
}

.pin-btn-active {
    color: #f59e0b;
}

.pin-btn-active:hover {
    color: #d97706;
}


/* ---- Danger Zone ---- */
.danger-zone {
    margin-top: 1.5rem;
    border: 1.5px solid var(--danger-bg) !important;
}

.danger-zone-title {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--danger-text);
    margin-bottom: 1rem;
}

.danger-zone-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.danger-zone-row p {
    margin: 0;
}

/* ---- Photo Gallery ---- */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.photo-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1.5px solid var(--border);
    background: var(--surface-2);
}

.photo-item img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.photo-meta {
    padding: .4rem .6rem;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}

.photo-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.photo-by {
    font-size: 11px;
}

.photo-delete {
    position: absolute;
    top: .4rem;
    right: .4rem;
    padding: .15rem .4rem !important;
    opacity: 0;
    transition: opacity .15s;
}

.photo-item:hover .photo-delete {
    opacity: 1;
}

.photo-upload-form {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.5rem;
}

.photo-upload-label input[type="file"] {
    display: none;
}

.photo-upload-label {
    cursor: pointer;
}