:root {
    --primary-color: #fc6c26;
    --accent-color: #fff4d6;
    --button-color: #fc6c26;
    --button-hover-color: #e85f1f;
    --button-active-color: #cf5219;
    --text-main: #2f2018;
    --bg-soft: #fff4d6;
    --bg-strong: #fc6c26;
    --page-gradient-start: #fff4d6;
    --page-gradient-end: #ffe9c2;
    --topbar-bg: rgba(255, 244, 214, 0.92);
    --sidebar-brand-text: #fff4d6;
    --sidebar-link-text: #fff4d6;
    --sidebar-link-hover-bg: rgba(255, 244, 214, 0.2);
    --link-hover-color: #cf5219;
    --auth-overlay-opacity: 0.28;
}

:root[data-theme='flat'] {
    --primary-color: #fc6c26;
    --accent-color: #fff4d6;
    --button-color: #fc6c26;
    --button-hover-color: #e85f1f;
    --button-active-color: #cf5219;
    --text-main: #2f2018;
    --bg-soft: #fff4d6;
    --bg-strong: #fc6c26;
    --page-gradient-start: #fff4d6;
    --page-gradient-end: #ffe9c2;
    --topbar-bg: #fff4d6;
    --sidebar-brand-text: #fff4d6;
    --sidebar-link-text: #fff4d6;
    --sidebar-link-hover-bg: rgba(255, 244, 214, 0.2);
    --link-hover-color: #cf5219;
    --auth-overlay-opacity: 0;
}

:root[data-theme='dark'] {
    --primary-color: #0f172a;
    --accent-color: #334155;
    --button-color: #38bdf8;
    --button-hover-color: #0ea5e9;
    --button-active-color: #0284c7;
    --text-main: #e2e8f0;
    --bg-soft: #111827;
    --bg-strong: #020617;
    --page-gradient-start: #020617;
    --page-gradient-end: #111827;
    --topbar-bg: rgba(15, 23, 42, 0.86);
    --sidebar-brand-text: #93c5fd;
    --sidebar-link-text: #cbd5e1;
    --sidebar-link-hover-bg: rgba(56, 189, 248, 0.18);
    --link-hover-color: #7dd3fc;
    --auth-overlay-opacity: 0.18;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-main);
    background: linear-gradient(135deg, var(--page-gradient-start) 0%, var(--page-gradient-end) 100%);
    min-height: 100vh;
}

.auth-body {
    overflow: hidden;
}

.auth-gradient {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 10% 10%, var(--primary-color) 0%, transparent 35%),
    radial-gradient(circle at 80% 20%, var(--accent-color) 0%, transparent 35%),
    radial-gradient(circle at 60% 80%, var(--button-color) 0%, transparent 40%);
    opacity: var(--auth-overlay-opacity);
    z-index: 0;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    border-radius: 18px;
    z-index: 1;
}

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

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, var(--bg-strong) 0%, var(--primary-color) 100%);
    color: #fff;
    transition: transform 0.3s ease;
}

.sidebar-brand small {
    color: var(--sidebar-brand-text);
}

.sidebar-close-btn {
    line-height: 1;
    border-color: rgba(255, 255, 255, 0.65);
    color: #fff;
}

.sidebar-close-btn:hover,
.sidebar-close-btn:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.85);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 1rem;
}

.sidebar .nav-link {
    color: var(--sidebar-link-text);
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    font-size: 0.9rem;
    transition: background 0.18s ease, color 0.18s ease;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
    background: var(--sidebar-link-hover-bg);
    color: #fff;
}

/* Group toggle (parent with children) */
.sidebar-group-toggle {
    cursor: pointer;
    user-select: none;
}

.sidebar-group-toggle.active {
    background: var(--sidebar-link-hover-bg);
    color: #fff;
}

/* Arrow indicator */
.sidebar-arrow {
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform 0.25s ease;
    flex-shrink: 0;
    margin-right: 2px;
}

.sidebar-group-toggle[aria-expanded="true"] .sidebar-arrow {
    transform: rotate(45deg);
}

.sidebar-group-hint {
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0.65;
}

