:root {
    --app-ink: #172b4d;
    --app-muted: #68778d;
    --app-primary: #3157c8;
    --app-primary-dark: #2445a6;
    --app-accent: #16a6a1;
    --app-page: #f3f6fb;
    --app-border: #e3e9f2;
    --app-shadow: 0 8px 26px rgba(23, 43, 77, 0.07);
}

* {
    scrollbar-color: #b9c5d7 transparent;
    scrollbar-width: thin;
}

body {
    min-height: 100vh;
    position: relative;
    background: var(--app-page);
    color: var(--app-ink);
    font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    line-height: 1.55;
}

button,
a,
input,
select,
textarea {
    touch-action: manipulation;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.table-responsive:focus-visible {
    outline: 3px solid rgba(49, 87, 200, 0.35);
    outline-offset: 2px;
}

.sidebar {
    position: fixed;
    z-index: 1030;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    padding: 1.5rem 0 1rem;
    overflow-y: auto;
    background: #142540;
    box-shadow: 6px 0 24px rgba(17, 34, 61, 0.12);
}

.sidebar-header {
    margin: 0 1rem 2rem;
    padding: 0.65rem 0.5rem 1.35rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    text-align: center;
}

.sidebar-header img {
    display: block;
    width: 58px;
    height: 58px;
    margin: 0 auto;
    object-fit: contain;
}

.sidebar-header h5 {
    margin-top: 0.55rem !important;
    margin-bottom: 0;
    color: #fff;
    font-size: 1rem;
    font-weight: 750;
    letter-spacing: 0.01em;
}

.sidebar nav {
    display: grid;
    gap: 0.35rem;
    padding: 0 0.85rem;
}

.sidebar nav a {
    display: flex;
    min-height: 46px;
    align-items: center;
    padding: 0.7rem 0.85rem;
    border-radius: 10px;
    color: #c0cce0;
    font-size: 0.92rem;
    font-weight: 550;
    text-decoration: none;
    transition: background-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.sidebar nav a:hover {
    transform: translateX(2px);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar nav a.active {
    background: linear-gradient(110deg, var(--app-primary), #3b78d8);
    box-shadow: 0 5px 14px rgba(35, 76, 175, 0.3);
    color: #fff;
}

.sidebar nav a i {
    width: 22px;
    margin-right: 0.7rem;
    color: #8fa9d2;
    text-align: center;
}

.sidebar nav a.active i,
.sidebar nav a:hover i {
    color: #fff;
}

.main-content {
    width: auto;
    min-width: 0;
    margin-left: 260px;
    padding: clamp(1.5rem, 2.4vw, 2.75rem);
}

.main-content > * {
    min-width: 0;
}

.main-content h2 {
    color: var(--app-ink);
    font-size: clamp(1.55rem, 2vw, 2rem);
    font-weight: 750;
    letter-spacing: -0.035em;
}

.main-content h5 {
    font-weight: 700;
}

.form-section,
.size-intro,
.size-filter,
.size-panel,
.fabric-calculator {
    border: 1px solid var(--app-border);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--app-shadow);
}

.main-content .form-section {
    padding: 1.5rem;
    border-color: var(--app-border);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--app-shadow);
}

.main-content .form-section h5 {
    border-color: var(--app-accent);
    color: var(--app-primary);
}

.form-label {
    color: #344563;
    font-weight: 650;
}

.form-text,
.text-muted {
    color: var(--app-muted) !important;
}

.form-text {
    line-height: 1.5;
}

.form-control,
.form-select {
    min-height: 42px;
    border-color: #d2dbea;
    border-radius: 9px;
    color: var(--app-ink);
}

.form-control:focus,
.form-select:focus {
    border-color: #7896e3;
    box-shadow: 0 0 0 0.2rem rgba(49, 87, 200, 0.13);
}

textarea.form-control {
    min-height: auto;
}

.btn {
    min-height: 40px;
    border-radius: 9px;
    font-weight: 650;
}

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

.btn-primary:hover {
    border-color: var(--app-primary-dark);
    background-color: var(--app-primary-dark);
}

.card {
    margin-bottom: 1.5rem;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--app-shadow);
}

.card-header {
    border-bottom: 1px solid var(--app-border);
    background: #fff;
    color: var(--app-ink);
    font-weight: 700;
}

.table-responsive {
    max-width: 100%;
    overflow: auto;
    border: 1px solid var(--app-border);
    border-radius: 12px;
    background: #fff;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
}

.table-responsive > .table {
    margin-bottom: 0;
    --bs-table-bg: #fff;
}

.table thead th {
    vertical-align: middle;
    background: #f0f4fa;
    color: #344563;
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.025em;
}

.table > :not(caption) > * > * {
    padding: 0.7rem 0.75rem;
    border-color: #e5eaf2;
}

.table tbody tr:hover > * {
    --bs-table-bg: #f7f9fd;
}

.badge {
    font-weight: 650;
    letter-spacing: 0.01em;
}

.alert {
    border: 1px solid transparent;
    border-radius: 12px;
}

.login-card.card {
    width: min(100%, 440px);
    margin: 1rem;
    padding: 1rem;
    border-radius: 20px;
    box-shadow: 0 18px 54px rgba(23, 43, 77, 0.13);
}

.login-page {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 1.25rem;
    background:
        radial-gradient(ellipse at 12% 12%, rgba(22, 166, 161, 0.1), transparent 34%),
        radial-gradient(ellipse at 90% 88%, rgba(49, 87, 200, 0.12), transparent 38%),
        var(--app-page);
}

.login-card h3 {
    color: var(--app-ink);
    font-weight: 750;
    letter-spacing: -0.025em;
}

.login-card .card-body {
    padding: 1.35rem;
}

.login-card .form-label {
    font-weight: 650;
}

.logo {
    margin-bottom: 1.1rem;
    text-align: center;
}

.logo img {
    width: 76px;
    height: 76px;
    object-fit: contain;
}

.welcome-text {
    color: #495057;
    font-size: 1.25rem;
}

.stats-card {
    background: linear-gradient(135deg, #3157c8 0%, #4b78df 100%);
    color: #fff;
}

.stats-card .card-title {
    color: rgba(255, 255, 255, 0.9);
}

.stats-card .stats-value {
    font-size: 2rem;
    font-weight: 750;
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .sidebar {
        width: 230px;
    }

    .sidebar-header {
        margin-inline: 0.75rem;
    }

    .sidebar nav {
        padding-inline: 0.7rem;
    }

    .sidebar nav a {
        padding-inline: 0.65rem;
        font-size: 0.86rem;
    }

    .main-content {
        margin-left: 230px;
        padding: 1.5rem;
    }
}

@media (max-width: 767.98px) {
    body {
        padding-top: 112px;
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 112px;
        padding: max(0.3rem, env(safe-area-inset-top)) 0 0.3rem;
        overflow: visible;
        box-shadow: 0 4px 18px rgba(17, 34, 61, 0.18);
    }

    .sidebar-header {
        display: flex;
        align-items: center;
        gap: 0.55rem;
        margin: 0 0.8rem 0.25rem;
        padding: 0;
        border: 0;
        text-align: left;
    }

    .sidebar-header img {
        width: 30px;
        height: 30px;
        margin: 0;
    }

    .sidebar-header h5 {
        margin: 0 !important;
        font-size: 0.84rem;
    }

    .sidebar nav {
        display: flex;
        gap: 0.35rem;
        padding: 0 0.6rem 0.2rem;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar nav a {
        min-width: 76px;
        min-height: 58px;
        flex: 0 0 auto;
        flex-direction: column;
        justify-content: center;
        gap: 0.25rem;
        margin: 0;
        padding: 0.35rem 0.55rem;
        border-radius: 10px;
        font-size: 0.69rem;
        line-height: 1.15;
        text-align: center;
        white-space: nowrap;
    }

    .sidebar nav a:hover {
        transform: none;
    }

    .sidebar nav a i {
        width: auto;
        margin: 0;
        font-size: 1.05rem;
    }

    .main-content {
        width: 100%;
        margin-left: 0;
        padding: 1.1rem 0.85rem 1.5rem;
    }

    .main-content > .d-flex:first-child {
        align-items: flex-start !important;
    }

    .main-content .form-section {
        padding: 1.1rem;
        border-radius: 14px;
    }

    .row {
        --bs-gutter-x: 0.85rem;
    }

    .card-body {
        padding: 1rem;
    }

    .btn,
    .form-control,
    .form-select {
        min-height: 46px;
    }

    .btn-sm,
    .form-control-sm,
    .form-select-sm {
        min-height: 44px;
    }

    textarea.form-control {
        min-height: 110px;
    }

    .table-responsive {
        position: relative;
        border-radius: 11px;
    }

    .table-responsive::after {
        display: block;
        padding: 0.45rem 0.65rem;
        border-top: 1px solid #e5eaf2;
        background: #f7f9fd;
        color: var(--app-muted);
        content: "Geser tabel ke kiri atau kanan untuk melihat kolom lainnya";
        font-size: 0.72rem;
        text-align: center;
    }

    .table-responsive > .table {
        width: max-content;
        min-width: 100%;
    }

    .table > :not(caption) > * > * {
        padding: 0.65rem 0.7rem;
    }

    .modal-dialog {
        margin: 0.65rem;
    }

    .modal-content {
        border: 0;
        border-radius: 16px;
        box-shadow: 0 12px 40px rgba(23, 43, 77, 0.2);
    }

    .login-card.card {
        margin: 0.75rem;
        padding: 0.5rem;
    }

    .login-page {
        padding: max(0.85rem, env(safe-area-inset-top)) 0.85rem max(0.85rem, env(safe-area-inset-bottom));
    }

    .login-card .card-body {
        padding: 1rem;
    }
}

@media (max-width: 380px) {
    .main-content {
        padding-inline: 0.7rem;
    }

    .sidebar nav a {
        min-width: 70px;
        font-size: 0.66rem;
    }

    body {
        padding-top: 108px;
    }

    .sidebar {
        max-height: 108px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
