/* PS Traders - Billing Application Styles */
/* Version: 2.0 - Sidebar Navigation */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --border-color: #e2e8f0;
    --text-color: #334155;
    --text-light: #64748b;

    /* Action button palette */
    /* Softer, standard tones that match the light UI */
    --action-view: #3b82f6;
    --action-view-dark: #2563eb;
    --action-edit: #6366f1;
    --action-edit-dark: #4f46e5;
    --action-print: #22c55e;
    --action-print-dark: #16a34a;
    --action-delete: #f87171;
    --action-delete-dark: #ef4444;
    --action-reset: #fbbf24;
    --action-reset-dark: #f59e0b;
    --action-cancel: #94a3b8;
    --action-cancel-dark: #64748b;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--light-color);
    color: var(--text-color);
    line-height: 1.6;
    padding-left: 80px;
    padding-top: 80px;
    transition: padding-left 0.3s ease, padding-top 0.3s ease;
}

body.sidebar-expanded {
    padding-left: 200px;
}

body.login-page {
    padding-left: 0;
    padding-top: 0;
}

/* Topbar */
.topbar {
    position: fixed;
    top: 0;
    left: 80px;
    right: 0;
    height: 80px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 999;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    transition: left 0.3s ease;
}

body.sidebar-expanded .topbar {
    left: 200px;
}

.topbar-content {
    width: 100%;
    max-width: 100%;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--dark-color);
    margin: 0;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    color: var(--text-color);
    font-weight: 500;
}

/* Header - Sidebar */
.main-header {
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    width: 80px !important;
    height: 100vh !important;
    background: linear-gradient(180deg, var(--primary-color) 0%, #1e40af 100%) !important;
    color: white;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease;
}

.main-header.expanded {
    width: 200px !important;
}

/* Avoid "collapse then expand" flash on page navigation.
   JS adds `.expanded` slightly later; this keeps the default state stable. */
body.sidebar-expanded .main-header {
    width: 200px !important;
}

body.sidebar-expanded .main-header .logo-text {
    display: block;
    opacity: 1;
    max-width: 200px;
    max-height: 200px;
}

body.sidebar-expanded .main-header .nav-text {
    opacity: 1;
    max-width: 200px;
}

body.sidebar-expanded .main-header .nav-link {
    justify-content: flex-start;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

body.sidebar-expanded .main-header .arrow-icon {
    transform: rotate(180deg);
}

.main-header::-webkit-scrollbar {
    width: 4px;
}

.main-header::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
}

.main-header::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.main-header::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

.header-content {
    display: flex !important;
    flex-direction: column !important;
    height: 100%;
    padding: 1rem 0;
    width: 100%;
}

.logo {
    padding: 1rem 0.5rem;
    margin-bottom: 1rem;
    text-align: left;
    border-bottom: 2px solid rgba(255,255,255,0.25);
    padding-bottom: 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 0 0 12px 12px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
}

.logo-text {
    opacity: 0;
    max-width: 0;
    max-height: 0;
    transition: opacity 0.3s ease, max-width 0.3s ease, max-height 0.3s ease;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    pointer-events: none;
}

.main-header:not(.expanded) .logo-text {
    display: none;
}

.main-header.expanded .logo-text {
    display: block;
}

.main-header.expanded .logo-text {
    opacity: 1;
    max-width: 200px;
    max-height: 200px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: white;
    width: 56px;
    height: 56px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    z-index: 10;
    flex-shrink: 0;
    padding: 0;
    border-radius: 16px;
    background: none;
}

.sidebar-toggle:hover {
    transform: scale(1.1);
}

.sidebar-toggle:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 3px;
}

.arrow-icon {
    width: 30px;
    height: 30px;
    transition: transform 0.3s ease;
    display: block;
}

.main-header:not(.expanded) .arrow-icon {
    width: 30px;
    height: 30px;
}

.main-header.expanded .arrow-icon {
    transform: rotate(180deg);
}

.logo h1 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
    line-height: 1.2;
    word-break: break-word;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    white-space: nowrap;
}

.logo span {
    font-size: 0.65rem;
    opacity: 0.9;
    display: block;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
}

