:root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-soft: #f5f7fa;
    --ink: #161b22;
    --ink-soft: #2f3744;
    --muted: #667085;
    --line: #e1e6ee;
    --line-strong: #c8d0dc;
    --primary: #0b63ce;
    --primary-dark: #084d9f;
    --primary-soft: #eaf2ff;
    --success: #067647;
    --success-soft: #ecfdf3;
    --danger: #b42318;
    --danger-soft: #fff1f0;
    --warning: #b54708;
    --warning-soft: #fff7e8;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-md: 0 14px 36px rgba(16, 24, 40, 0.10);
    --shadow-lg: 0 26px 80px rgba(16, 24, 40, 0.18);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

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

.main-panel {
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 72px;
    padding: 14px 30px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.topbar-left,
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-title {
    min-width: 0;
}

.topbar-title strong {
    display: block;
    color: var(--ink);
    font-size: 20px;
    line-height: 1.2;
}

.eyebrow {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.menu-toggle:hover {
    border-color: var(--line-strong);
    background: var(--surface-soft);
    box-shadow: 0 8px 18px rgba(16, 24, 40, 0.08);
}

.menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: var(--ink);
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.sidebar-open .menu-toggle span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.sidebar-open .menu-toggle span:nth-child(2) {
    opacity: 0;
}

.sidebar-open .menu-toggle span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

.role-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 6px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    width: min(340px, calc(100vw - 40px));
    height: 100vh;
    padding: 22px;
    background: #fff;
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    transform: translateX(-106%);
    transition: transform 0.22s ease;
}

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

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: block;
    border: 0;
    background: rgba(16, 24, 40, 0.46);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.sidebar-open {
    overflow: hidden;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    color: var(--ink);
    font-weight: 850;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    font-size: 17px;
    font-weight: 900;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: 1px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.side-nav {
    display: grid;
    gap: 8px;
    margin-top: 28px;
}

.side-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 800;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.side-nav a:hover,
.side-nav a.active {
    border-color: var(--line);
    background: var(--surface-soft);
    color: var(--primary);
}

.nav-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary-soft);
}

.nav-icon::before,
.nav-icon::after {
    content: "";
    position: absolute;
    border-radius: 2px;
    background: var(--primary);
}

.nav-dashboard::before {
    width: 13px;
    height: 13px;
    border: 2px solid var(--primary);
    background: transparent;
}

.nav-dashboard::after {
    width: 5px;
    height: 2px;
    bottom: 9px;
}

.nav-box::before {
    width: 14px;
    height: 11px;
    border: 2px solid var(--primary);
    background: transparent;
}

.nav-box::after {
    width: 12px;
    height: 2px;
    top: 9px;
}

.nav-loan::before {
    width: 14px;
    height: 14px;
    border: 2px solid var(--primary);
    background: transparent;
}

.nav-loan::after {
    width: 8px;
    height: 2px;
    transform: rotate(-35deg);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 11px;
    margin-top: auto;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.sidebar-footer strong,
.sidebar-footer small {
    display: block;
}

.sidebar-footer small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-weight: 900;
}

.container {
    width: min(1160px, calc(100% - 44px));
    margin: 30px auto 48px;
}

.auth-body {
    background:
        radial-gradient(circle at 20% 20%, rgba(11, 99, 206, 0.10), transparent 30%),
        radial-gradient(circle at 80% 15%, rgba(22, 27, 34, 0.08), transparent 28%),
        var(--bg);
}

.auth-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 26px;
}

.auth-card {
    width: min(430px, 100%);
    padding: 34px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.auth-card::before {
    content: "PinjamBarang";
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    margin-bottom: 20px;
    padding: 6px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--ink);
    font-size: 13px;
    font-weight: 900;
}

