/* Invoice Management System - Clean & Simple Theme */
/* Inspired by phpMyAdmin pmahomme theme */

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* Form Controls */
.form-control,
.form-select {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    transition: border-color 0.15s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: #24345f;
    box-shadow: 0 0 0 2px rgba(18, 30, 59, 0.12);
}

.form-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Buttons */
button,
.btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

button:hover,
.btn:hover {
    opacity: 0.9;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
}

th {
    background-color: #eefcf3;
    font-weight: 600;
    text-align: left;
    padding: 7px 10px;
    border-bottom: 2px solid #bbf7d0;
}

td {
    padding: 5px 10px;
    border-bottom: 1px solid #e9ecef;
}

tr:hover {
    background-color: #f8f9fa;
}

table thead tr:hover {
    background-color: #121e3bff !important;
}

/* Cards/Panels */
.card,
.panel {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.card-header,
.panel-heading {
    padding: 12px 16px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #ddd;
    font-weight: 600;
}

.card-body,
.panel-body {
    padding: 16px;
}

/* Navigation */
nav:not(.app-nav) {
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Links */
a {
    color: #4a90e2;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #357abd;
    text-decoration: underline;
}

/* Alerts/Messages */
.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
}

.alert-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.alert-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 3px;
}

.badge-success {
    background-color: #28a745;
    color: #fff;
}

.badge-warning {
    background-color: #ffc107;
    color: #333;
}

.badge-danger {
    background-color: #dc3545;
    color: #fff;
}

.badge-info {
    background-color: #17a2b8;
    color: #fff;
}

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    margin-top: 16px;
}

.pagination a,
.pagination span {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background-color: #fff;
    color: #333;
    border-radius: 3px;
}

.pagination a:hover {
    background-color: #f8f9fa;
    text-decoration: none;
}

.pagination .active {
    background-color: #4a90e2;
    color: #fff;
    border-color: #4a90e2;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-1 {
    margin-top: 4px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 16px;
}

.mb-1 {
    margin-bottom: 4px;
}

.mb-2 {
    margin-bottom: 8px;
}

.mb-3 {
    margin-bottom: 12px;
}

.mb-4 {
    margin-bottom: 16px;
}

.p-2 {
    padding: 8px;
}

.p-3 {
    padding: 12px;
}

.p-4 {
    padding: 16px;
}

/* Sidebar */
.app-sidebar {
    z-index: 30;
    overflow: hidden;
    border-right: 1px solid rgba(15, 23, 42, 0.08);
    background:
        linear-gradient(180deg, rgba(18, 30, 59, 0.08) 0%, rgba(255, 255, 255, 0) 170px),
        #ffffff;
    box-shadow: 12px 0 32px rgba(15, 23, 42, 0.06);
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 78px;
    padding: 18px 18px 16px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border-radius: 8px;
    color: #ffffff;
    background: #24345f;
    box-shadow: 0 10px 22px rgba(18, 30, 59, 0.20);
}

.brand-mark .bi::before {
    font-size: 18px;
}

.app-brand h2 {
    color: #102033;
    font-size: 18px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: 0;
}

.app-brand p {
    margin-top: 4px;
    color: #64748b;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
}

.app-nav {
    padding: 14px 12px 18px;
    background: transparent;
    border-bottom: 0;
    box-shadow: none;
}

.nav-section {
    margin-top: 14px;
}

.nav-heading {
    display: flex;
    align-items: center;
    margin: 0 0 6px;
    padding: 8px 10px;
    border-left: 3px solid #121e3bff;
    border-radius: 8px;
    color: #ffffff;
    background: #121e3bff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: default;
    user-select: none;
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 38px;
    margin-top: 4px;
    padding: 9px 11px;
    border-radius: 8px;
    color: #334155;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    transition: color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.nav-link:hover {
    color: #121e3b;
    background-color: rgba(18, 30, 59, 0.08);
    text-decoration: none;
    transform: translateX(2px);
}

.nav-child {
    margin-left: 0;
    padding-left: 26px;
    color: #475569;
    font-size: 12.5px;
    font-weight: 600;
}

.nav-child::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: #121e3b;
    transform: translateY(-50%);
    opacity: 0.75;
}

.nav-link.is-active {
    color: #121e3b;
    background: rgba(18, 30, 59, 0.10);
    box-shadow: inset 0 0 0 1px rgba(18, 30, 59, 0.10);
}