.sidebar-group-hint-text {
    font-size: 0.68rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    line-height: 1;
    transition: opacity 0.2s;
}

.sidebar-group-toggle:hover .sidebar-group-hint,
.sidebar-group-toggle.active .sidebar-group-hint {
    opacity: 1;
}

/* Submenu */
.sidebar-submenu {
    margin: 2px 0 4px 0;
    padding: 0;
    gap: 1px;
}

.sidebar-submenu-link {
    padding: 0.45rem 0.85rem 0.45rem 1.4rem;
    font-size: 0.855rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: rgba(255, 255, 255, 0.82);
}

.sidebar-submenu-link:hover,
.sidebar-submenu-link.active {
    background: var(--sidebar-link-hover-bg);
    color: #fff;
}

.sidebar-submenu-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-submenu-link.active .sidebar-submenu-dot,
.sidebar-submenu-link:hover .sidebar-submenu-dot {
    opacity: 1;
}

/* Left border accent on active submenu item */
.sidebar-submenu-link.active {
    border-left: 3px solid rgba(255,255,255,0.7);
    padding-left: calc(1.4rem - 3px);
}

.content-shell {
    flex: 1;
    min-width: 0;
}

.topbar {
    background: var(--topbar-bg);
    backdrop-filter: blur(6px);
}

.topbar-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
}

.topbar-user-badge {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-logout-btn {
    white-space: nowrap;
}

.stat-card {
    border-radius: 16px;
}

.table thead th {
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary {
    --bs-btn-bg: var(--button-color);
    --bs-btn-border-color: var(--button-color);
    --bs-btn-hover-bg: var(--button-hover-color);
    --bs-btn-hover-border-color: var(--button-hover-color);
    --bs-btn-active-bg: var(--button-active-color);
    --bs-btn-active-border-color: var(--button-active-color);
}

.btn-outline-primary {
    --bs-btn-color: var(--button-color);
    --bs-btn-border-color: var(--button-color);
    --bs-btn-hover-bg: var(--button-color);
    --bs-btn-hover-border-color: var(--button-color);
    --bs-btn-active-bg: var(--button-active-color);
    --bs-btn-active-border-color: var(--button-active-color);
}

.page-item.active .page-link {
    background-color: var(--button-color);
    border-color: var(--button-color);
}

a {
    color: var(--primary-color);
}

a:hover {
    color: var(--link-hover-color);
}

.theme-select {
    min-width: 160px;
}

:root[data-theme='dark'] .topbar,
:root[data-theme='dark'] .card,
:root[data-theme='dark'] .modal-content,
:root[data-theme='dark'] .table,
:root[data-theme='dark'] .form-control,
:root[data-theme='dark'] .form-select,
:root[data-theme='dark'] .list-group-item {
    color: #e2e8f0;
}

:root[data-theme='dark'] .topbar {
    border-color: rgba(148, 163, 184, 0.2) !important;
}

:root[data-theme='dark'] .text-muted {
    color: #94a3b8 !important;
}

:root[data-theme='dark'] .card,
:root[data-theme='dark'] .modal-content,
:root[data-theme='dark'] .form-control,
:root[data-theme='dark'] .form-select,
:root[data-theme='dark'] .table,
:root[data-theme='dark'] .list-group-item {
    background-color: #0f172a;
    border-color: rgba(148, 163, 184, 0.25);
}

:root[data-theme='dark'] .table-light,
:root[data-theme='dark'] .bg-light {
    background-color: #1e293b !important;
    color: #e2e8f0 !important;
}

:root[data-theme='dark'] .table > :not(caption) > * > * {
    background-color: transparent;
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.18);
}

:root[data-theme='dark'] .btn-light,
:root[data-theme='dark'] .btn-outline-secondary {
    --bs-btn-color: #e2e8f0;
    --bs-btn-bg: #1e293b;
    --bs-btn-border-color: #334155;
    --bs-btn-hover-bg: #334155;
    --bs-btn-hover-border-color: #475569;
    --bs-btn-hover-color: #e2e8f0;
}

:root[data-theme='dark'] .page-link {
    color: #7dd3fc;
    background-color: #0f172a;
    border-color: #334155;
}

:root[data-theme='dark'] .page-link:hover {
    color: #bae6fd;
    background-color: #1e293b;
}

:root[data-theme='dark'] .auth-card {
    background-color: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
}

.global-loader {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.article-image-box {
    min-height: 240px;
}

.vacation-card {
    border-radius: 14px;
}

.vacation-actions .btn {
    min-width: 120px;
}

.signature-pad-wrapper {
    border: 1px solid rgba(15, 23, 42, 0.16);
    border-radius: 10px;
    background: #ffffff;
    padding: 0.5rem;
}

.signature-canvas {
    width: 100%;
    min-height: 220px;
    border-radius: 8px;
    border: 1px dashed rgba(15, 23, 42, 0.3);
    touch-action: none;
    cursor: crosshair;
}

#articleMainImage {
    max-height: 320px;
    object-fit: contain;
}

#articleDetailModal,
#articleImageModal {
    z-index: 1060;
}

