/* ========================================
   Enterprise Payment Instruction System
   Professional B&W Theme
   ======================================== */

:root {
    /* Colors */
    --black: #0a0a0a;
    --gray-900: #1a1a1a;
    --gray-800: #2d2d2d;
    --gray-700: #404040;
    --gray-600: #525252;
    --gray-500: #737373;
    --gray-400: #a3a3a3;
    --gray-300: #d4d4d4;
    --gray-200: #e5e5e5;
    --gray-100: #f5f5f5;
    --white: #ffffff;
    
    /* Accent Colors */
    --accent-blue: #3b82f6;
    --accent-green: #22c55e;
    --accent-orange: #f97316;
    --accent-red: #ef4444;
    
    /* Semantic */
    --primary: var(--black);
    --secondary: var(--gray-700);
    --success: var(--accent-green);
    --warning: var(--accent-orange);
    --danger: var(--accent-red);
    --info: var(--accent-blue);
    
    /* UI */
    --bg-body: var(--gray-100);
    --bg-card: var(--white);
    --bg-input: var(--white);
    --bg-hover: var(--gray-100);
    --border-color: var(--gray-200);
    --border-dark: var(--gray-300);
    --text-primary: var(--gray-900);
    --text-secondary: var(--gray-600);
    --text-muted: var(--gray-500);
    
    /* Spacing */
    --sidebar-width: 260px;
    --header-height: 64px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

/* ========================================
   Base Styles
   ======================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

table {
    border-collapse: collapse;
    width: 100%;
}

/* ========================================
   Page Structure
   ======================================== */
.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: block;
}

#mainApp {
    display: none;
    min-height: 100vh;
}

#mainApp.active {
    display: block;
}

/* ========================================
   Login Page
   ======================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
}

.login-box {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: 3rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
}

.login-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--black);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.login-logo svg {
    width: 36px;
    height: 36px;
    color: var(--white);
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.login-form .form-group {
    margin-bottom: 1.5rem;
}

.login-form label {
    display: block;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.input-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon svg {
    position: absolute;
    left: 0.75rem;
    width: 18px;
    height: 18px;
    color: var(--gray-400);
    flex-shrink: 0;
    pointer-events: none;
}

.input-icon input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-input);
    height: 2.75rem;
    display: block;
}

.login-form input:not(.input-icon input) {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-input);
}

.login-form input:focus {
    outline: none;
    border-color: var(--black);
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.08);
}

.login-form input::placeholder {
    color: var(--gray-400);
}

.btn-block {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-lg {
    padding: 1rem 1.5rem;
    font-size: 1rem;
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-top: 1rem;
    display: none;
}

.error-message.show {
    display: block;
}

.login-footer {
    margin-top: 2rem;
    text-align: center;
}

.lang-switch {
    display: inline-flex;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.lang-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.lang-btn:hover {
    background: var(--bg-hover);
}

.lang-btn.active {
    background: var(--black);
    color: var(--white);
}

.login-info {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
}

.info-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    color: var(--white);
}

.info-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

.demo-accounts {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.demo-account {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    font-size: 0.813rem;
}

.demo-account .role {
    opacity: 0.7;
}

.demo-account .creds {
    font-family: monospace;
}

/* ========================================
   Header
   ======================================== */
.top-header {
    height: var(--header-height);
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    color: var(--text-secondary);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
}

.brand svg {
    width: 32px;
    height: 32px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.813rem;
    transition: var(--transition);
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header-btn svg {
    width: 18px;
    height: 18px;
}

.user-dropdown {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem;
    padding-right: 0.75rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 100px;
    transition: var(--transition);
}

.user-btn:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--black);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-weight: 600;
    font-size: 0.875rem;
}

.user-info-mini {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.3;
}

.user-info-mini span:first-child {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.user-info-mini span:last-child {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.user-btn svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    display: none;
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.dropdown-menu a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.dropdown-menu svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    overflow-y: auto;
    z-index: 90;
    transition: transform var(--transition-slow);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--black);
    color: var(--white);
}

.nav-item.highlight {
    background: var(--gray-100);
    border: 1px dashed var(--gray-300);
}