.form-card {
    width: min(640px, 100%);
    margin: 0 auto;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.form-card h1 {
    margin-bottom: 20px;
}

h1 {
    margin: 0 0 8px;
    color: var(--ink);
    font-size: 30px;
    line-height: 1.16;
    letter-spacing: 0;
}

.muted {
    margin: 0;
    color: var(--muted);
}

.alert {
    margin: 0 0 18px;
    padding: 13px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 750;
}

.alert-success {
    color: var(--success);
    background: var(--success-soft);
    border-color: #abefc6;
}

.alert-error {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: #fecdca;
}

.form {
    display: grid;
    gap: 16px;
}

.form label {
    display: grid;
    gap: 7px;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 750;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
    resize: vertical;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #aeb8c8;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 0;
    box-shadow: 0 0 0 4px rgba(11, 99, 206, 0.12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 9px 16px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    color: var(--ink-soft);
    font-size: 14px;
    font-weight: 850;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.btn:hover {
    border-color: #aeb8c8;
    background: var(--surface-soft);
    color: var(--ink);
}

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

.btn:focus-visible,
.side-nav a:focus-visible,
.action-link:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 4px rgba(11, 99, 206, 0.14);
}

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

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

.btn.ghost {
    border-color: var(--line);
    background: #fff;
}

.btn.small {
    min-height: 34px;
    padding: 6px 11px;
    font-size: 13px;
}

.btn.success {
    border-color: #abefc6;
    background: var(--success-soft);
    color: var(--success);
}

.btn.success:hover {
    border-color: var(--success);
    background: #dcfae6;
}

.btn.danger {
    border-color: #fecdca;
    background: var(--danger-soft);
    color: var(--danger);
}

.btn.danger:hover {
    border-color: var(--danger);
    background: #fee4e2;
}

.demo-box {
    display: grid;
    gap: 7px;
    margin-top: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--ink-soft);
    font-size: 14px;
}

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

.page-head h1 {
    font-size: 32px;
}

.stats-grid,
.actions-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card,
.action-link {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.stat-card {
    padding: 22px;
}

.stat-card span {
    display: block;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

.stat-card strong {
    color: var(--ink);
    font-size: 38px;
    line-height: 1;
}

.action-link {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 78px;
    padding: 20px 56px 20px 20px;
    color: var(--ink-soft);
    font-weight: 850;
    transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease, color 0.16s ease;
}

.action-link:hover {
    border-color: rgba(11, 99, 206, 0.30);
    color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.action-link::after {
    content: ">";
    position: absolute;
    right: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
}

.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    padding: 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.toolbar input {
    max-width: 380px;
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 15px 16px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    background: var(--surface-soft);
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 850;
    text-transform: uppercase;
}

td {
    color: #1f2937;
}

tbody tr {
    transition: background 0.12s ease;
}

tbody tr:hover {
    background: #fbfcff;
}

tr:last-child td {
    border-bottom: 0;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.table-actions form {
    margin: 0;
}

.empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--muted);
}

.form-actions,
.form-grid {
    display: flex;
    gap: 12px;
}

.form-actions {
    align-items: center;
    justify-content: flex-end;
    padding-top: 4px;
}

.form-grid > * {
    flex: 1;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 27px;
    padding: 5px 10px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
}

.status-diajukan {
    background: var(--warning-soft);
    color: var(--warning);
    border-color: #fedf89;
}

.status-disetujui {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: #b2ccff;
}

.status-dikembalikan {
    background: var(--success-soft);
    color: var(--success);
    border-color: #abefc6;
}

.status-ditolak {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #fecdca;
}

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(16, 24, 40, 0.54);
}

.confirm-modal[hidden] {
    display: none !important;
}

.confirm-modal.show {
    display: flex;
}

.confirm-dialog {
    width: min(420px, 100%);
    padding: 24px;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.confirm-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 900;
}

.confirm-dialog h2 {
    margin: 14px 0 6px;
    font-size: 20px;
}

.confirm-dialog p {
    margin: 0;
    color: var(--muted);
}

.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

@media (max-width: 760px) {
    .topbar {
        gap: 10px;
        min-height: 66px;
        padding: 12px 14px;
    }

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

    .topbar-actions {
        gap: 8px;
    }

    .role-pill {
        display: none;
    }

    .topbar-title strong {
        overflow: hidden;
        max-width: 42vw;
        font-size: 17px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar .btn {
        min-height: 38px;
        padding: 7px 11px;
    }

    .container {
        width: min(100% - 28px, 1160px);
        margin-top: 22px;
    }

    .page-head,
    .toolbar,
    .form-actions,
    .form-grid {
        align-items: stretch;
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    .stats-grid,
    .actions-grid {
        grid-template-columns: 1fr;
    }

    .table-wrap {
        overflow: visible;
        border: 0;
        background: transparent;
        box-shadow: none;
    }

    table,
    thead,
    tbody,
    tr,
    th,
    td {
        display: block;
    }

    thead {
        display: none;
    }

    tbody {
        display: grid;
        gap: 12px;
    }

    tr {
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--surface);
        box-shadow: var(--shadow-sm);
    }

    tr:last-child td {
        border-bottom: 1px solid var(--line);
    }

    tr:last-child td:last-child {
        border-bottom: 0;
    }

    td {
        display: grid;
        grid-template-columns: 118px minmax(0, 1fr);
        gap: 12px;
        padding: 12px 14px;
        border-bottom: 1px solid var(--line);
        overflow-wrap: anywhere;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 850;
        text-transform: uppercase;
    }

    td.table-actions {
        display: grid;
        align-items: stretch;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    td.table-actions::before {
        grid-column: 1 / -1;
    }

    .table-actions .btn,
    .table-actions form,
    .table-actions button {
        width: 100%;
    }

    .table-actions > :only-child {
        grid-column: 1 / -1;
    }

    .auth-card,
    .form-card {
        padding: 22px;
    }

    .toolbar input {
        max-width: none;
    }

    .confirm-actions {
        flex-direction: column-reverse;
    }
}