@media (max-width: 991.98px) {
    .sidebar {
        position: fixed;
        z-index: 1040;
        top: 0;
        bottom: 0;
        left: 0;
        max-width: 280px;
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .article-image-box {
        min-height: 180px;
    }
}

@media (max-width: 575.98px) {
    .topbar .container-fluid {
        gap: 0.5rem;
    }

    .theme-select {
        min-width: 112px;
        max-width: 120px;
    }

    .topbar-actions {
        gap: 0.4rem !important;
    }

    .topbar-user-badge {
        max-width: 110px;
        font-size: 0.78rem;
    }

    .topbar-logout-btn {
        padding-inline: 0.55rem;
    }

    body {
        font-size: 0.92rem;
    }

    h1,
    .h1 {
        font-size: 1.5rem;
    }

    h2,
    .h2 {
        font-size: 1.28rem;
    }

    h3,
    .h3 {
        font-size: 1.12rem;
    }

    h4,
    .h4,
    h5,
    .h5,
    h6,
    .h6 {
        font-size: 1rem;
    }

    .table {
        font-size: 0.86rem;
    }

    .btn,
    .form-control,
    .form-select,
    .form-label,
    .modal-title,
    .card-body,
    .pagination,
    small,
    .small {
        font-size: 0.86rem;
    }

    #articleMainImage {
        max-height: 220px;
    }

    #articlesTable,
    #articleStocksTable {
        font-size: 0.8rem;
    }

    #articlesTable {
        width: 100%;
        min-width: 100%;
    }

    #articlesTable thead {
        display: none;
    }

    #articlesTable,
    #articlesTable tbody,
    #articlesTable tr,
    #articlesTable td {
        display: block;
        width: 100%;
    }

    #articlesTable tr {
        border: 1px solid rgba(15, 23, 42, 0.12);
        border-radius: 10px;
        margin-bottom: 0.6rem;
        background: rgba(255, 255, 255, 0.92);
        padding: 0.35rem 0.45rem;
    }

    #articlesTable td {
        border: 0;
        padding: 0.36rem 0.12rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.55rem;
    }

    #articlesTable td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #334155;
        flex: 0 0 42%;
    }

    #articlesTable td:last-child {
        padding-top: 0.5rem;
    }

    #articlesTable .btn-article-detail {
        width: 100%;
    }

    #articlesTable th,
    #articlesTable td,
    #articleStocksTable th,
    #articleStocksTable td {
        padding: 0.4rem 0.45rem;
        vertical-align: middle;
    }

    #articlesTable .btn,
    #articleDetailModal .btn,
    #articlesPaginationInfo,
    #articlesPageIndicator {
        font-size: 0.8rem;
    }

    #articlesPerPage {
        min-width: 64px;
    }

    .vacation-actions .btn {
        min-width: 100%;
    }

    .signature-canvas {
        min-height: 180px;
    }

    :root[data-theme='dark'] #articlesTable tr {
        background: #0f172a;
        border-color: rgba(148, 163, 184, 0.24);
    }

    :root[data-theme='dark'] #articlesTable td::before {
        color: #cbd5e1;
    }
}