.nav-item.highlight:hover,
.nav-item.highlight.active {
    background: var(--black);
    color: var(--white);
    border-color: transparent;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-divider {
    height: 1px;
    background: var(--border-color);
    margin: 1rem 0;
}

/* ========================================
   Main Content
   ======================================== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 2rem;
    min-height: calc(100vh - var(--header-height));
}

.content-page {
    display: none;
}

.content-page.active {
    display: block;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 0.938rem;
}

.page-header-back {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-header-actions {
    display: flex;
    gap: 0.75rem;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.875rem;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--black);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--gray-800);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-dark);
}

.btn-outline:hover {
    background: var(--bg-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: #16a34a;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.813rem;
}

.btn-sm svg {
    width: 16px;
    height: 16px;
}

.btn-icon {
    padding: 0.5rem;
}

/* ========================================
   Cards
   ======================================== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-link {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
}

.card-link:hover {
    color: var(--text-primary);
}

.card-body {
    padding: 1.5rem;
}

.card-body.no-padding {
    padding: 0;
}

/* ========================================
   Stats Grid
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-card.featured {
    background: var(--black);
    color: var(--white);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.blue {
    background: #eff6ff;
    color: var(--accent-blue);
}

.stat-icon.orange {
    background: #fff7ed;
    color: var(--accent-orange);
}

.stat-icon.green {
    background: #f0fdf4;
    color: var(--accent-green);
}

.stat-card.featured .stat-icon {
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.stat-card.featured .stat-label {
    color: rgba(255, 255, 255, 0.7);
}

/* ========================================
   Dashboard Grid
   ======================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
}

.recent-list {
    max-height: 400px;
    overflow-y: auto;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
}

.recent-item:last-child {
    border-bottom: none;
}

.recent-item:hover {
    background: var(--bg-hover);
}

.recent-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.recent-ref {
    font-weight: 600;
    color: var(--text-primary);
}

.recent-company {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.recent-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.recent-amount {
    font-weight: 600;
    text-align: right;
}

.status-chart {
    padding: 1rem;
}

.chart-bar {
    margin-bottom: 1.25rem;
}

.chart-bar:last-child {
    margin-bottom: 0;
}

.chart-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.chart-label span:first-child {
    color: var(--text-secondary);
}

.chart-label span:last-child {
    font-weight: 600;
}

.chart-track {
    height: 8px;
    background: var(--gray-100);
    border-radius: 100px;
    overflow: hidden;
}

.chart-fill {
    height: 100%;
    border-radius: 100px;
    transition: width var(--transition-slow);
}

.chart-fill.blue { background: var(--accent-blue); }
.chart-fill.orange { background: var(--accent-orange); }
.chart-fill.green { background: var(--accent-green); }
.chart-fill.red { background: var(--accent-red); }

/* ========================================
   Data Table
   ======================================== */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem 1.5rem;
    text-align: left;
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.813rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    border-bottom: 1px solid var(--border-color);
    font-size: 0.938rem;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* ========================================
   Status Badge
   ======================================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-badge.draft {
    background: var(--gray-100);
    color: var(--gray-600);
}

.status-badge.draft::before {
    background: var(--gray-400);
}

.status-badge.pending_review,
.status-badge.pending_approval {
    background: #fef3c7;
    color: #b45309;
}

.status-badge.pending_review::before,
.status-badge.pending_approval::before {
    background: var(--accent-orange);
}

.status-badge.approved {
    background: #dcfce7;
    color: #15803d;
}

.status-badge.approved::before {
    background: var(--accent-green);
}

.status-badge.rejected {
    background: #fee2e2;
    color: #b91c1c;
}

.status-badge.rejected::before {
    background: var(--accent-red);
}

/* ========================================
   Forms
   ======================================== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-group .required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.938rem;
    transition: var(--transition);
    background: var(--bg-input);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--black);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--gray-400);
}

.form-group input[readonly] {
    background: var(--gray-100);
    color: var(--text-muted);
}

.form-group small {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.813rem;
    color: var(--text-muted);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Number Input Groups - Mobile Friendly */
.num-input-group {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-input);
}

.num-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    padding: 0;
    border: none;
    background: var(--gray-100);
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.num-btn:active {
    background: var(--gray-200);
}

.num-btn:hover {
    background: var(--gray-200);
}

.num-input-group .num-input {
    flex: 1;
    border: none;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    text-align: center;
    background: transparent;
    outline: none;
}

.num-input-group .num-input:focus {
    box-shadow: none;
}

/* ========================================
   Payment Form Wizard
   ======================================== */
.payment-form {
    max-width: 900px;
}

.progress-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2.5rem;
    padding: 0 2rem;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: var(--transition);
}

.progress-step span {
    font-size: 0.813rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition);
}