/* Logo text adjustments when collapsed */
.main-header:not(.expanded) .logo {
    justify-content: center;
    padding: 1rem 0.5rem;
}

.main-header:not(.expanded) .logo h1 {
    font-size: 0.85rem;
    margin-bottom: 0.15rem;
}

.main-header:not(.expanded) .logo span {
    font-size: 0.55rem;
}

.main-header.expanded .logo h1 {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.main-header.expanded .logo span {
    font-size: 0.65rem;
}

.main-nav {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.5rem;
    flex: 1;
    padding: 0.5rem;
    width: 100%;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.875rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    font-weight: 500;
    position: relative;
    border-left: 3px solid transparent;
    background: transparent;
    gap: 0.75rem;
}

.nav-icon {
    min-width: 20px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.skeleton-icon {
    color: rgba(255, 255, 255, 0.7);
}

.skeleton-icon svg {
    width: 100%;
    height: 100%;
}

.nav-text {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.9rem;
    transition: opacity 0.3s ease, max-width 0.3s ease;
}

.main-header.expanded .nav-text {
    opacity: 1;
    max-width: 200px;
}

.main-header.expanded .nav-link {
    justify-content: flex-start;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.nav-link:hover {
    transform: none;
    box-shadow: none;
}

/* Remove hover background for menu items (keep active only) */
.main-nav .nav-link:not(.active):not(.logout):not(.reset-credentials):hover {
    background: transparent !important;
    border-left-color: transparent !important;
}

.nav-link.active {
    /* Match the sidebar gradient better (no left "white border") */
    background-color: rgba(255, 255, 255, 0.14);
    border-left-color: transparent;
    font-weight: 600;
}

.nav-link.active .skeleton-icon {
    color: white;
}

.nav-link.logout {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    margin-top: 10px;
    border-left: none;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
    font-weight: 600;
    display: flex;
    /* Slightly smaller + centered content */
    padding: 0.75rem 0.875rem;
    min-height: 46px;
    gap: 0.5rem;
}

.main-header.expanded .nav-link.logout {
    justify-content: center;
    text-align: center;
}

.nav-link.logout .nav-icon {
    min-width: 18px;
    width: 18px;
    height: 18px;
}

.nav-link.logout .nav-text {
    font-size: 0.85rem;
}

.main-header:not(.expanded) .nav-link.logout {
    display: none;
}

.nav-link.logout:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.main-header.expanded .nav-link.logout:hover {
    transform: translateY(-2px) translateX(0);
}

/* Logout confirmation modal */
.ps-logout-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    z-index: 2000;
}

.ps-logout-overlay.is-open {
    display: flex;
}

.ps-logout-modal {
    width: min(420px, 100%);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(226, 232, 240, 0.9);
    padding: 1.25rem 1.25rem 1rem;
    transform: translateY(10px) scale(0.985);
    opacity: 0;
    transition: transform 180ms ease, opacity 180ms ease;
}

.ps-logout-overlay.is-open .ps-logout-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.ps-logout-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.ps-logout-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    flex: 0 0 auto;
}

.ps-logout-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark-color);
    margin: 0;
}

.ps-logout-message {
    margin: 0.5rem 0 1rem;
    color: var(--text-color);
    line-height: 1.5;
}