.nav-link.is-active::after {
    content: "";
    position: absolute;
    right: 8px;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 999px;
    background: #24345f;
}

.app-sidebar-footer {
    padding: 14px 12px;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(248, 250, 252, 0.86);
}

.account-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 40px;
    margin-bottom: 8px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #24345f;
    background: #ffffff;
    border: 1px solid rgba(36, 52, 95, 0.20);
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.account-button:hover {
    color: #121e3b;
    background: rgba(36, 52, 95, 0.08);
    border-color: rgba(36, 52, 95, 0.32);
}

.logout-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: 8px;
    color: #ffffff;
    background: #dc2626;
    border: 1px solid #dc2626;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(127, 29, 29, 0.14);
}

.logout-button:hover {
    color: #ffffff;
    background: #b91c1c;
    border-color: #b91c1c;
}

.mobile-menu-button,
.sidebar-backdrop {
    display: none;
}

select.form-select.native-select-hidden-mobile {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.mobile-select {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
}

.mobile-select-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 38px;
    padding: 8px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    line-height: 1.25;
    text-align: left;
}

.mobile-select-button span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-select-button i {
    width: 8px;
    height: 8px;
    border-right: 2px solid #64748b;
    border-bottom: 2px solid #64748b;
    transform: rotate(45deg);
    flex: 0 0 auto;
    margin-top: -4px;
}

.mobile-select.is-open .mobile-select-button {
    border-color: #24345f;
    box-shadow: 0 0 0 2px rgba(18, 30, 59, 0.12);
}

.mobile-select.is-open .mobile-select-button i {
    margin-top: 4px;
    transform: rotate(225deg);
}

.mobile-select-menu {
    position: fixed;
    z-index: 80;
    display: none;
    max-height: 240px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #cbd5e1;
    border-radius: 9px;
    background: #ffffff;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.18);
}

.mobile-select.is-open .mobile-select-menu {
    display: block;
}

.mobile-select-search {
    position: sticky;
    top: 0;
    z-index: 1;
    width: 100%;
    min-height: 36px;
    padding: 8px 11px;
    border: 0;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 9px 9px 0 0;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    outline: none;
}

.mobile-select-search:focus {
    box-shadow: inset 0 -1px 0 #24345f;
}

.mobile-select-option {
    display: block;
    width: 100%;
    padding: 9px 11px;
    border-radius: 0;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    line-height: 1.25;
    text-align: left;
    border-bottom: 1px solid #eef2f7;
}

.mobile-select-option:last-child {
    border-bottom: 0;
}

.mobile-select-option.is-selected,
.mobile-select-option:hover {
    background: rgba(18, 30, 59, 0.08);
    color: #121e3b;
}

.mobile-select-empty {
    padding: 12px;
    color: #94a3b8;
    font-size: 13px;
    text-align: center;
}

.app-messages {
    position: relative;
    z-index: 2;
}

.django-message {
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.08);
}

#toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9999;
    display: grid;
    gap: 8px;
    width: min(360px, calc(100vw - 32px));
    pointer-events: none;
}

.app-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 12px 14px;
    border-radius: 8px;
    color: #ffffff;
    font-size: 14px;
    line-height: 1.25;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: auto;
}

.app-toast.is-hidden {
    opacity: 0;
    transform: translateX(18px);
}

.app-toast-success {
    background: #16a34a;
}

.app-toast-error {
    background: #dc2626;
}

.app-toast-warning {
    background: #ca8a04;
}

.app-toast-info {
    background: #2563eb;
}

.app-toast svg {
    flex: 0 0 auto;
}

.app-toast .toast-message {
    flex: 1 1 auto;
}

.app-toast button {
    flex: 0 0 auto;
    color: #ffffff;
    opacity: 0.85;
}

.app-toast button:hover {
    opacity: 1;
}

.confirm-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    transition: opacity 0.16s ease;
}

.confirm-modal-backdrop.is-open {
    opacity: 1;
}

.confirm-modal-backdrop.is-closing {
    opacity: 0;
}

.confirm-modal {
    width: min(420px, 100%);
    padding: 18px;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
    transform: translateY(8px) scale(0.98);
    transition: transform 0.16s ease;
}

.confirm-modal-backdrop.is-open .confirm-modal {
    transform: translateY(0) scale(1);
}

