:root {
    color-scheme: light;
    --font-main: "Prompt", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-muted: #eef2f7;
    --text: #111827;
    --text-muted: #64748b;
    --border: #e5e7eb;
    --primary: #2563eb;
    --primary-strong: #1d4ed8;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
    --radius: 16px;
    --sidebar-width: 280px;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b1120;
    --surface: #111827;
    --surface-soft: #172033;
    --surface-muted: #1f2937;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.22);
    --primary: #60a5fa;
    --primary-strong: #3b82f6;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    font-family: var(--font-main);
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    font-size: 15px;
    line-height: 1.62;
    letter-spacing: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    letter-spacing: 0;
    line-height: 1.25;
}

.font-black,
.font-extrabold {
    font-weight: 700 !important;
}

.font-bold {
    font-weight: 600 !important;
}

.tracking-tight,
.tracking-tighter,
.tracking-widest,
.tracking-\[0\.2em\],
.tracking-\[0\.3em\] {
    letter-spacing: 0 !important;
}

a {
    color: inherit;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 34rem),
        var(--bg);
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, width 0.25s ease;
    backdrop-filter: blur(18px);
}

body.sidebar-collapsed {
    --sidebar-width: 86px;
}

body.sidebar-collapsed .app-sidebar .nav-link {
    justify-content: center;
    padding-inline: 12px;
}

body.sidebar-collapsed .app-sidebar .nav-link span,
body.sidebar-collapsed .app-sidebar .nav-section-label,
body.sidebar-collapsed .app-sidebar .brand-copy,
body.sidebar-collapsed .app-sidebar .logout-label {
    display: none;
}

.app-sidebar.is-open {
    transform: translateX(0);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: none;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(4px);
}

.sidebar-overlay.is-active {
    display: block;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(135deg, #2563eb, #0f766e);
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.25);
}

.nav-section-label {
    padding: 0 14px;
    margin: 18px 0 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.nav-link {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    margin: 4px 10px;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-link i {
    width: 22px;
    text-align: center;
    font-size: 17px;
}

.nav-link:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary), #0f766e);
    color: #fff;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}

.sidebar-pin {
    display: none;
}

.app-main {
    width: 100%;
    min-width: 0;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 72px;
    padding: 14px 18px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(18px);
}

.app-content {
    width: min(100%, 1440px);
    margin: 0 auto;
    padding: 18px;
}

.page-shell {
    padding-bottom: 48px;
}

.section-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.section-subtitle {
    color: var(--text-muted);
    margin-top: 4px;
    font-size: 14px;
}

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

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

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-soft);
    color: var(--primary);
    flex: 0 0 auto;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0 0 4px;
}

.stat-value {
    font-size: 24px;
    line-height: 1.15;
    font-weight: 700;
    margin: 0;
}

.stat-note {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

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

.search-box {
    position: relative;
    min-width: min(100%, 320px);
}

.search-box i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding-left: 42px !important;
}

.segmented {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 5px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 14px;
}

.segmented a,
.segmented button {
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.segmented a.active,
.segmented button.active {
    color: #fff;
    background: var(--primary);
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.data-table th {
    padding: 13px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: left;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tr:hover td {
    background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    white-space: nowrap;
}

.badge-success {
    color: #047857;
    background: #ecfdf5;
    border-color: #bbf7d0;
}

.badge-warning {
    color: #b45309;
    background: #fffbeb;
    border-color: #fde68a;
}

.badge-danger {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fecaca;
}

.badge-muted {
    color: var(--text-muted);
    background: var(--surface-soft);
    border-color: var(--border);
}

.badge-dark {
    color: #fff;
    background: #111827;
}

.attention-pulse,
.attention-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    border-radius: 999px;
}

.attention-pulse {
    width: 12px;
    height: 12px;
    position: relative;
}

.attention-pulse::before,
.attention-pulse::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
}

.attention-pulse::after {
    animation: pawnops-pulse 1.15s ease-out infinite;
}

.attention-dot {
    width: 7px;
    height: 7px;
    margin-right: 2px;
    background: currentColor;
    animation: pawnops-blink 1s ease-in-out infinite;
}

.attention-danger {
    color: var(--danger);
}

.attention-warning {
    color: var(--warning);
}

@keyframes pawnops-pulse {
    0% {
        transform: scale(1);
        opacity: 0.55;
    }
    100% {
        transform: scale(2.45);
        opacity: 0;
    }
}

@keyframes pawnops-blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.28;
    }
}