.ps-logout-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.ps-logout-btn {
    border: none;
    border-radius: 10px;
    padding: 0.65rem 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.ps-logout-btn:active {
    transform: translateY(1px);
}

.ps-logout-btn-cancel {
    background: linear-gradient(135deg, var(--action-cancel), var(--action-cancel-dark));
    color: white;
}

.ps-logout-btn-cancel:hover {
    background: linear-gradient(135deg, var(--action-cancel-dark), #334155);
}

.ps-logout-btn-ok {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    box-shadow: 0 10px 22px rgba(239, 68, 68, 0.28);
}

.ps-logout-btn-ok:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 12px 26px rgba(239, 68, 68, 0.35);
}

/* Reset Credentials nav button and modal - new scoped styles only */
.nav-link.reset-credentials {
    background: linear-gradient(135deg, #64748b, #475569) !important;
    margin-top: auto;
    margin-bottom: 10px;
    border-left: none;
    box-shadow: 0 2px 6px rgba(71, 85, 105, 0.3);
    font-weight: 600;
    display: flex;
    padding: 0.75rem 0.875rem;
    min-height: 46px;
    gap: 0.5rem;
    border: none;
    cursor: pointer;
    font-family: inherit;
    width: 100%;
    text-align: left;
    color: white;
}

.main-header.expanded .nav-link.reset-credentials {
    justify-content: center;
    text-align: center;
}

.nav-link.reset-credentials .nav-icon,
.nav-link.reset-credentials .skeleton-icon {
    min-width: 18px;
    width: 18px;
    height: 18px;
    color: white;
}

.nav-link.reset-credentials .nav-text {
    font-size: 0.85rem;
    color: white;
}

.main-header:not(.expanded) .nav-link.reset-credentials {
    display: none;
}

.nav-link.reset-credentials:hover {
    background: linear-gradient(135deg, #475569, #334155) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(51, 65, 85, 0.5);
}

.main-header.expanded .nav-link.reset-credentials:hover {
    transform: translateY(-2px) translateX(0);
}

.ps-reset-credentials-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    z-index: 2001;
}

.ps-reset-credentials-overlay.is-open {
    display: flex;
}

.ps-reset-credentials-modal {
    width: min(420px, 100%);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 16px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(226, 232, 240, 0.9);
    padding: 1.25rem 1.25rem 1rem;
    transform: translateY(10px) scale(0.985);
    opacity: 0;
    transition: transform 180ms ease, opacity 180ms ease;
}

.ps-reset-credentials-overlay.is-open .ps-reset-credentials-modal {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.ps-reset-credentials-overlay .ps-reset-credentials-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark-color);
    margin: 0 0 0.5rem 0;
}

.ps-reset-credentials-overlay .ps-reset-credentials-message {
    margin: 0 0 1rem 0;
    color: var(--text-color);
    line-height: 1.5;
    font-size: 0.95rem;
}

.ps-reset-credentials-overlay .form-group {
    margin-bottom: 1rem;
}

.ps-reset-credentials-overlay .form-group:last-of-type {
    margin-bottom: 1.25rem;
}

.ps-reset-credentials-overlay .ps-reset-credentials-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.ps-reset-credentials-overlay .ps-reset-credentials-btn {
    border: none;
    border-radius: 10px;
    padding: 0.65rem 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.ps-reset-credentials-overlay .ps-reset-credentials-btn:active {
    transform: translateY(1px);
}

.ps-reset-credentials-overlay .ps-reset-credentials-btn-cancel {
    background: linear-gradient(135deg, var(--action-cancel), var(--action-cancel-dark));
    color: white;
}

.ps-reset-credentials-overlay .ps-reset-credentials-btn-save {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.28);
}

.ps-reset-credentials-overlay .ps-reset-credentials-msg {
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
}

.ps-reset-credentials-overlay .ps-reset-credentials-msg.error {
    color: #dc2626;
}

.ps-reset-credentials-overlay .ps-reset-credentials-msg.success {
    color: #059669;
}

/* Mobile menu toggle button */
.mobile-menu-toggle {
    display: none;
}

/* Mobile close button (inside sidebar) - Hidden on desktop */
.mobile-close-btn {
    display: none !important;
    position: absolute;
    top: 1rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 10;
    padding: 0;
}

.mobile-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.mobile-close-btn:active {
    transform: scale(0.95);
}

.mobile-close-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 2px;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 0;
}

.page-header h1 {
    font-size: 1.75rem;
    color: var(--dark-color);
    font-weight: 600;
}

.page-actions {
    display: flex;
    gap: 1rem;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

.login-box {
    background: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: var(--primary-color);
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-light);
}