.confirm-modal h2 {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
}

.confirm-modal p {
    margin-top: 8px;
    color: #475569;
    font-size: 14px;
    line-height: 1.45;
}

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

.confirm-modal-actions button {
    min-height: 38px;
    padding: 8px 14px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
}

.confirm-cancel {
    color: #334155;
    background: #f1f5f9;
    border: 1px solid #dbe4ee;
}

.confirm-cancel:hover {
    background: #e2e8f0;
}

.confirm-danger {
    color: #ffffff;
    background: #dc2626;
    border: 1px solid #dc2626;
}

.confirm-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

/* Table action icon buttons */
.action-buttons {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.action-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid #dbe4ee;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.action-icon-button:hover {
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.action-icon-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(18, 30, 59, 0.16);
}

.action-icon-button svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.action-icon-button.is-edit {
    color: #24345f;
    border-color: rgba(18, 30, 59, 0.20);
    background: rgba(18, 30, 59, 0.04);
}

.action-icon-button.is-edit:hover {
    color: #121e3b;
    background: rgba(18, 30, 59, 0.08);
    border-color: rgba(18, 30, 59, 0.32);
}

.action-icon-button.is-delete {
    color: #dc2626;
    border-color: #fecaca;
    background: #fff7f7;
}

.action-icon-button.is-delete:hover {
    color: #b91c1c;
    background: #fef2f2;
    border-color: #fca5a5;
}

.action-icon-button.is-delete:focus-visible {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.16);
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 34px;
}

.page-toolbar a,
.page-toolbar button {
    min-height: 32px;
    padding: 6px 11px !important;
    border-radius: 8px !important;
    font-size: 0.78rem !important;
    line-height: 1.15 !important;
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-height: 40px;
    padding: 7px 10px;
    border-top: 1px solid #e2e8f0;
    background: #fbfdff;
}

.table-pagination a,
.table-pagination span {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 700;
}

.table-pagination a {
    padding: 5px 10px;
    color: #334155;
    background: #ffffff;
    border: 1px solid #dbe4ee;
}

.table-pagination a:hover {
    color: #047857;
    background: #f0fdf4;
    border-color: #bbf7d0;
    text-decoration: none;
}

.table-pagination span {
    color: #64748b;
    padding: 0 4px;
}

/* Shared table headers */
table thead,
table thead.bg-gray-50,
table thead.bg-gray-100 {
    background: #121e3bff !important;
}

table thead th {
    color: #ffffff !important;
    background: transparent !important;
    border-top: 1px solid #121e3bff;
    border-bottom: 1px solid #121e3bff !important;
    font-size: 0.72rem;
    font-weight: 800 !important;
    letter-spacing: 0.08em;
    padding-top: 6px !important;
    padding-bottom: 6px !important;
}

table tbody td {
    padding-top: 5px !important;
    padding-bottom: 5px !important;
    line-height: 1.18 !important;
    font-size: 0.82rem;
}

table tbody td .rounded-full {
    line-height: 1.2 !important;
    padding-top: 1px !important;
    padding-bottom: 1px !important;
}

table .table-index {
    width: 42px;
    min-width: 42px;
    padding-left: 10px !important;
    padding-right: 6px !important;
    color: #64748b !important;
    text-align: center !important;
    white-space: nowrap;
}

table tbody .table-index {
    font-size: 0.76rem;
    font-weight: 700;
}

.invoice-detail-items {
    margin-left: -12px;
    width: calc(100% + 18px);
}

.invoice-detail-info {
    align-items: start;
    padding-top: 18px !important;
    padding-bottom: 18px !important;
}

.invoice-detail-info .mt-2 {
    margin-top: 0 !important;
}

.invoice-detail-items.py-8 {
    padding-top: 12px !important;
    padding-bottom: 26px !important;
}

.invoice-detail-items th,
.invoice-detail-items td {
    text-align: left !important;
}

.invoice-detail-actions {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    justify-content: stretch !important;
}

.invoice-detail-actions > * {
    width: 100% !important;
    min-height: 36px;
    margin-left: 0 !important;
}

.invoice-detail-actions .action-icon-button,
.invoice-detail-actions .invoice-detail-action-button {
    height: 36px;
    justify-content: center;
}

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

table thead th:first-child {
    border-top-left-radius: 8px;
}

table thead th:last-child {
    border-top-right-radius: 8px;
}

