:root {
    --primary: #1565c0;
    --primary-dark: #0d47a1;
    --primary-hover: #0f56a8;
    --primary-soft: #eaf3ff;
    --background: #f4f7fb;
    --surface: #ffffff;
    --surface-secondary: #f8fafc;
    --text: #172033;
    --text-muted: #667085;
    --border: #dce5f0;
    --success: #198754;
    --danger: #dc3545;
    --warning: #f59e0b;
    --shadow: 0 18px 45px rgba(21, 101, 192, 0.10);
    --radius: 20px;
    --sidebar-width: 260px;
    --topbar-height: 72px;
    --footer-height: 58px;
}

[data-bs-theme="dark"] {
    --primary: #64a6ff;
    --primary-dark: #2979d4;
    --primary-hover: #78b2ff;
    --primary-soft: #162f50;
    --background: #071426;
    --surface: #0e2038;
    --surface-secondary: #122842;
    --text: #f4f8ff;
    --text-muted: #aebcd0;
    --border: #243c5b;
    --success: #38b677;
    --danger: #ff6b76;
    --warning: #fbbf24;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.25);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    color: var(--text);
    background: var(--background);
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    transition:
        color 0.2s ease,
        background-color 0.2s ease;
}

body.sidebar-open {
    overflow: hidden;
}

a {
    text-decoration: none;
}

button,
a,
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent;
}

[hidden] {
    display: none !important;
}

.app-wide-container {
    width: 100%;
    max-width: 1800px;
    margin-right: auto;
    margin-left: auto;
    padding-right: clamp(18px, 2.2vw, 38px);
    padding-left: clamp(18px, 2.2vw, 38px);
}

.app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1050;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: #ffffff;
    background:
        radial-gradient(
            circle at top right,
            rgba(255, 255, 255, 0.18),
            transparent 29%
        ),
        linear-gradient(
            180deg,
            #1768c4 0%,
            #0d47a1 100%
        );
    box-shadow:
        14px 0 40px rgba(13, 71, 161, 0.16);
}

.sidebar-header {
    min-height: var(--topbar-height);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    color: #ffffff;
}

.sidebar-brand:hover {
    color: #ffffff;
}

.sidebar-brand-logo,
.public-brand-logo {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.30);
    border-radius: 14px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
    font-size: 15px;
    font-weight: 900;
}

.sidebar-brand-text,
.public-brand-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-brand-text strong,
.public-brand-text strong {
    overflow: hidden;
    color: #ffffff;
    font-size: 16px;
    font-weight: 850;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-brand-text small,
.public-brand-text small {
    overflow: hidden;
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-close-button,
.sidebar-toggle-button,
.theme-icon-button {
    display: inline-grid;
    place-items: center;
    padding: 0;
    cursor: pointer;
}

.sidebar-close-button {
    display: none;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid rgba(255, 255, 255, 0.20);
    border-radius: 12px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.10);
}

.sidebar-close-button svg,
.sidebar-toggle-button svg {
    width: 21px;
    height: 21px;
    fill: currentColor;
}

.sidebar-navigation {
    min-height: 0;
    padding: 20px 13px 18px;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 7px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color:
        rgba(255, 255, 255, 0.24)
        transparent;
}

.sidebar-section-label {
    padding: 5px 12px 8px;
    color: rgba(255, 255, 255, 0.50);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.sidebar-link {
    min-height: 48px;
    padding: 9px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid transparent;
    border-radius: 13px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 13px;
    font-weight: 720;
    transition:
        color 0.18s ease,
        border-color 0.18s ease,
        background-color 0.18s ease,
        transform 0.18s ease;
}

.sidebar-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.11);
    transform: translateX(2px);
}

.sidebar-link.active {
    border-color: rgba(255, 255, 255, 0.20);
    color: #0d47a1;
    background: #ffffff;
    box-shadow:
        0 12px 25px rgba(0, 0, 0, 0.12);
}

.sidebar-link-icon {
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    display: grid;
    place-items: center;
}

.sidebar-link-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.sidebar-footer {
    padding: 15px 20px 18px;
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-footer span {
    color: rgba(255, 255, 255, 0.82);
    font-size: 10px;
    font-weight: 750;
}

.sidebar-footer small {
    margin-top: 2px;
    color: rgba(255, 255, 255, 0.50);
    font-size: 9px;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    z-index: 1040;
    display: none;
    border: 0;
    background: rgba(3, 13, 28, 0.55);
    backdrop-filter: blur(3px);
}

.app-page,
.public-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app-page {
    margin-left: var(--sidebar-width);
}

.app-topbar,
.public-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.90);
    box-shadow:
        0 8px 30px rgba(21, 101, 192, 0.06);
    backdrop-filter: blur(18px);
}