.progress-step.active .step-circle,
.progress-step.completed .step-circle {
    background: var(--black);
    color: var(--white);
}

.progress-step.active span {
    color: var(--text-primary);
}

.progress-line {
    flex: 1;
    height: 2px;
    background: var(--gray-200);
    margin: 0 1rem;
    margin-bottom: 1.5rem;
}

.form-step {
    display: none;
}

.form-step.active {
    display: block;
}

.form-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.form-actions-right {
    display: flex;
    gap: 0.75rem;
}

/* ========================================
   Items Table
   ======================================== */
.items-table-wrapper {
    overflow-x: auto;
    margin-bottom: 1rem;
}

.items-table {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.items-table th,
.items-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.items-table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 0.813rem;
    color: var(--text-muted);
}

.items-table tbody tr:last-child td {
    border-bottom: none;
}

.items-table input,
.items-table select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.items-table input:focus,
.items-table select:focus {
    outline: none;
    border-color: var(--black);
}

.items-table .num-input {
    text-align: right;
    width: 100px;
}

.items-table .btn-remove {
    padding: 0.375rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.items-table .btn-remove:hover {
    color: var(--danger);
    background: #fee2e2;
}

.items-table .btn-remove svg {
    width: 18px;
    height: 18px;
}

.totals-row td {
    background: var(--gray-50);
    font-weight: 600;
}

.btn-add-item {
    margin-top: 1rem;
}

/* ========================================
   Work Items
   ======================================== */
.work-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.work-item {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.work-item input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.work-item input:focus {
    outline: none;
    border-color: var(--black);
}

.work-item .btn-remove {
    padding: 0.5rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.work-item .btn-remove:hover {
    color: var(--danger);
    background: #fee2e2;
}

/* ========================================
   Summary
   ======================================== */
.summary-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
}

.summary-details {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.summary-section {
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.summary-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.summary-section h4 {
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.summary-section p {
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.summary-section p strong {
    color: var(--text-secondary);
    font-weight: 500;
}

.summary-totals-card {
    background: var(--gray-900);
    color: var(--white);
}

.summary-totals-card .card-header {
    border-color: rgba(255, 255, 255, 0.1);
}

.summary-totals-card .card-header h3 {
    color: var(--white);
}

.summary-totals {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row span:first-child {
    color: rgba(255, 255, 255, 0.7);
}

.summary-row span:last-child {
    font-weight: 600;
    font-size: 1.125rem;
}

.summary-row.total {
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 2px solid rgba(255, 255, 255, 0.2);
}

.summary-row.total span:first-child {
    color: var(--white);
    font-weight: 600;
}

.summary-row.total span:last-child {
    font-size: 1.5rem;
}

/* ========================================
   View Payment
   ======================================== */
.view-content {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
}

.view-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.view-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.view-card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.view-card-body {
    padding: 1.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-item.full {
    grid-column: 1 / -1;
}

.info-label {
    font-size: 0.813rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.info-value {
    font-size: 0.938rem;
    color: var(--text-primary);
}

.timeline {
    display: flex;
    flex-direction: column;
}

.timeline-item {
    display: flex;
    gap: 1rem;
    padding-bottom: 1.5rem;
    position: relative;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: 11px;
    top: 24px;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.timeline-dot svg {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
}

.timeline-dot.success {
    background: #dcfce7;
}

.timeline-dot.success svg {
    color: var(--success);
}

.timeline-dot.danger {
    background: #fee2e2;
}

.timeline-dot.danger svg {
    color: var(--danger);
}

.timeline-content {
    flex: 1;
}

.timeline-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.timeline-text {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ========================================
   Filters
   ======================================== */
.filters-bar {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.search-box {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.search-box svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--gray-400);
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.938rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--black);
}

.filter-select {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--white);
    font-size: 0.938rem;
    color: var(--text-primary);
    min-width: 180px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--black);
}

/* ========================================
   Empty State
   ======================================== */
.empty-state {
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--gray-300);
    margin-bottom: 1.5rem;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* ========================================
   Modal
   ======================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    align-items: flex-end;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal.show {
    display: flex;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: -1;
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: 1rem 1rem 0 0;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 560px;
    max-height: 95vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-sm {
    max-width: 420px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.modal-close {
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-close:active {
    background: var(--gray-100);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.confirm-text {
    font-size: 0.938rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* ========================================
   Toast
   ======================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    background: var(--gray-900);
    color: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition);
    z-index: 1100;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-icon {
    width: 20px;
    height: 20px;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid,
    .summary-grid,
    .view-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 992px) {
    .menu-toggle {
        display: flex;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .progress-steps {
        padding: 0;
    }
    
    .progress-step span {
        display: none;
    }
}

@media (max-width: 768px) {
    .login-container {
        padding: 1rem;
    }
    
    .login-box {
        padding: 2rem;
    }
    
    .login-info {
        display: none;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        max-width: none;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.75rem 1rem;
    }
    
    .user-info-mini {
        display: none;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 1rem;
    }
    
    .form-actions-right {
        width: 100%;
        flex-direction: column;
    }
    
    .form-actions-right .btn {
        width: 100%;
    }
    
    #btnPrevStep {
        width: 100%;
    }
}

/* ========================================
   Utilities
   ======================================== */
.hidden {
    display: none !important;
}

.text-muted {
    color: var(--text-muted);
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* Mobile optimizations for modals */
@media (max-width: 640px) {
    .modal {
        padding: 0;
        align-items: flex-start;
    }
    
    .modal-content {
        border-radius: 1rem 1rem 0 0;
        max-width: 100%;
        max-height: 100vh;
        margin-top: auto;
    }
    
    .modal-header {
        padding: 1rem 1.25rem;
    }
    
    .modal-header h2 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 1.25rem;
        max-height: calc(100vh - 140px);
    }
    
    .modal-footer {
        padding: 1rem 1.25rem;
        gap: 0.5rem;
    }
    
    .modal-footer .btn {
        flex: 1;
        min-height: 44px;
        font-size: 0.95rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .form-group {
        width: 100%;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px !important;
        padding: 0.875rem;
        min-height: 44px;
    }
    
    .form-group label {
        font-size: 0.95rem;
        font-weight: 500;
        margin-bottom: 0.5rem;
    }
    
    /* Ensure proper tap targets */
    button, input[type="button"], input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better spacing on mobile */
    .modal-content {
        animation: slideUp 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    }
}

@media (max-width: 480px) {
    .modal {
        padding: 0;
    }
    
    .modal-header h2 {
        font-size: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .modal-footer {
        padding: 1rem;
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        padding: 0.875rem;
    }
    
    /* Stack form elements on very small screens */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .checkbox-label {
        font-size: 0.9rem;
    }
}

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }

/* ========================================
   RTL (Right-to-Left) Support for Arabic
   ======================================== */

body[dir="rtl"] {
    text-align: right;
}

body[dir="rtl"] .sidebar {
    right: 0;
    left: auto;
    border-right: none;
    border-left: 1px solid var(--border-color);
}

body[dir="rtl"] .main-content {
    margin-right: var(--sidebar-width);
    margin-left: 0;
}

body[dir="rtl"] .navbar {
    margin-right: var(--sidebar-width);
    margin-left: 0;
}

body[dir="rtl"] .nav-links {
    padding-right: 0;
    padding-left: 1rem;
}

body[dir="rtl"] .nav-link {
    text-align: right;
}

body[dir="rtl"] .nav-link svg {
    margin-right: 0;
    margin-left: 0.75rem;
}

body[dir="rtl"] .btn svg {
    margin-right: 0;
    margin-left: 0.5rem;
}

body[dir="rtl"] .user-info {
    margin-right: 0;
    margin-left: auto;
}

body[dir="rtl"] .language-switcher {
    margin-left: 0;
    margin-right: 1rem;
}

body[dir="rtl"] .stats-grid {
    direction: rtl;
}

body[dir="rtl"] .invoice-actions,
body[dir="rtl"] .payment-actions {
    text-align: left;
}

body[dir="rtl"] input,
body[dir="rtl"] select,
body[dir="rtl"] textarea {
    text-align: right;
}

body[dir="rtl"] .form-row {
    direction: rtl;
}

body[dir="rtl"] .checkbox-label {
    padding-right: 2rem;
    padding-left: 0;
}

body[dir="rtl"] .checkbox-label input[type="checkbox"] {
    right: 0;
    left: auto;
}

@media (max-width: 768px) {
    body[dir="rtl"] .main-content {
        margin-right: 0;
    }
    
    body[dir="rtl"] .navbar {
        margin-right: 0;
    }
    
    body[dir="rtl"] .sidebar {
        right: -var(--sidebar-width);
        left: auto;
    }
    
    body[dir="rtl"] .sidebar.active {
        right: 0;
    }
}