.quick-action-btn {
    transition: all 0.2s ease;
}

.quick-action-btn:hover {
    border-color: #05CB3A !important;
    background-color: rgba(13, 181, 97, 0.1) !important;
}

.quick-action-btn:hover i {
    color: #05CB3A !important;
}

/* Primary Button Styles */
.btn-primary {
    background-color: #121e3bff;
    color: white;
    border: none;
}

.btn-primary:hover {
    background-color: #1c2b52;
    color: white;
}

/* Primary Text Color */
.text-primary {
    color: #05CB3A;
}

.text-primary:hover {
    color: #0a8f4d;
}

/* Primary Background Light */
.bg-primary-light {
    background-color: rgba(13, 181, 97, 0.1);
}

/* Primary Border */
.border-primary {
    border-color: #05CB3A;
}

/* Global Color Override - Replace Indigo with Green */
.bg-indigo-600,
.bg-indigo-700,
button.bg-indigo-600,
button.bg-indigo-700,
a.bg-indigo-600,
a.bg-indigo-700 {
    background-color: #121e3bff !important;
}

/* Local icon set (replaces external icon frameworks) */
.bi {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    line-height: 1;
    font-style: normal;
}

.bi::before {
    display: inline-block;
    font-size: 1em;
    line-height: 1;
    font-weight: 600;
    content: "•";
}

.bi-house-door::before { content: "⌂"; }
.bi-people::before { content: "◉"; }
.bi-box-seam::before { content: "▣"; }
.bi-file-earmark-text::before { content: "▤"; }
.bi-person-badge::before { content: "◍"; }
.bi-box-arrow-right::before { content: "↦"; }
.bi-person-plus::before { content: "+"; }
.bi-plus-circle::before { content: "⊕"; }
.bi-file-earmark-plus::before { content: "⊞"; }
.bi-shield-lock::before { content: "⛨"; }
.bi-check-circle::before { content: "✓"; }
.bi-info-circle::before { content: "i"; }
.bi-plus-lg::before { content: "+"; }
.bi-trash3-fill::before { content: "✕"; }

.bg-indigo-600:hover,
.bg-indigo-700:hover,
button.bg-indigo-600:hover,
button.bg-indigo-700:hover,
a.bg-indigo-600:hover,
a.bg-indigo-700:hover {
    background-color: #1c2b52 !important;
}

.bg-indigo-50 {
    background-color: rgba(13, 181, 97, 0.1) !important;
}

.bg-indigo-100 {
    background-color: rgba(13, 181, 97, 0.2) !important;
}

.text-indigo-600,
.text-indigo-800,
.text-indigo-900,
a.text-indigo-600,
a.text-indigo-800,
a.text-indigo-900 {
    color: #05CB3A !important;
}

.text-indigo-600:hover,
.text-indigo-800:hover,
.text-indigo-900:hover,
a.text-indigo-600:hover,
a.text-indigo-800:hover,
a.text-indigo-900:hover {
    color: #0a8f4d !important;
}

.border-indigo-500 {
    border-color: #05CB3A !important;
}

.focus\:ring-indigo-500:focus {
    --tw-ring-color: #05CB3A !important;
}

.hover\:border-indigo-500:hover {
    border-color: #05CB3A !important;
}

/* Tutorial Modal Fixed Positioning */
#tutorial-modal {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    top: auto !important;
    left: auto !important;
    transform: translate(0, 0) !important;
}