.login-footer {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-section h2 {
    margin-bottom: 1.5rem;
    color: var(--dark-color);
    font-size: 1.25rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.3s;
    text-align: center;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #1e40af;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-block {
    width: 100%;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Action buttons (unique colors across the app) */
.btn-view {
    background: linear-gradient(135deg, var(--action-view), var(--action-view-dark));
    color: #fff;
}
.btn-view:hover {
    background: linear-gradient(135deg, var(--action-view-dark), #1d4ed8);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(37, 99, 235, 0.25);
}

.btn-edit {
    background: linear-gradient(135deg, var(--action-edit), var(--action-edit-dark));
    color: #fff;
}
.btn-edit:hover {
    background: linear-gradient(135deg, var(--action-edit-dark), #6d28d9);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(124, 58, 237, 0.22);
}

.btn-print {
    background: linear-gradient(135deg, var(--action-print), var(--action-print-dark));
    color: #fff;
}
.btn-print:hover {
    background: linear-gradient(135deg, var(--action-print-dark), #0d9488);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(20, 184, 166, 0.22);
}

.btn-delete {
    background: linear-gradient(135deg, var(--action-delete), var(--action-delete-dark));
    color: #fff;
}
.btn-delete:hover {
    background: linear-gradient(135deg, var(--action-delete-dark), #dc2626);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(239, 68, 68, 0.22);
}

.btn-reset {
    background: linear-gradient(135deg, var(--action-reset), var(--action-reset-dark));
    color: #fff;
}
.btn-reset:hover {
    background: linear-gradient(135deg, var(--action-reset-dark), #b45309);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(245, 158, 11, 0.22);
}

.btn-cancel {
    background: linear-gradient(135deg, var(--action-cancel), var(--action-cancel-dark));
    color: #fff;
}
.btn-cancel:hover {
    background: linear-gradient(135deg, var(--action-cancel-dark), #334155);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(100, 116, 139, 0.22);
}

.btn-view:focus-visible,
.btn-edit:focus-visible,
.btn-print:focus-visible,
.btn-delete:focus-visible,
.btn-reset:focus-visible,
.btn-cancel:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.55);
    outline-offset: 2px;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-content h3 {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--dark-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* Tables */
.table-container {
    background: white;
    border-radius: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background-color: var(--primary-color);
    color: white;
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Action buttons layout inside table cells */
.table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.table-actions .btn.btn-sm {
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.total-row {
    background-color: #f1f5f9;
    font-weight: bold;
}

.text-center {
    text-align: center;
}

/* Items Table */
.items-table-container {
    overflow-x: auto;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.items-table th,
.items-table td {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.items-table th {
    background-color: #f8fafc;
    font-weight: 600;
}

.items-table input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.items-table select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.btn-remove {
    padding: 0.5rem 1rem;
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
}

.btn-remove:hover {
    background-color: #dc2626;
}

/* Bill Summary */
.bill-summary {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1.5rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row.total-row {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color);
    border-top: 2px solid var(--primary-color);
    padding-top: 1rem;
    margin-top: 0.5rem;
}

/* Bill View */
.bill-view {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.bill-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.bill-info h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.bill-details p {
    margin-bottom: 0.5rem;
}

.bill-customer {
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 4px;
}

.bill-customer h3 {
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

.bill-items-table {
    margin-bottom: 2rem;
}

.bill-summary-view {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 8px;
}

/* Status Badge */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.status-paid {
    background-color: #d1fae5;
    color: #065f46;
}

.status-partial {
    background-color: #fef3c7;
    color: #92400e;
}

.status-pending {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Filter Section */
.filter-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.filter-form {
    margin: 0;
}

/* Quick Actions */
.quick-actions {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.quick-actions h2 {
    margin-bottom: 1.5rem;
    color: var(--dark-color);
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Report Summary */
.report-summary {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.report-summary h2 {
    margin-bottom: 1.5rem;
    color: var(--dark-color);
}

/* Footer */
.main-footer {
    background: var(--dark-color);
    color: white;
    text-align: center;
    padding: 2rem;
    margin-top: 4rem;
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
    }
    
    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    body:not(.login-page) {
        padding-left: 0 !important;
        padding-top: 80px !important;
    }
    
    body.sidebar-expanded {
        padding-left: 0 !important;
    }
    
    .topbar {
        left: 0 !important;
        height: 80px;
    }
    
    .main-header {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 200px !important;
    }
    
    .main-header.open {
        transform: translateX(0);
    }
    
    .main-header.expanded {
        width: 200px !important;
    }
    
    .main-header.open .nav-text {
        opacity: 1;
        max-width: 200px;
    }
    
    .main-header.open .logo-text {
        opacity: 1;
        max-height: 200px;
    }
    
    .main-header.open .nav-link.logout {
        display: flex;
    }
    
    .main-header:not(.open) .nav-link.logout {
        display: none;
    }
    
    .main-header.open .nav-link.reset-credentials {
        display: flex;
    }
    
    .main-header:not(.open) .nav-link.reset-credentials {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex !important;
    }
    
    /* Hide hamburger button when sidebar is open */
    .mobile-menu-toggle.hidden,
    body.mobile-sidebar-open .mobile-menu-toggle {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
    
    .sidebar-toggle {
        display: none;
    }
    
    /* Show mobile close button when sidebar is open on mobile */
    .main-header.open .mobile-close-btn {
        display: flex !important;
    }
    
    /* Hide mobile close button when sidebar is closed */
    .main-header:not(.open) .mobile-close-btn {
        display: none !important;
    }
    
    .topbar-content {
        padding: 0 1rem;
        padding-left: calc(40px + 1.5rem); /* Account for hamburger menu (40px width + 1rem left + 0.5rem gap) */
        padding-right: calc(60px + 1rem); /* Account for user name (approx 60px + 1rem padding) */
        position: relative;
        justify-content: center;
        align-items: center;
    }
    
    .page-title {
        font-size: 1.125rem;
        text-align: center;
        flex: 1;
        margin: 0;
        padding: 0 0.5rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .topbar-user {
        position: absolute;
        right: 1rem;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.875rem;
    }
    
    .container {
        padding: 1rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 1.5rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .stat-card {
        padding: 1rem;
        gap: 0.75rem;
        border-radius: 6px;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .stat-icon {
        font-size: 2rem;
        flex-shrink: 0;
    }
    
    .stat-content {
        text-align: center;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .stat-content h3 {
        font-size: 0.8125rem;
        margin-bottom: 0.375rem;
        text-align: center;
    }
    
    .stat-value {
        font-size: 1.5rem;
        text-align: center;
    }
    
    .stat-label {
        font-size: 0.8125rem;
        text-align: center;
    }
    
    .quick-actions {
        padding: 1.5rem 1rem;
        border-radius: 6px;
        margin-bottom: 1rem;
    }
    
    .quick-actions h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .action-buttons .btn {
        width: 100%;
        padding: 0.875rem 1rem;
        font-size: 0.9375rem;
        text-align: center;
        justify-content: center;
    }
    
    .data-table {
        font-size: 0.875rem;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }
    
    .main-nav {
        padding: 0.75rem 0.5rem;
        gap: 0.5rem;
    }
    
    .nav-link {
        padding: 0.875rem 0.5rem;
        font-size: 0.875rem;
        min-height: 44px;
    }
    
    /* Create Bill Page - Mobile Responsive Styles */
    /* Customer Information Section - Already responsive via form-row */
    .form-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .form-section h2 {
        font-size: 1.125rem;
        margin-bottom: 1rem;
    }
    
    /* Items Table - Transform to Mobile Form Layout */
    .items-table-container {
        overflow-x: visible;
    }
    
    /* Hide table header on mobile */
    .items-table thead {
        display: none;
    }
    
    /* Transform table structure to block layout */
    .items-table {
        display: block;
        width: 100%;
        border: none;
    }
    
    .items-table tbody {
        display: block;
        width: 100%;
    }
    
    .items-table tr.item-row {
        display: block;
        width: 100%;
        background: white;
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    .items-table tr.item-row:last-of-type {
        margin-bottom: 0;
    }
    
    /* Transform table cells to block layout with labels */
    .items-table td {
        display: block;
        width: 100%;
        border: none;
        padding: 0.75rem 0;
        position: relative;
    }
    
    /* Add labels before each field using CSS */
    .items-table td:first-child::before {
        content: "Product *";
        display: block;
        font-weight: 600;
        color: var(--text-color);
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    .items-table td:nth-child(2)::before {
        content: "Quantity *";
        display: block;
        font-weight: 600;
        color: var(--text-color);
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    .items-table td:nth-child(3)::before {
        content: "Unit";
        display: block;
        font-weight: 600;
        color: var(--text-color);
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    .items-table td:nth-child(4)::before {
        content: "Rate *";
        display: block;
        font-weight: 600;
        color: var(--text-color);
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    .items-table td:nth-child(5)::before {
        content: "GST %";
        display: block;
        font-weight: 600;
        color: var(--text-color);
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    .items-table td:nth-child(6)::before {
        content: "Amount";
        display: block;
        font-weight: 600;
        color: var(--text-color);
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    .items-table td:nth-child(7)::before {
        content: "CGST";
        display: block;
        font-weight: 600;
        color: var(--text-color);
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    .items-table td:nth-child(8)::before {
        content: "SGST";
        display: block;
        font-weight: 600;
        color: var(--text-color);
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    .items-table td:nth-child(9)::before {
        content: "IGST";
        display: block;
        font-weight: 600;
        color: var(--text-color);
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    .items-table td:nth-child(10)::before {
        content: "Total";
        display: block;
        font-weight: 600;
        color: var(--text-color);
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Action button - no label, add separator */
    .items-table td:last-child {
        padding-top: 1rem;
        margin-top: 0.75rem;
        border-top: 1px solid var(--border-color);
    }
    
    .items-table td:last-child::before {
        display: none;
    }
    
    /* Make all inputs and selects full width */
    .items-table input[type="text"],
    .items-table input[type="number"],
    .items-table select {
        width: 100%;
        padding: 0.75rem;
        font-size: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 4px;
        margin: 0;
        box-sizing: border-box;
    }
    
    /* Hide hidden inputs visually but keep them functional */
    .items-table input[type="hidden"] {
        display: none;
    }
    
    /* Style read-only display fields (spans) */
    .items-table .amount,
    .items-table .cgst,
    .items-table .sgst,
    .items-table .igst,
    .items-table .total {
        display: block;
        padding: 0.75rem;
        background: #f8fafc;
        border: 1px solid var(--border-color);
        border-radius: 4px;
        width: 100%;
        font-weight: 500;
        color: var(--text-color);
        box-sizing: border-box;
    }
    
    /* Remove button styling */
    .items-table .btn-remove {
        width: 100%;
        padding: 0.75rem;
        font-size: 0.9375rem;
        margin-top: 0;
    }
    
    /* Add Item button */
    .items-table-container > .btn {
        width: 100%;
        padding: 0.875rem;
        font-size: 1rem;
        margin-top: 0.75rem;
    }
    
    /* Bill Summary Section - Mobile */
    .bill-summary {
        padding: 1rem;
    }
    
    .summary-row {
        padding: 0.625rem 0;
        font-size: 0.9375rem;
    }
    
    .summary-row.total-row {
        font-size: 1.125rem;
        padding-top: 0.875rem;
        margin-top: 0.5rem;
    }
    
    /* Payment Fields */
    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .form-actions .btn {
        width: 100%;
        padding: 0.875rem;
        font-size: 1rem;
    }
    
    /* Ensure form groups have proper spacing */
    .form-group {
        margin-bottom: 1.25rem;
    }
    
    .form-group label {
        font-size: 0.9375rem;
        margin-bottom: 0.5rem;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 1rem;
        padding: 0.75rem;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }
    
    /* Ensure bill form container is properly sized */
    .bill-form {
        width: 100%;
    }
    
    /* Make sure textarea is responsive */
    .form-group textarea {
        min-height: 80px;
        resize: vertical;
    }
    
    /* Ensure buttons are tappable (minimum 44x44px touch target) */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Improve spacing for bill summary on mobile */
    .bill-summary .summary-row {
        flex-wrap: wrap;
    }
    
    .bill-summary .summary-row span:first-child {
        margin-bottom: 0.25rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    body {
        padding-left: 80px;
    }
    
    body.sidebar-expanded {
        padding-left: 200px;
    }
    
    .topbar {
        left: 80px;
    }
    
    body.sidebar-expanded .topbar {
        left: 200px;
    }
}