[data-bs-theme="dark"] .app-topbar,
[data-bs-theme="dark"] .public-header {
    background: rgba(14, 32, 56, 0.90);
}

.app-topbar-content,
.public-header-content {
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.app-topbar-left,
.app-topbar-actions {
    display: flex;
    align-items: center;
}

.app-topbar-left {
    min-width: 0;
    gap: 13px;
}

.app-topbar-actions {
    justify-content: flex-end;
    gap: 10px;
}

.sidebar-toggle-button {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: none;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    background: var(--surface);
}

.sidebar-toggle-button:hover,
.sidebar-toggle-button:focus-visible {
    border-color: var(--primary);
    color: var(--primary);
    outline: none;
}

.topbar-page-identity {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar-page-identity strong {
    color: var(--text);
    font-size: 14px;
    font-weight: 850;
}

.topbar-page-identity span {
    margin-top: 1px;
    color: var(--text-muted);
    font-size: 10px;
}

/* Tombol mode terang dan gelap */
.theme-icon-button {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border: 1px solid #cbd9eb;
    border-radius: 14px;
    color: var(--primary);
    background: var(--surface);
    box-shadow:
        0 3px 10px rgba(21, 101, 192, 0.08);
    transition:
        color 0.18s ease,
        border-color 0.18s ease,
        background-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

.theme-icon-button:hover,
.theme-icon-button:focus-visible {
    border-color: var(--primary);
    color: #ffffff;
    background: var(--primary);
    box-shadow:
        0 8px 20px rgba(21, 101, 192, 0.22);
    outline: none;
    transform: translateY(-1px);
}

.theme-icon-button .theme-icon {
    width: 25px;
    height: 25px;
    display: block;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.theme-icon-button .theme-icon-sun {
    display: none;
}

.theme-icon-button .theme-icon-moon {
    display: block;
}

[data-bs-theme="dark"] .theme-icon-button .theme-icon-moon {
    display: none;
}

[data-bs-theme="dark"] .theme-icon-button .theme-icon-sun {
    display: block;
}

[data-bs-theme="dark"] .theme-icon-button {
    border: 1px solid rgba(100, 166, 255, 0.65);
    color: #a9ceff;
    background: #102844;
    box-shadow:
        0 0 0 2px rgba(100, 166, 255, 0.16),
        0 8px 22px rgba(0, 0, 0, 0.22);
}

[data-bs-theme="dark"] .theme-icon-button:hover,
[data-bs-theme="dark"] .theme-icon-button:focus-visible {
    border-color: #78b2ff;
    color: #071426;
    background: #78b2ff;
    box-shadow:
        0 0 0 3px rgba(100, 166, 255, 0.22),
        0 10px 24px rgba(0, 0, 0, 0.30);
}

.action-dropdown {
    display: inline-flex;
    justify-content: flex-end;
}

.action-menu-button {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--text-muted);
    background: var(--surface);
    cursor: pointer;
    transition:
        color 0.18s ease,
        border-color 0.18s ease,
        background-color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease;
}

.action-menu-button:hover,
.action-menu-button:focus-visible,
.action-dropdown.show .action-menu-button {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
    box-shadow:
        0 8px 18px rgba(21, 101, 192, 0.12);
    outline: none;
    transform: translateY(-1px);
}

.action-menu-button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.action-dropdown-menu {
    min-width: 168px;
    padding: 7px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.action-dropdown-item {
    min-height: 38px;
    padding: 9px 10px;
    border-radius: 9px;
    color: var(--text);
    font-size: 12px;
    font-weight: 750;
}

.action-dropdown-item:hover,
.action-dropdown-item:focus {
    color: var(--primary);
    background: var(--primary-soft);
}

.action-dropdown-form {
    margin: 0;
}

.action-dropdown-button {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
}

.action-dropdown-danger {
    color: var(--danger);
}

.action-dropdown-danger:hover,
.action-dropdown-danger:focus {
    color: #ffffff;
    background: var(--danger);
}

.product-list-card,
.category-list-card,
.check-history-card {
    overflow: visible !important;
}

.mobile-product-actions,
.mobile-category-actions,
.mobile-history-actions {
    align-items: center;
    justify-content: space-between;
}

.mobile-product-actions > span,
.mobile-category-actions > span,
.mobile-history-actions > span {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.mobile-product-actions {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
}

.mobile-product-actions > .action-dropdown,
.mobile-category-actions > .action-dropdown,
.mobile-history-actions > .action-dropdown {
    margin-left: auto;
}

.mobile-history-card .action-dropdown-form {
    margin: 0 !important;
    padding-top: 0 !important;
    border-top: 0 !important;
}

.account-dropdown {
    min-width: 0;
}

.account-menu-button {
    min-width: 0;
    min-height: 46px;
    padding: 5px 8px 5px 6px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    transition:
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background-color 0.18s ease;
}

.account-menu-button:hover,
.account-menu-button[aria-expanded="true"] {
    border-color: rgba(21, 101, 192, 0.42);
    background: var(--primary-soft);
    box-shadow:
        0 9px 22px rgba(21, 101, 192, 0.09);
}

.account-menu-avatar {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            #1565c0,
            #0d47a1
        );
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.account-menu-text {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    padding-right: 4px;
}

.account-menu-text strong {
    max-width: 190px;
    overflow: hidden;
    color: var(--text);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-menu-text small {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 8px;
    font-weight: 750;
    letter-spacing: 0.35px;
    text-transform: uppercase;
}

.account-menu-chevron {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    fill: var(--text-muted);
    transition: transform 0.18s ease;
}

.account-menu-button[aria-expanded="true"]
.account-menu-chevron {
    transform: rotate(180deg);
}

.account-dropdown-menu {
    width: 230px;
    margin-top: 9px !important;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 15px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.account-dropdown-heading {
    padding: 10px 11px 12px;
    display: flex;
    flex-direction: column;
    border-bottom: 1px solid var(--border);
}

.account-dropdown-heading strong {
    overflow: hidden;
    color: var(--text);
    font-size: 13px;
    font-weight: 850;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-dropdown-heading span {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 750;
    text-transform: uppercase;
}

.account-dropdown-item,
.account-logout-button {
    min-height: 40px;
    padding: 9px 11px;
    display: flex;
    align-items: center;
    border: 0;
    border-radius: 10px;
    color: var(--text);
    background: transparent;
    font-size: 12px;
    font-weight: 700;
}

.account-dropdown-item:hover,
.account-dropdown-item:focus {
    color: var(--primary);
    background: var(--primary-soft);
}

.account-logout-form {
    margin: 0;
}

.account-logout-button {
    width: 100%;
    color: var(--danger);
    text-align: left;
}

.account-logout-button:hover,
.account-logout-button:focus {
    color: #ffffff;
    background: var(--danger);
}

.public-header {
    color: #ffffff;
    border-bottom: 0;
    background:
        radial-gradient(
            circle at top right,
            rgba(255, 255, 255, 0.20),
            transparent 34%
        ),
        linear-gradient(
            135deg,
            #1565c0,
            #0d47a1
        );
}

[data-bs-theme="dark"] .public-header {
    background:
        radial-gradient(
            circle at top right,
            rgba(255, 255, 255, 0.12),
            transparent 34%
        ),
        linear-gradient(
            135deg,
            #123c70,
            #071d3c
        );
}

.public-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    color: #ffffff;
}

.public-brand:hover {
    color: #ffffff;
}

.public-theme-button {
    border-color: rgba(255, 255, 255, 0.55);
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.10);
}

.public-theme-button:hover,
.public-theme-button:focus-visible {
    border-color: #ffffff;
    color: #0d47a1;
    background: #ffffff;
    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.16);
}

[data-bs-theme="dark"] .public-theme-button {
    border-color: rgba(169, 206, 255, 0.72);
    color: #a9ceff;
    background: rgba(7, 20, 38, 0.60);
}

[data-bs-theme="dark"] .public-theme-button:hover,
[data-bs-theme="dark"] .public-theme-button:focus-visible {
    border-color: #78b2ff;
    color: #071426;
    background: #78b2ff;
}

.app-main {
    width: 100%;
    padding: 28px 0 calc(44px + var(--footer-height));
    flex: 1 0 auto;
}

.flash-wrapper {
    margin-bottom: 22px;
}

.flash-wrapper .alert {
    border-radius: 14px;
}

.btn-primary {
    border-color: #1565c0;
    background: #1565c0;
}

.btn-primary:hover,
.btn-primary:focus {
    border-color: #0f56a8;
    background: #0f56a8;
}

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

.btn-light:hover {
    border-color: var(--border);
    color: var(--text);
    background: var(--primary-soft);
}

.form-control,
.form-select {
    min-height: 48px;
    border-color: var(--border);
    border-radius: 13px;
    color: var(--text);
    background: var(--surface);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    color: var(--text);
    background: var(--surface);
    box-shadow:
        0 0 0 0.22rem rgba(21, 101, 192, 0.14);
}

.form-label {
    margin-bottom: 8px;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
}

.error-card {
    max-width: 680px;
    margin: 40px auto;
    padding: 44px 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.error-card > strong {
    display: block;
    color: var(--primary);
    font-size: 64px;
    font-weight: 900;
}

.error-card h1 {
    margin: 18px 0 10px;
    font-size: 28px;
    font-weight: 800;
}

.error-card p {
    margin-bottom: 24px;
    color: var(--text-muted);
}

.error-card .btn {
    min-height: 46px;
    display: inline-flex;
    align-items: center;
    padding: 8px 22px;
    border-radius: 13px;
    font-weight: 700;
}

.app-footer {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 990;
    min-height: var(--footer-height);
    margin-top: 0;
    padding: 10px 0;
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 -10px 30px rgba(21, 101, 192, 0.07);
    backdrop-filter: blur(18px);
}

[data-bs-theme="dark"] .app-footer {
    background: rgba(14, 32, 56, 0.94);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.22);
}

.app-page .app-footer {
    left: var(--sidebar-width);
}

.app-footer-content {
    min-width: 0;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
}

.app-footer strong {
    color: var(--text);
    font-size: 12px;
}

.app-footer span {
    min-width: 0;
    overflow: hidden;
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-footer small {
    color: var(--text-muted);
    font-size: 10px;
}

@media (min-width: 1200px) {
    .app-sidebar {
        transform: translateX(0) !important;
    }
}

@media (max-width: 1199.98px) {
    .app-sidebar {
        width: 275px;
        transform: translateX(-105%);
        transition: transform 0.24s ease;
    }

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

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .sidebar-close-button,
    .sidebar-toggle-button {
        display: inline-grid;
    }

    .app-page {
        margin-left: 0;
    }

    .app-page .app-footer {
        left: 0;
    }
}

@media (max-width: 767.98px) {
    :root {
        --topbar-height: 66px;
        --footer-height: 74px;
    }

    .app-wide-container {
        padding-right: 16px;
        padding-left: 16px;
    }

    .app-main {
        padding: 20px 0 calc(32px + var(--footer-height));
    }

    .topbar-page-identity span {
        display: none;
    }

    .account-menu-text small {
        display: none;
    }

    .account-menu-text strong {
        max-width: 130px;
    }

    .app-footer {
        padding: 8px 0;
    }

    .app-footer-content {
        grid-template-columns: minmax(0, 1fr) auto;
        row-gap: 3px;
    }

    .app-footer strong,
    .app-footer span {
        grid-column: 1 / 2;
    }

    .app-footer span {
        text-align: left;
    }

    .app-footer small {
        grid-column: 2 / 3;
        grid-row: 1 / 3;
        justify-self: end;
    }
}

@media (max-width: 479.98px) {
    .topbar-page-identity {
        display: none;
    }

    .app-topbar-content {
        gap: 10px;
    }

    .app-topbar-actions {
        gap: 7px;
    }

    .sidebar-toggle-button,
    .theme-icon-button {
        width: 40px;
        height: 40px;
        flex-basis: 40px;
    }

    .theme-icon-button .theme-icon {
        width: 23px;
        height: 23px;
    }

    .account-menu-button {
        min-height: 42px;
        padding-right: 6px;
    }

    .account-menu-avatar {
        width: 31px;
        height: 31px;
        flex-basis: 31px;
        border-radius: 10px;
    }

    .account-menu-text strong {
        max-width: 105px;
        font-size: 11px;
    }

    .account-menu-chevron {
        width: 15px;
        height: 15px;
        flex-basis: 15px;
    }

    .public-brand-text small {
        display: none;
    }
}

@media (max-width: 359.98px) {
    .account-menu-text {
        display: none;
    }

    .account-menu-chevron {
        margin-left: 1px;
    }
}