@media (max-width: 768px) {
    body {
        font-size: 13px;
        background: #f8fafc;
        overflow-x: hidden;
    }

    html {
        overflow-x: hidden;
    }

    .min-h-screen.flex {
        display: block;
    }

    .mobile-menu-button {
        position: fixed;
        top: 10px;
        left: 12px;
        z-index: 60;
        display: inline-flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        width: 38px;
        height: 38px;
        border: 1px solid #dbe4ee;
        border-radius: 10px;
        background: #ffffff;
        box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
        transition: left 0.22s ease, transform 0.18s ease, opacity 0.18s ease;
    }

    body.sidebar-open .mobile-menu-button {
        left: calc(min(56vw, 260px) - 19px);
    }

    .mobile-menu-button span {
        width: 18px;
        height: 2px;
        border-radius: 999px;
        background: #334155;
        transition: transform 0.18s ease, opacity 0.18s ease;
    }

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

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

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

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 45;
        display: block;
        background: rgba(15, 23, 42, 0.38);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.18s ease;
    }

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

    .app-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        z-index: 50;
        display: flex !important;
        flex-direction: column;
        width: min(56vw, 260px) !important;
        height: 100vh !important;
        height: 100svh !important;
        max-height: 100vh;
        max-height: 100svh;
        transform: translateX(-104%);
        border-right: 1px solid rgba(15, 23, 42, 0.08);
        border-bottom: 0;
        box-shadow: 18px 0 42px rgba(15, 23, 42, 0.2);
        transition: transform 0.22s ease;
    }

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

    .app-brand {
        min-height: 52px;
        padding: 10px 10px 10px 54px;
    }

    body.sidebar-open .app-brand {
        padding-left: 10px;
        padding-right: 34px;
    }

    .brand-mark {
        width: 30px;
        height: 30px;
        flex-basis: 30px;
    }

    .app-brand h2 {
        font-size: 13px;
    }

    .app-brand p {
        font-size: 10px;
    }

    .app-nav {
        display: block;
        flex: 1 1 auto;
        min-height: 0;
        padding: 9px;
        overflow-x: hidden;
        overflow-y: auto;
        white-space: normal;
        -webkit-overflow-scrolling: touch;
    }

    .nav-section {
        display: block;
        margin-top: 9px;
    }

    .nav-heading {
        padding: 7px 8px;
        font-size: 9px;
    }

    .nav-link {
        min-height: 32px;
        margin-top: 4px;
        padding: 7px 8px;
        font-size: 11px;
        background: transparent;
        border: 0;
    }

    .nav-link:hover {
        transform: none;
    }

    .nav-child {
        padding-left: 18px;
    }

    .nav-link.is-active::after {
        top: 9px;
        left: auto;
        right: 8px;
        bottom: 9px;
        width: 3px;
        height: auto;
    }

    .app-sidebar-footer {
        flex: 0 0 auto;
        position: sticky;
        bottom: 0;
        z-index: 2;
        padding: 7px 9px 9px;
        padding-bottom: max(9px, env(safe-area-inset-bottom));
        background: rgba(248, 250, 252, 0.98);
        box-shadow: 0 -8px 18px rgba(15, 23, 42, 0.06);
    }

    .logout-button {
        min-height: 32px;
        font-size: 11px;
    }

    .account-button {
        min-height: 32px;
        margin-bottom: 6px;
        font-size: 11px;
    }

    .ml-64 {
        margin-left: 0 !important;
    }

    header.sticky {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        z-index: 40 !important;
        background: #ffffff !important;
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08) !important;
    }

    header .px-6 {
        padding-left: 60px !important;
        padding-right: 14px !important;
    }

    header .py-4 {
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }

    header h1 {
        font-size: 18px !important;
        line-height: 1.25 !important;
    }

    main.p-6,
    main {
        padding: 60px 12px 12px !important;
    }

    .app-messages {
        margin-top: 6px !important;
        margin-bottom: 12px !important;
    }

    .django-message {
        padding: 10px 12px !important;
        font-size: 13px;
        line-height: 1.35;
    }

    .space-y-6 > :not([hidden]) ~ :not([hidden]) {
        margin-top: 12px !important;
    }

    .page-toolbar {
        justify-content: stretch;
        min-height: 0;
    }

    .page-actions,
    .page-toolbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .page-toolbar a,
    .page-toolbar button,
    .page-actions a,
    .page-actions button {
        flex: 1 1 auto;
        justify-content: center;
        min-height: 34px;
    }

    .overflow-x-auto {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .overflow-x-auto > table {
        width: max-content;
        min-width: 100%;
        table-layout: auto;
    }

    .overflow-x-auto > table thead th {
        padding-left: 8px !important;
        padding-right: 8px !important;
        padding-top: 6px !important;
        padding-bottom: 6px !important;
        line-height: 1.18 !important;
        font-size: 0.68rem;
    }

    .overflow-x-auto > table tbody td {
        padding-left: 8px !important;
        padding-right: 8px !important;
        padding-top: 5px !important;
        padding-bottom: 5px !important;
        line-height: 1.18 !important;
        font-size: 0.78rem;
    }

    select,
    .form-select {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        position: relative;
        z-index: 1;
    }

    table thead th {
        font-size: 0.68rem;
        padding-top: 6px !important;
        padding-bottom: 6px !important;
    }

    table tbody td {
        font-size: 0.78rem;
    }

    table .table-index {
        width: 36px;
        min-width: 36px;
    }

    .invoice-detail-card.p-8 {
        padding: 20px 14px !important;
    }

    .invoice-detail-info {
        gap: 12px;
        padding-top: 12px !important;
        padding-bottom: 10px !important;
    }

    .invoice-detail-items {
        margin-left: -8px;
        width: calc(100% + 18px);
    }

    .invoice-detail-items.py-8 {
        padding-top: 8px !important;
        padding-bottom: 22px !important;
    }

    .invoice-detail-items table {
        table-layout: auto;
    }

    .invoice-detail-items th,
    .invoice-detail-items td {
        padding-left: 3px !important;
        padding-right: 3px !important;
        text-align: left !important;
    }

    .invoice-detail-items thead th {
        font-size: 0.58rem;
        letter-spacing: 0;
        white-space: nowrap;
    }

    .invoice-detail-items tbody td {
        font-size: 0.76rem;
    }

    .invoice-detail-items .table-index {
        width: 24px;
        min-width: 24px;
    }

    .invoice-detail-items th:nth-child(2),
    .invoice-detail-items td:nth-child(2) {
        width: 1%;
        white-space: nowrap;
    }

    .invoice-detail-items th:nth-child(3),
    .invoice-detail-items td:nth-child(3) {
        width: 1%;
        white-space: nowrap;
    }

    .invoice-detail-items th:nth-child(4),
    .invoice-detail-items td:nth-child(4) {
        width: 1%;
        white-space: nowrap;
    }

    .invoice-detail-items th:nth-child(5),
    .invoice-detail-items td:nth-child(5),
    .invoice-detail-items th:nth-child(6),
    .invoice-detail-items td:nth-child(6) {
        width: auto;
        white-space: nowrap;
    }

    .table-pagination {
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
    }

    .action-buttons {
        gap: 7px;
    }

    .action-icon-button {
        width: 28px;
        height: 28px;
    }

    .max-w-2xl,
    .max-w-3xl,
    .max-w-4xl,
    .max-w-lg,
    .max-w-md {
        max-width: 100% !important;
    }

    .grid {
        grid-template-columns: 1fr !important;
    }

    .dashboard-stats {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
        margin-top: 8px !important;
        margin-bottom: 10px !important;
    }

    .dashboard-stats > div {
        padding: 10px !important;
        min-height: 86px;
    }

    .dashboard-stats .flex {
        align-items: flex-start;
        gap: 6px;
    }

    .dashboard-stats p.text-sm {
        font-size: 11px !important;
        line-height: 1.2 !important;
    }

    .dashboard-stats p.text-2xl {
        font-size: 15px !important;
        line-height: 1.2 !important;
        margin-top: 2px;
        overflow-wrap: anywhere;
    }

    .dashboard-stats p.text-xs {
        font-size: 9.5px !important;
        line-height: 1.2 !important;
        margin-top: 6px !important;
    }

    .dashboard-stats .rounded-full {
        padding: 6px !important;
        flex: 0 0 auto;
    }

    .dashboard-stats svg {
        width: 15px !important;
        height: 15px !important;
    }

    .dashboard-activity {
        gap: 10px !important;
        margin-top: 10px !important;
        margin-bottom: 10px !important;
    }

    .dashboard-panel-header {
        padding: 10px 12px !important;
    }

    .dashboard-panel-header h3,
    .dashboard-quick-actions h3 {
        font-size: 15px !important;
        line-height: 1.25 !important;
    }

    .dashboard-panel-body {
        padding: 10px !important;
    }

    .dashboard-list {
        row-gap: 7px !important;
    }

    .dashboard-list-item {
        padding: 8px 9px !important;
        border-radius: 7px !important;
        gap: 10px;
    }

    .dashboard-list-item p {
        line-height: 1.2 !important;
    }

    .dashboard-list-item p.font-medium,
    .dashboard-list-item p.font-semibold {
        font-size: 12px !important;
    }

    .dashboard-list-item p.text-sm {
        font-size: 10.5px !important;
    }

    .dashboard-panel-body > a {
        margin-top: 10px !important;
        font-size: 12px !important;
    }

    .dashboard-quick-actions {
        padding: 9px !important;
        margin-top: 8px !important;
        margin-bottom: 8px !important;
    }

    .dashboard-quick-actions h3 {
        margin-bottom: 7px !important;
    }

    .dashboard-quick-actions .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 6px !important;
    }

    .dashboard-quick-actions .quick-action-btn {
        padding: 6px 5px !important;
        min-height: 48px;
        border-radius: 6px !important;
        border-width: 1px !important;
    }

    .dashboard-quick-actions .quick-action-btn i {
        margin-bottom: 3px !important;
        font-size: 13px !important;
    }

    .dashboard-quick-actions .quick-action-btn span {
        font-size: 10px !important;
        line-height: 1.2 !important;
        text-align: center;
    }

    form.p-6 {
        padding: 14px !important;
    }

    .form-control,
    .form-select {
        min-height: 36px;
        font-size: 13px;
    }

    .flex.justify-end.space-x-3 {
        gap: 8px;
        flex-wrap: wrap;
    }

    .flex.justify-end.space-x-3 > * {
        margin-left: 0 !important;
        flex: 1 1 auto;
        justify-content: center;
    }

    .role-panel-header {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 10px;
    }

    .role-panel-title {
        font-size: 16px !important;
        line-height: 1.2 !important;
    }

    .role-create-form {
        min-width: 0;
        width: 100%;
        flex-wrap: nowrap;
        gap: 6px;
        padding: 6px;
        border-radius: 12px;
    }

    .role-create-input {
        min-width: 0;
        flex: 1 1 auto;
        flex-basis: auto;
    }

    .role-create-form input {
        min-height: 32px;
        font-size: 12px;
    }

    .role-create-form .role-action-button {
        min-height: 32px;
        padding: 6px 10px;
        font-size: 11px !important;
    }

    .role-card-header {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .role-summary-meta,
    .role-permission-actions {
        justify-content: flex-start;
    }

    .permission-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 6px;
    }

    .permission-chip {
        min-height: 32px;
        gap: 6px;
        padding: 6px 7px;
        font-size: 11px;
    }

    .permission-chip input {
        width: 13px;
        height: 13px;
    }

    .toast-container,
    #toast-container {
        left: 12px !important;
        right: 12px !important;
        top: 58px !important;
        z-index: 70 !important;
    }
}