@media (prefers-reduced-motion: reduce) {
    .attention-pulse::after,
    .attention-dot {
        animation: none;
    }
}

.action-button {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 13px;
    border-radius: 11px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
}

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

.action-button.danger {
    color: #fff;
    border-color: var(--danger);
    background: var(--danger);
}

.inventory-row-overdue td {
    background: color-mix(in srgb, var(--danger) 6%, transparent);
}

.inventory-row-active td {
    background: color-mix(in srgb, var(--success) 3%, transparent);
}

.inventory-status-strong {
    font-weight: 700;
}

.quick-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.54);
    backdrop-filter: blur(7px);
}

.quick-modal-backdrop.is-open {
    display: flex;
}

.quick-modal-panel {
    width: min(100%, 760px);
    max-height: min(88vh, 780px);
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.quick-modal-body {
    max-height: calc(min(88vh, 780px) - 86px);
    overflow-y: auto;
}

.confirm-dialog {
    width: min(100%, 440px);
}

.confirm-dialog-icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--primary);
}

.confirm-dialog-icon.is-danger {
    background: var(--danger);
}

.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    min-width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    color: var(--text-muted);
    background: var(--surface);
    text-decoration: none;
    font-size: 13px;
}

.pagination .active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.responsive-table {
    overflow-x: auto;
}

.icon-button {
    width: 42px;
    height: 42px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.icon-button:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}

.page-hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.page-hero h1 {
    margin: 0;
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.16;
    letter-spacing: 0;
}

.page-hero p {
    margin: 8px 0 0;
    color: var(--text-muted);
}

.apple-card,
.ui-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.ui-soft {
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

input,
select,
textarea {
    font-family: var(--font-main) !important;
    border-radius: 12px !important;
    border: 1px solid var(--border) !important;
    background: var(--surface) !important;
    color: var(--text) !important;
    min-height: 42px;
    font-size: 15px !important;
}

input::placeholder,
textarea::placeholder {
    color: color-mix(in srgb, var(--text-muted) 75%, transparent);
}

.text-gray-900,
.text-gray-800,
.text-gray-700 {
    color: var(--text) !important;
}

.text-gray-600,
.text-gray-500,
.text-gray-400 {
    color: var(--text-muted) !important;
}

.bg-white {
    background-color: var(--surface) !important;
}

.bg-gray-50,
.bg-gray-100 {
    background-color: var(--surface-soft) !important;
}

.border-gray-50,
.border-gray-100,
.border-gray-200 {
    border-color: var(--border) !important;
}

.login-screen {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
    background:
        radial-gradient(circle at 18% 18%, rgba(37, 99, 235, 0.18), transparent 24rem),
        radial-gradient(circle at 80% 20%, rgba(15, 118, 110, 0.15), transparent 20rem),
        var(--bg);
}

.login-visual {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: clamp(28px, 5vw, 64px);
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 430px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: clamp(24px, 4vw, 36px);
}

.metric-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.metric-mini {
    padding: 16px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 78%, transparent);
    border: 1px solid var(--border);
}

@media (min-width: 1024px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        align-self: flex-start;
        height: 100vh;
        transform: none;
        flex: 0 0 var(--sidebar-width);
    }

    .app-main {
        flex: 1 1 auto;
    }

    .desktop-hidden {
        display: none !important;
    }

    .sidebar-pin {
        display: inline-flex;
    }
}

@media (max-width: 900px) {
    .login-screen {
        grid-template-columns: 1fr;
    }

    .login-visual {
        min-height: 40vh;
        padding-bottom: 8px;
    }

    .metric-strip {
        grid-template-columns: 1fr;
    }

    .page-hero {
        align-items: stretch;
        flex-direction: column;
    }

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

@media (max-width: 640px) {
    .app-content {
        padding: 14px;
    }

    .app-topbar {
        padding: 12px 14px;
    }

    .login-panel {
        padding: 14px;
    }

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

    .stat-card {
        min-height: auto;
    }
}
