* { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: #f4f6f8;
    margin: 0;
    color: #1f2937;
}
.navbar {
    background: linear-gradient(135deg, #1e3a5f 0%, #16304f 100%);
    color: #fff;
    padding: 14px 26px;
    display: flex;
    align-items: center;
    gap: 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 60;
    flex-wrap: wrap;
}
.navbar a {
    color: #cfe0f5;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}
.navbar a:hover { color: #fff; background: rgba(255,255,255,0.12); }
.navbar a.active {
    background: #fff;
    color: #1e3a5f;
    font-weight: 600;
}
.navbar a.active:hover { background: #fff; color: #1e3a5f; }
.navbar a.logout { color: #fbd9d9; }
.navbar a.logout:hover { color: #fff; background: rgba(255,255,255,0.12); }
.navbar .brand { font-weight: bold; font-size: 18px; margin-right: 10px; }
.navbar .logout { margin-left: auto; }

.container { max-width: 1100px; margin: 24px auto; padding: 0 20px; }

/* ---- Fixed-header / scrolling-list shell ----
   Wrap the page in .app-shell, put navbar + stats + forms inside
   .sticky-head, and put the list/table inside .scroll-body.
   Only .scroll-body scrolls; the head stays put. */
html, body.app-shell { height: 100%; }
body.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    margin: 0;
}
body.app-shell .navbar { position: static; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.sticky-head {
    flex: 0 0 auto;
    background: #f4f6f8;
    box-shadow: 0 4px 10px -6px rgba(0,0,0,0.18);
    position: relative;
    z-index: 40;
}
.sticky-head .container { margin: 10px auto 8px; }
.sticky-head h2 { margin: 6px 0 4px; font-size: 16px; }
.sticky-head .hint { margin: 2px 0 8px; font-size: 12px; }
.sticky-head form { margin-bottom: 2px; }
.sticky-head textarea { padding: 8px; font-size: 13px; }
.scroll-body {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.scroll-body .container { margin: 8px auto 28px; }
.table-wrap { overflow-x: auto; border-radius: 8px; }
.table-wrap .data-table { min-width: 640px; }
.scroll-body h2 { margin-top: 6px; font-size: 17px; }

h2 { color: #1e3a5f; margin-top: 30px; }

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f2942 0%, #1e3a5f 45%, #2f6690 100%);
    padding: 24px;
}
.auth-box {
    background: #fff;
    padding: 34px 32px 28px;
    border-radius: 14px;
    box-shadow: 0 12px 34px rgba(0,0,0,0.28);
    width: 320px;
    position: relative;
    overflow: hidden;
}
.auth-box::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 6px;
    background: linear-gradient(90deg, #f59e0b, #10b981 50%, #1e3a5f);
}
.auth-box h2 { margin-top: 6px; text-align: center; }
.auth-box label { display: block; margin: 12px 0 4px; font-size: 14px; }
.auth-box input, .auth-box button { width: 100%; padding: 10px; border-radius: 6px; border: 1px solid #ccc; }
.auth-box button {
    margin-top: 18px;
    background: #1e3a5f;
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: background .15s;
}
.auth-box button:hover { background: #14283f; }
.auth-box .hint { font-size: 12px; color: #666; text-align: center; margin-top: 14px; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 56px; }
.password-wrap button.pw-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    margin: 0;
    padding: 5px 10px;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid #cfd8e3;
    background: #f4f6f8;
    color: #1e3a5f;
    cursor: pointer;
}
.password-wrap button.pw-toggle:hover { background: #e2eaf3; }

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
    border-radius: 8px;
    overflow: hidden;
}
.data-table th, .data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid #eee;
    text-align: left;
    font-size: 14px;
}
.data-table th { background: #eef2f7; font-weight: 600; color: #1e3a5f; }
.data-table tbody tr:nth-child(even) { background: #fafbfc; }
.data-table tbody tr:hover { background: #f0f5fb; }
.data-table tfoot th { background: #dde6f0; }

.inline-form { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.inline-form input { padding: 8px; border: 1px solid #ccc; border-radius: 4px; }
.inline-form button, .data-table button {
    background: #1e3a5f; color: #fff; border: none; padding: 8px 14px;
    border-radius: 4px; cursor: pointer;
}
.inline-form button:hover, .data-table button:hover { background: #14283f; }

.stacked-form { max-width: 360px; }
.stacked-form label { display: block; margin: 12px 0 4px; font-size: 14px; }
.stacked-form input, .stacked-form textarea {
    width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px;
}
.stacked-form button {
    margin-top: 16px; background: #1e3a5f; color: #fff; border: none;
    padding: 10px 16px; border-radius: 4px; cursor: pointer;
}

textarea { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-family: monospace; }
form button[type=submit] {
    margin-top: 10px; background: #1e7a4a; color: #fff; border: none;
    padding: 10px 18px; border-radius: 4px; cursor: pointer; font-weight: bold;
}

.stats-row { display: flex; gap: 10px; margin: 10px 0; flex-wrap: wrap; }
.stat-box {
    background: #fff; padding: 8px 14px; border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08); text-align: center;
    flex: 1 1 130px; border-top: 3px solid #1e3a5f;
}
.stat-box strong { display: block; font-size: 17px; color: #1e3a5f; line-height: 1.25; }
.stat-box span { font-size: 11px; color: #666; text-transform: uppercase; letter-spacing: .3px; }

.error { color: #b91c1c; background: #fee2e2; padding: 8px 12px; border-radius: 4px; }
.success { color: #166534; background: #dcfce7; padding: 8px 12px; border-radius: 4px; }
.hint { font-size: 13px; color: #666; }

.badge { padding: 2px 8px; border-radius: 10px; font-size: 12px; }
.badge-active, .badge-parsed, .badge-generated, .badge-refunded { background: #dcfce7; color: #166534; }
.badge-inactive, .badge-failed, .badge-rejected { background: #fee2e2; color: #b91c1c; }
.badge-partial, .badge-pending { background: #fef9c3; color: #854d0e; }

select {
    padding: 8px; border: 1px solid #ccc; border-radius: 4px;
    background: #fff; font-family: inherit; font-size: 13px;
}
.status-form { display: flex; gap: 6px; align-items: center; }
.status-form button {
    background: #1e3a5f; color: #fff; border: none; padding: 7px 12px;
    border-radius: 4px; cursor: pointer; font-size: 13px;
}
.status-form button:hover { background: #14283f; }

/* ---- Combined login page (Admin / User tabs) ---- */
.auth-box.wide { width: 370px; }
.role-tabs {
    display: flex;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #dbe3ec;
    margin-bottom: 22px;
}
.role-tab {
    flex: 1;
    text-align: center;
    padding: 11px 6px;
    cursor: pointer;
    background: #eef2f7;
    color: #1e3a5f;
    font-weight: 600;
    font-size: 14px;
    border: none;
    transition: background .15s, color .15s;
}
.role-tab.active { background: #1e3a5f; color: #fff; }
.role-tab[data-tab="user"].active { background: #0f766e; }
.role-tab:not(.active):hover { background: #e2eaf3; }
.login-form { display: none; }
.login-form.active { display: block; }
#user-form button { background: #0f766e; }
#user-form button:hover { background: #0b5c54; }
.auth-box .brand-sub { text-align: center; color: #6b7a8d; font-size: 13px; margin: -6px 0 20px; }

/* ---- Responsive tweaks ---- */
@media (max-width: 760px) {
    .navbar { padding: 10px 16px; gap: 14px; }
    .navbar .brand { width: 100%; margin-right: 0; }
    .navbar .logout { margin-left: 0; }
    .sticky-head .container, .scroll-body .container, .container { padding: 0 14px; }
    .stats-row { gap: 8px; margin: 8px 0; }
    .stat-box { flex: 1 1 30%; padding: 6px 6px; }
    .stat-box strong { font-size: 14px; }
    .stat-box span { font-size: 9px; }
    .sticky-head h2 { font-size: 14px; margin: 4px 0 2px; }
    .sticky-head .hint { font-size: 11px; margin: 0 0 6px; }
    .inline-form { flex-direction: column; }
    .inline-form input, .inline-form button { width: 100%; }
    .data-table th, .data-table td { padding: 9px 10px; font-size: 13px; }
    .auth-box, .auth-box.wide { width: 90vw; max-width: 370px; padding: 26px 22px; }
    h2 { margin-top: 18px; font-size: 19px; }
}