/* ===== Shared search toolbar (list pages) ===== */
.search-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 4px 10px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color .15s, box-shadow .15s;
    flex: 1 1 320px;
    min-width: 0;
    max-width: 560px;
}

.search-bar:focus-within {
    border-color: #121e3b;
    box-shadow: 0 0 0 3px rgba(18, 30, 59, 0.08);
}

.search-bar i {
    color: #94a3b8;
    font-size: 16px;
}

.search-bar input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    padding: 6px 4px;
    font-size: 14px;
    color: #0f172a;
    background: transparent;
}

.search-bar input::placeholder { color: #94a3b8; }

.search-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 7px;
    color: #64748b;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.search-clear:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.search-submit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: #121e3b;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s;
    white-space: nowrap;
}

.search-submit:hover { background: #1c2b52; }

.search-toolbar .page-actions {
    margin-left: auto;
}

.search-toolbar .page-actions > a,
.search-toolbar .page-actions > button {
    min-width: 140px;
    justify-content: center;
    padding: 8px 14px !important;
    font-size: 13px !important;
    font-weight: 600;
    line-height: 1.2;
}

@media (max-width: 640px) {
    .search-toolbar {
        gap: 8px;
        flex-wrap: nowrap;
    }
    .search-bar {
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
        padding: 3px 8px;
    }
    .search-bar input {
        font-size: 13px;
        padding: 5px 2px;
    }
    .search-submit {
        padding: 6px 10px;
        font-size: 12px;
    }
    .search-toolbar .page-actions {
        margin-left: 0;
        flex-shrink: 0;
        gap: 6px;
    }
    .search-toolbar .page-actions > a,
    .search-toolbar .page-actions > button {
        min-width: 0;
        padding: 7px 12px !important;
        font-size: 12px !important;
        white-space: nowrap;
    }
}

#app-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, #05CB3A, #24345f);
    box-shadow: 0 0 8px rgba(5, 203, 58, 0.55);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: width 0.3s ease-out, opacity 0.25s ease;
}

#app-progress.is-active {
    opacity: 1;
}
