/* Admin theme. No third-party CSS: this file provides the small set of grid,
   form, button and table classes the pages use, plus the layout. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; line-height: 1.5; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 12px; }
h4 { font-size: 15px; margin-top: 24px; }
img { max-width: 100%; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
table { border-collapse: collapse; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Grid: columns stack on small screens */
.row { display: flex; flex-wrap: wrap; margin: 0 -12px; }
.row > [class*="col-"] { padding: 0 12px; width: 100%; }
@media (min-width: 992px) {
    .col-lg-6 { max-width: 760px; }
    .col-lg-9 { max-width: 980px; }
    .col-sm-8 { width: 66.66% !important; }
    .col-sm-4 { width: 33.33% !important; }
}

.icon { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid transparent; cursor: pointer; font-size: 14px; line-height: 1.4;
    color: #fff; text-decoration: none !important; white-space: nowrap; font-family: inherit;
}
.btn:hover { filter: brightness(.95); color: #fff; }
.btn-lg { padding: 10px 18px; font-size: 15px; }
.btn-block { display: flex; width: 100%; }
.btn-link { background: transparent; color: var(--brand); border-color: transparent; }
.btn-link:hover { color: var(--brand-dark); }

/* Tables */
.table { width: 100%; background: #fff; }
.table th, .table td { padding: 10px 12px; text-align: left; }
.table-bordered { border: 1px solid var(--border); }

/* Forms */
.form-control { display: block; width: 100%; font-family: inherit; color: var(--text); }
textarea.form-control { min-height: 80px; }
.checkbox label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.label { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; color: #fff; }

:root {
    --brand: #1f4e8c;
    --brand-dark: #173b6b;
    --accent: #f28c28;
    --sidebar: #0f1f3d;
    --sidebar-text: #b9c4d8;
    --sidebar-active: #1c3463;
    --bg: #f3f5fa;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --success: #15803d;
    --danger: #b91c1c;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --sidebar-width: 240px;
    --topbar-height: 60px;
}

html, body { background: var(--bg); }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
a:hover, a:focus { color: var(--brand-dark); }

/* ---------- Layout ---------- */
.sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: var(--sidebar-width);
    background: var(--sidebar);
    color: var(--sidebar-text);
    overflow-y: auto;
    z-index: 1030;
    transition: transform .2s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-height);
    padding: 0 20px;
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-brand:hover, .sidebar-brand:focus { color: #fff; text-decoration: none; }
.sidebar-brand .icon { color: var(--accent); width: 22px; height: 22px; flex-basis: 22px; }
.sidebar-section {
    padding: 18px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #7f8db0;
}
.sidebar-nav { list-style: none; margin: 0; padding: 0 10px 20px; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    margin: 2px 0;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
}
.sidebar-nav a .icon { opacity: .85; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }

.topbar {
    position: fixed;
    top: 0; right: 0;
    left: var(--sidebar-width);
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
    z-index: 1020;
}
.topbar-title { font-weight: 600; font-size: 16px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.menu-toggle {
    display: none;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 6px 10px;
    color: var(--text);
    border-radius: 8px;
}
.menu-toggle:hover { background: var(--bg); }

#page-wrapper {
    margin-left: var(--sidebar-width);
    padding: calc(var(--topbar-height) + 24px) 28px 40px;
    min-height: 100vh;
}
.sidebar-backdrop { display: none; }

/* ---------- Page elements ---------- */
.page-header {
    margin: 0 0 20px;
    padding: 0;
    border: 0;
    font-size: 22px;
    font-weight: 600;
}
.panel {
    background: var(--card);
    border: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.panel-default > .panel-heading {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    font-weight: 600;
    color: var(--text);
    border-radius: var(--radius) var(--radius) 0 0;
}
.panel-heading:after { content: ""; display: table; clear: both; }
.panel-body { padding: 20px; overflow-x: auto; }
.dataTable_wrapper, .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { margin-bottom: 0; }
.table > thead > tr > th, .table > tbody > tr > th, .table > tr > th, .table th {
    background: #f9fafb;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border) !important;
    white-space: nowrap;
}
.table > tbody > tr > td, .table td { vertical-align: middle; border-top: 1px solid var(--border); }
.table-bordered, .table-bordered > tbody > tr > td, .table-bordered > tbody > tr > th { border-color: var(--border); }
.table-striped > tbody > tr:nth-of-type(odd) { background: #fcfcfd; }
.table-hover > tbody > tr:hover { background: #f5f8ff; }

.btn { border-radius: 8px; font-weight: 500; padding: 6px 14px; transition: background .15s, box-shadow .15s; }
.btn + .btn, form + .btn, .btn + form { margin-left: 4px; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-warning { background: var(--accent); border-color: var(--accent); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-default { background: #fff; border-color: var(--border); color: var(--text); }
.btn-default:hover { background: var(--bg); color: var(--text); filter: none; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

label { font-weight: 600; font-size: 13px; color: #374151; margin-bottom: 6px; }
.form-group { margin-bottom: 18px; }
.form-control,
.panel-body select,
.panel-body input[type=text],
.panel-body input[type=email],
.panel-body input[type=password],
.panel-body input[type=date],
.panel-body textarea {
    height: auto;
    min-height: 38px;
    padding: 7px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: none;
    background: #fff;
    font-size: 14px;
    max-width: 100%;
}
.panel-body select:not(.form-control),
.panel-body input[type=text]:not(.form-control) { display: inline-block; width: auto; margin: 0 6px 6px 0; }
.form-control:focus, .panel-body select:focus, .panel-body input:focus, .panel-body textarea:focus {
    border-color: var(--brand);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(31, 78, 140, .15);
}
#error_msg:not(:empty) {
    display: block;
    margin-bottom: 16px;
    padding: 10px 14px;
    border-radius: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger) !important;
}
.alert-flash {
    margin-bottom: 20px;
    padding: 10px 14px;
    border-radius: 8px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    font-weight: 500;
}
.label-success { background: var(--success); }
.badge-status { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-unpaid { background: #fee2e2; color: #991b1b; }
.badge-export { background: #e0e7ff; color: #3730a3; }

/* Compact "more actions" menu without JavaScript */
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.actions .btn + .btn { margin-left: 0; }
.more-menu { position: relative; display: inline-block; }
.more-menu > summary { list-style: none; cursor: pointer; }
.more-menu > summary::-webkit-details-marker { display: none; }
.more-menu[open] > summary { background: var(--bg); }
.more-menu-items {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 230px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(16, 24, 40, .15);
    padding: 6px;
    z-index: 20;
}
.more-menu-items a { display: block; padding: 8px 12px; border-radius: 6px; color: var(--text); }
.more-menu-items a:hover { background: var(--bg); text-decoration: none; }

/* Dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.stat-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.text-right { text-align: right; }

/* Pagination (Paginator) */
div.pagination { display: flex; flex-wrap: wrap; gap: 4px; margin: 16px 0 0; }
div.pagination a, div.pagination span { border-radius: 6px !important; }

/* ---------- Login / password pages ---------- */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(135deg, #0f1f3d 0%, #1f4e8c 100%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); padding: 32px 28px; }
.auth-card h3 { margin: 0 0 6px; font-size: 22px; font-weight: 700; }
.auth-card .auth-sub { color: var(--muted); margin-bottom: 22px; }
.auth-card .btn-block { padding: 10px; font-size: 15px; }
.auth-card .form-control { height: 42px; }
.auth-logo { display: block; max-height: 56px; margin: 0 auto 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1025; }
    .topbar { left: 0; padding: 0 12px; }
    .menu-toggle { display: inline-flex; }
    #page-wrapper { margin-left: 0; padding: calc(var(--topbar-height) + 16px) 16px 32px; }
}
@media (max-width: 600px) {
    .panel-body { padding: 14px; }
    .panel-body select:not(.form-control),
    .panel-body input[type=text]:not(.form-control) { display: block; width: 100%; margin-right: 0; }
    .page-header { font-size: 19px; }
    .topbar-user { display: none; }
}

.search-form { display: flex; gap: 8px; max-width: 460px; margin-bottom: 20px; }
.search-form .form-control { flex: 1; }

/* Keep wide tables inside their card instead of widening the page */
#page-wrapper, .row > [class*="col-"], .panel, .panel-body { min-width: 0; }
label { display: block; }
.checkbox label { display: flex; }
@media (max-width: 600px) {
    .table td, .table th { white-space: nowrap; }
    .stat-grid { grid-template-columns: 1fr; }
}
.row > form { width: 100%; padding: 0 12px; }
.actions { flex-wrap: nowrap; }
