/* ============================================================================
   Smart Invoice Reader - Global Styles
   Design tokens: bg #f8f9fa | card white/#e5e7eb | blue #2563eb | red #dc2626
                  text #111827 | muted #6b7280 | border #e5e7eb
   ============================================================================ */

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

html {
    max-width: 100%;
    overflow-x: clip;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #f8f9fa;
    color: #111827;
    line-height: 1.6;
    max-width: 100%;
    overflow-x: hidden;
    font-size: 15px;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ============================================================================
   Navigation
   ============================================================================ */

.navbar {
    background-color: #fff;
    border-bottom: 1px solid #f0f0f0;
    padding: 0;
}

.navbar .container {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 60px;
}

.navbar-brand {
    flex: 1;
    font-size: 16px;
    font-weight: 700;
}

.logo {
    color: #111827;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo:hover {
    color: #111827;
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.logo-mark {
    width: 20px;
    height: 24px;
    border: 2px solid #2563eb;
    border-radius: 4px;
    display: inline-block;
    position: relative;
    flex: 0 0 auto;
}

.logo-mark::after {
    content: "";
    position: absolute;
    left: 4px;
    right: 4px;
    top: 7px;
    height: 2px;
    background: #2563eb;
    box-shadow: 0 5px 0 #2563eb;
}

.navbar-links {
    display: flex;
    list-style: none;
    gap: 28px;
    align-items: center;
}

.navbar-links a {
    color: #9ca3af;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: color 0.2s;
}

.navbar-links a:hover {
    color: #111827;
}

.navbar-links a.nav-active {
    color: #111827;
    font-weight: 600;
}

.navbar-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
}

.user-email {
    display: flex;
    align-items: center;
    gap: 7px;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
}

.plan-badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1.4;
    white-space: nowrap;
}

.plan-badge--free     { background: #f3f4f6; color: #6b7280; }
.plan-badge--starter  { background: #eff6ff; color: #2563eb; }
.plan-badge--business { background: #f0fdf4; color: #16a34a; }

.btn-logout {
    color: #374151;
    border: 1px solid #d1d5db;
    background: transparent;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.15s, border-color 0.15s;
}

.btn-logout:hover {
    background-color: #f9fafb;
    border-color: #9ca3af;
    color: #374151;
}

/* ============================================================================
   Main Content
   ============================================================================ */

.main-content {
    min-height: calc(100vh - 140px);
    padding: 36px 0;
    padding-top: calc(60px + 36px);
}

/* Hamburger button — hidden on desktop */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #111827;
    border-radius: 2px;
    transition: all 0.2s;
}

/* Mobile dropdown menu — hidden by default */
.mobile-menu {
    display: none;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

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

.mobile-menu ul {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}

.mobile-menu ul li a {
    display: block;
    padding: 13px 20px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 1px solid #f9fafb;
}

.mobile-menu ul li:last-child a {
    border-bottom: none;
}

.mobile-menu ul li a:hover {
    background: #f9fafb;
    color: #111827;
}

.mobile-menu ul li a.nav-active {
    color: #2563eb;
    font-weight: 600;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s;
    text-align: center;
    white-space: nowrap;
    min-height: 40px;
    line-height: 1.4;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #2563eb;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #f9fafb;
    border-color: #9ca3af;
}

.btn-danger {
    background-color: #dc2626;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background-color: #b91c1c;
}

.btn-small {
    padding: 5px 11px;
    font-size: 12px;
    min-height: 30px;
}

.btn-full {
    width: 100%;
    display: block;
}

/* ============================================================================
   Forms
   ============================================================================ */

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: #111827;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-height: 40px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input[readonly] {
    background: #f9fafb;
    color: #6b7280;
    cursor: default;
}

.upload-options {
    max-width: 520px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ============================================================================
   Admin Panel
   ============================================================================ */

.admin-stats {
    grid-template-columns: repeat(4, 1fr);
}

.admin-pricing-note {
    font-size: 12px;
    color: #9ca3af;
    text-align: right;
    margin: -8px 0 20px;
}

.admin-panel-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 16px;
}

/* Admin table column overrides */
.admin-table td { padding: 12px 14px; }

.admin-biz-name {
    display: block;
    font-weight: 600;
    color: #111827;
}

.admin-biz-phone {
    display: block;
    font-size: 12px;
    color: #9ca3af;
    margin-top: 2px;
}

.admin-usage-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 140px;
}

.admin-bar-track {
    flex: 1;
    margin-bottom: 0;
    min-width: 60px;
}

.admin-usage-label {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
}

.admin-joined-cell {
    white-space: nowrap;
    color: #6b7280;
    font-size: 13px;
}

.admin-plan-action {
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-plan-select {
    height: 32px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0 8px;
    font-size: 13px;
    font-family: inherit;
    color: #374151;
    background: white;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.admin-plan-select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.btn-plan-save {
    height: 32px;
    padding: 0 14px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s;
}

.btn-plan-save:hover:not(:disabled) { background: #1d4ed8; }
.btn-plan-save:disabled { opacity: 0.6; cursor: not-allowed; }

.plan-save-msg {
    display: block;
    font-size: 12px;
    margin-top: 4px;
    min-height: 16px;
    transition: opacity 0.3s;
}

.plan-save-msg--ok  { color: #16a34a; }
.plan-save-msg--err { color: #dc2626; }

/* ============================================================================
   Authentication / Login Page
   ============================================================================ */

.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #f8f9fa;
    padding: 40px 20px;
    /* login page has no navbar; cancel main-content's fixed navbar padding-top */
    margin-top: calc(-60px - 36px);
}

.login-box {
    background: white;
    padding: 32px 40px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.10);
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.login-logo .logo-mark {
    width: 40px;
    height: 40px;
}

.login-box h1 {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    text-align: center;
    margin-bottom: 6px;
}

.login-box .subtitle {
    color: #6b7280;
    font-size: 14px;
    text-align: center;
    margin-bottom: 0;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form .form-group label {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.login-form .form-group input {
    height: 44px;
    border-radius: 8px;
    padding: 0 14px;
    font-size: 15px;
    min-height: unset;
}

.login-form .btn-primary {
    height: 44px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    min-height: unset;
    padding: 0;
    line-height: 44px;
}

.login-form .btn-primary:hover:not(:disabled) {
    background-color: #1d4ed8;
}

.login-error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 10px 14px;
    color: #dc2626;
    font-size: 13px;
    margin-top: 12px;
}

.login-success {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    padding: 10px 14px;
    color: #16a34a;
    font-size: 13px;
    margin-bottom: 16px;
}

/* Label row with "Forgot password?" link on the right */
.form-label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.form-label-row label {
    margin-bottom: 0;
}

.forgot-password-link {
    font-size: 12px;
    color: #9ca3af;
    text-decoration: none;
    line-height: 1;
}

.forgot-password-link:hover {
    color: #6b7280;
    text-decoration: underline;
}

.login-help {
    margin-top: 24px;
    text-align: center;
}

.auth-link {
    color: #2563eb;
    font-weight: 500;
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
}

.field-optional {
    color: #9ca3af;
    font-size: 12px;
    font-weight: 400;
}

.field-error {
    display: none;
    color: #dc2626;
    font-size: 12px;
    margin-top: 5px;
}

.login-form .input-error {
    border-color: #dc2626 !important;
}

.login-form .input-error:focus {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
}

/* ============================================================================
   Page Headers
   ============================================================================ */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.page-header .text-muted {
    margin-bottom: 0;
}

/* Unpaid invoices grouped view */
.unpaid-page-header {
    margin-bottom: 24px;
}

.unpaid-page-back {
    display: inline-block;
    font-size: 13px;
    color: #6b7280;
    text-decoration: none;
    margin-bottom: 10px;
}

.unpaid-page-back:hover {
    color: #111827;
}

.unpaid-page-title {
    font-size: 22px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 4px;
}

.unpaid-page-subtitle {
    font-size: 13px;
    color: #9ca3af;
    margin: 0;
}

.month-group {
    margin-bottom: 28px;
}

.month-group-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0;
}

.month-group-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #6b7280;
}

.month-group-subtotal {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

/* ============================================================================
   Dashboard
   ============================================================================ */

.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.dash-title {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.2px;
    margin: 0 0 2px;
}

.dash-subtitle {
    font-size: 13px;
    color: #9ca3af;
    margin: 0;
}

/* Month/year filter bar */
.dash-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 20px;
    flex-wrap: wrap;
}

.dash-filter-select {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    color: #374151;
    background: #fff;
    cursor: pointer;
    height: 38px;
}

.dash-filter-select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.dash-filter-btn {
    height: 38px;
    padding: 0 16px;
    white-space: nowrap;
}

/* Unpaid invoice alert banner */
.unpaid-banner {
    background: #fffbeb;
    border-bottom: 1px solid #fcd34d;
    font-size: 13px;
    padding: 8px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #374151;
    margin-top: -36px;
    margin-bottom: 24px;
}

.unpaid-banner-link {
    color: #2563eb;
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
    margin-left: 16px;
    flex-shrink: 0;
}

.unpaid-banner-link:hover {
    text-decoration: underline;
}

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left-width: 3px;
    border-radius: 8px;
    padding: 24px;
}

.stat-card--navy  { border-left-color: #2563eb; }
.stat-card--slate { border-left-color: #475569; }
.stat-card--mid   { border-left-color: #94a3b8; }
.stat-card--green { border-left-color: #16a34a; }
.stat-card--red   { border-left-color: #dc2626; }

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #6b7280;
    margin: 0 0 10px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.3px;
    line-height: 1;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-compare {
    font-size: 12px;
    font-weight: 500;
    margin: 6px 0 0;
}

.stat-compare--up   { color: #16a34a; }
.stat-compare--down { color: #dc2626; }
.stat-compare--neutral { color: #9ca3af; }

/* Top Suppliers */
.dash-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 20px;
}

.dash-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f3f4f6;
}

.dash-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.supplier-row {
    padding: 11px 0;
    border-bottom: 1px solid #f3f4f6;
}

.supplier-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.supplier-row-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 7px;
}

.supplier-row-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

.supplier-row-name {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.supplier-row-count {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
    flex-shrink: 0;
}

.supplier-row-amount {
    font-size: 13px;
    font-weight: 600;
    color: #2563eb;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    flex-shrink: 0;
    margin-left: 12px;
}

.supplier-bar-track {
    height: 4px;
    background: #f1f5f9;
    border-radius: 2px;
    overflow: hidden;
}

.supplier-bar-fill {
    height: 100%;
    background: #2563eb;
    border-radius: 2px;
    min-width: 2px;
    transition: width 0.5s ease;
}

/* Quick links */
.dash-links {
    display: flex;
    gap: 24px;
    margin-top: 4px;
}

.dash-link {
    font-size: 13px;
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

.dash-link:hover {
    text-decoration: underline;
}

/* ============================================================================
   Upload Page
   ============================================================================ */

/* Usage indicator */
.usage-indicator {
    padding: 14px 16px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 20px;
    max-width: 520px;
}

.usage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.usage-count {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.usage-plan-badge {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 2px 8px;
    border-radius: 10px;
}

.usage-plan-badge--free     { background: #f3f4f6; color: #6b7280; }
.usage-plan-badge--starter  { background: #eff6ff; color: #2563eb; }
.usage-plan-badge--business { background: #f0fdf4; color: #16a34a; }

.usage-bar-track {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.usage-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
    min-width: 2px;
}

.usage-bar-fill--normal  { background: #2563eb; }
.usage-bar-fill--warning { background: #f59e0b; }
.usage-bar-fill--danger  { background: #dc2626; }

.usage-warning {
    font-size: 12px;
    color: #92400e;
    margin: 0;
}

/* Blocked / limit-reached state */
.usage-blocked {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 24px 20px;
    text-align: center;
    margin-top: 8px;
}

.usage-blocked-title {
    font-size: 15px;
    font-weight: 700;
    color: #dc2626;
    margin: 0 0 8px;
}

.usage-blocked-message {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.6;
    margin: 0 0 20px;
}

.usage-blocked-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #25d366;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s;
}

.btn-whatsapp:hover {
    background: #1ebe5e;
    color: white;
}

.upload-section {
    margin-bottom: 24px;
}

.upload-box {
    border: 2px dashed #2563eb;
    border-radius: 8px;
    padding: 56px 24px;
    text-align: center;
    background-color: #f0f7ff;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.upload-box:hover,
.upload-box.drag-over {
    border-color: #1d4ed8;
    background-color: #dbeafe;
}

.upload-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 112px;
    height: 32px;
    padding: 0 14px;
    border-radius: 999px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 14px;
}

.upload-box h3 {
    font-size: 17px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 6px;
}

.text-small {
    font-size: 12px;
    color: #9ca3af;
}

.loading-state {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 3px solid #e5e7eb;
    border-top: 3px solid #2563eb;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Upload progress steps — one step visible at a time */
.upload-steps {
    list-style: none;
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    margin-top: 22px;
    text-align: left;
    min-height: 28px;
}

.step {
    display: none;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    font-weight: 500;
    color: #374151;
}

.step.active {
    display: flex;
    animation: step-in 0.3s ease forwards;
}

.step-dot {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #2563eb;
    animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes step-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.35); }
    50%       { box-shadow: 0 0 0 6px rgba(37, 99, 235, 0); }
}

/* ============================================================================
   Page Panel (card wrapper for upload / invoices list)
   ============================================================================ */

.page-panel {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

/* ============================================================================
   Review / Form Pages
   ============================================================================ */

.review-form {
    background: white;
    padding: 28px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.review-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 24px;
    align-items: start;
}

.review-form-column,
.review-preview-column {
    min-width: 0;
}

.file-preview-panel {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    position: sticky;
    top: 80px;
}

.review-file-image,
.review-file-frame {
    width: 100%;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
}

.review-file-image {
    display: block;
    max-height: 820px;
    object-fit: contain;
}

.review-file-frame {
    min-height: 760px;
}

.file-preview-fallback {
    border: 1px dashed #d1d5db;
    border-radius: 6px;
    padding: 24px;
    text-align: center;
}

.form-section {
    margin-bottom: 28px;
}

.form-section h2 {
    font-size: 15px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e5e7eb;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h2 {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

/* ============================================================================
   Tables
   ============================================================================ */

.items-table-responsive,
.invoices-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.invoices-table-wrap {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 4px;
}

.items-table,
.invoices-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.items-table thead,
.invoices-table thead {
    background-color: #f9fafb;
}

.items-table th,
.invoices-table th {
    padding: 11px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
}

.items-table td,
.invoices-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
    color: #111827;
    vertical-align: middle;
}

/* Invoices-list specific overrides */
.invoices-table td          { padding: 16px 14px; }
.invoices-table .col-inv    { min-width: 140px; }
.invoices-table .col-date   { white-space: nowrap; }
.invoices-table .table-actions { flex-wrap: nowrap; }

.items-table tbody tr:last-child td,
.invoices-table tbody tr:last-child td {
    border-bottom: none;
}

.item-row:hover,
.invoices-table tbody tr:hover {
    background-color: #fafafa;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.table-actions form {
    margin: 0;
}

.items-table input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}

.items-table input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.invoice-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
}

.invoice-link:hover {
    text-decoration: underline;
}

/* ============================================================================
   Alerts
   ============================================================================ */

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 3px solid;
    font-size: 14px;
}

.alert-error {
    background-color: #fef2f2;
    color: #991b1b;
    border-left-color: #dc2626;
}

.alert-warning {
    background-color: #fffbeb;
    color: #92400e;
    border-left-color: #f59e0b;
}

.alert-info {
    background-color: #eff6ff;
    color: #1e40af;
    border-left-color: #2563eb;
}

.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border-left-color: #16a34a;
}

.inline-error {
    background-color: #fef2f2;
    border-left: 3px solid #dc2626;
    border-radius: 6px;
    color: #991b1b;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    margin-top: 20px;
    margin-bottom: 12px;
    padding: 12px 16px;
}

.inline-warning,
.field-warning {
    background-color: #fffbeb;
    border-left: 3px solid #f59e0b;
    border-radius: 6px;
    color: #92400e;
    font-size: 13px;
    line-height: 1.5;
    padding: 10px 14px;
}

.field-warning {
    margin-top: 8px;
}

.inline-warning {
    margin: 10px 0 14px;
}

.item-warning-row td {
    padding-top: 0;
    background-color: #fffbeb;
}

.item-warning-text {
    display: block;
    color: #92400e;
    font-size: 13px;
    line-height: 1.4;
    padding: 4px 0;
}

/* ============================================================================
   Invoice Detail
   ============================================================================ */

.invoice-detail {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.detail-section {
    padding: 24px 28px;
    border-bottom: 1px solid #e5e7eb;
}

.detail-section:last-child {
    border-bottom: none;
}

.detail-section h2 {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #6b7280;
    margin-bottom: 16px;
}

.invoice-file-preview {
    display: block;
    max-width: 100%;
    max-height: 720px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    object-fit: contain;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.detail-item {
    padding: 14px 16px;
    background-color: #f9fafb;
    border: 1px solid #f3f4f6;
    border-radius: 6px;
}

.detail-item.highlight {
    background-color: #eff6ff;
    border-color: #bfdbfe;
    border-left: 3px solid #2563eb;
}

.detail-label {
    display: block;
    color: #6b7280;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    font-weight: 600;
}

.detail-value {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    overflow-wrap: anywhere;
}

/* ============================================================================
   Badges
   ============================================================================ */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.badge-success {
    background-color: #f0fdf4;
    color: #166534;
}

.badge-paid {
    background-color: #dcfce7;
    color: #166534;
}

.badge-unpaid {
    background-color: #f3f4f6;
    color: #6b7280;
}

/* Payment toggle button */
.btn-payment {
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}

.btn-payment:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-payment:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Inline payment status message */
.payment-msg {
    display: block;
    font-size: 12px;
    margin-top: 4px;
    min-height: 16px;
}

.payment-msg--ok  { color: #166534; }
.payment-msg--err { color: #991b1b; }

/* ============================================================================
   Pagination
   ============================================================================ */

.pagination {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 24px 0;
}

/* ============================================================================
   Empty State
   ============================================================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 24px;
    color: #6b7280;
}

/* ============================================================================
   Form Actions
   ============================================================================ */

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.form-actions .btn {
    flex: 1;
}

/* ============================================================================
   Utility
   ============================================================================ */

.text-muted {
    color: #6b7280;
    font-size: 14px;
}

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    flex-wrap: wrap;
}

.action-buttons .btn {
    flex: 1;
    min-width: 180px;
}

/* ============================================================================
   Footer
   ============================================================================ */

.footer {
    background-color: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 24px 0;
    margin-top: 48px;
    text-align: center;
    color: #9ca3af;
    font-size: 13px;
}

/* ============================================================================
   Focus / Accessibility
   ============================================================================ */

:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================================================
   Review layout — collapse at 960px
   ============================================================================ */

@media (max-width: 960px) {
    .review-layout {
        grid-template-columns: 1fr;
    }

    .review-preview-column {
        order: -1;
    }

    .file-preview-panel {
        position: static;
    }

    .review-file-frame {
        min-height: 520px;
    }
}

/* ============================================================================
   Mobile Upload Buttons (hidden on desktop, shown on mobile via media query)
   ============================================================================ */

.mobile-upload-btns {
    display: none;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 8px;
}

.mob-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 52px;
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    border-radius: 8px;
    cursor: pointer;
    box-sizing: border-box;
    transition: opacity 0.15s;
}

.mob-upload-camera {
    background: #2563eb;
    color: white;
    border: none;
}

.mob-upload-camera:hover {
    opacity: 0.9;
}

.mob-upload-gallery {
    background: white;
    color: #111827;
    border: 1px solid #d1d5db;
}

.mob-upload-gallery:hover {
    background: #f9fafb;
}

/* ============================================================================
   Mobile Invoice Cards
   ============================================================================ */

.mobile-cards {
    display: none;
    padding: 12px;
    box-sizing: border-box;
    width: 100%;
}

.m-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 10px;
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;
}

.m-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.m-inv-num {
    color: #2563eb;
    font-weight: 600;
    text-decoration: none;
}

.m-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.m-badge.paid {
    background: #dcfce7;
    color: #16a34a;
}

.m-badge.unpaid {
    background: #f3f4f6;
    color: #6b7280;
}

.m-supplier {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 14px;
}

.m-meta {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 12px;
}

.m-meta strong {
    color: #111827;
}

.m-actions {
    display: flex;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}

.m-actions form {
    flex: 1;
    min-width: 0;
    display: flex;
}

.m-btn {
    flex: 1;
    min-width: 0;
    padding: 8px 4px;
    font-size: 12px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
    display: inline-block;
}

.m-actions form .m-btn {
    width: 100%;
}

.m-btn-view {
    background: #2563eb;
    color: white;
}

.m-btn-pay {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db !important;
}

.m-btn-del {
    background: #dc2626;
    color: white;
}

/* ============================================================================
   Responsive — 768px
   ============================================================================ */

@media (max-width: 768px) {
    .navbar .container {
        height: 60px;
        flex-direction: row;
        align-items: center;
        padding: 0 16px;
    }

    .navbar-brand {
        flex: 1;
    }

    .logo {
        justify-content: flex-start;
        text-align: left;
    }

    .navbar-links {
        display: none;
    }

    .navbar-right {
        flex: none;
        justify-content: flex-end;
        gap: 8px;
    }

    .user-email {
        display: none;
    }

    .btn-logout {
        display: none;
    }

    .hamburger {
        display: flex;
    }

    .container { padding: 0 16px; }

    .main-content {
        min-height: calc(100vh - 180px);
        padding: 20px 0;
        padding-top: 80px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        margin-bottom: 20px;
    }

    .page-header h1 { font-size: 20px; }

    .page-header .btn { width: 100%; }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
        margin-bottom: 16px;
    }

    .admin-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-card { padding: 16px 18px; }

    .stat-value { font-size: 18px; }

    .review-form,
    .invoice-detail { border-radius: 6px; }

    .dash-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .dash-filter {
        flex-direction: column;
        align-items: stretch;
    }

    .dash-filter-select,
    .dash-filter-btn {
        width: 100%;
        box-sizing: border-box;
    }

    .unpaid-banner {
        margin-top: -20px;
        padding: 8px 16px;
    }

    .dash-section { padding: 16px 18px; }

    .upload-options { max-width: none; }

    .auth-container {
        align-items: flex-start;
        padding: 24px 16px;
    }

    .login-box {
        padding: 24px;
    }

    .upload-box {
        padding: 36px 16px;
        width: 100%;
    }

    .upload-icon {
        min-width: 0;
        max-width: 100%;
    }

    .loading-state { padding: 28px 16px; }

    .review-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .review-preview-column { order: -1; }

    .file-preview-panel {
        position: static;
        padding: 14px;
        width: 100%;
        overflow: hidden;
    }

    .review-file-image,
    .review-file-frame,
    .invoice-file-preview {
        display: block;
        max-width: 100%;
    }

    .review-file-image { max-height: 62vh; }

    .review-file-frame {
        width: 100%;
        height: 62vh;
        min-height: 420px;
    }

    .review-form { padding: 18px; }

    .page-panel { padding: 16px; }

    .form-section { margin-bottom: 22px; }

    .form-section h2,
    .section-header h2 { font-size: 13px; }

    .section-header {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 10px;
    }

    .items-table { min-width: 680px; }

    .items-table th,
    .items-table td { padding: 10px 12px; }

    .items-table input { min-width: 110px; }

    .items-table .item-description { min-width: 160px; }

    /* Show mobile cards, hide desktop table */
    .mobile-cards { display: block; }
    .invoice-table { display: none; }

    /* Show mobile upload buttons, hide drag-drop box */
    .mobile-upload-btns { display: flex; }
    .upload-box { display: none; }

    .form-actions {
        position: sticky;
        bottom: 0;
        z-index: 20;
        background: white;
        box-shadow: 0 -6px 16px rgba(15, 23, 42, 0.07);
        margin: 20px -18px -18px;
        padding: 12px 18px 18px;
    }

    .form-actions .btn,
    .btn { min-height: 44px; }

    .detail-section { padding: 16px 20px; }

    .detail-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .empty-state { padding: 36px 18px; }

    .footer {
        margin-top: 28px;
        padding: 18px 0;
    }

    .action-buttons { flex-direction: column; }

    .action-buttons .btn { width: 100%; }
}

/* ============================================================================
   Responsive — 480px
   ============================================================================ */

@media (max-width: 480px) {
    .container { padding: 0 12px; }

    .main-content { padding: 16px 0; padding-top: 80px; }

    .navbar .container { padding: 10px 12px; }

    .navbar-brand { font-size: 15px; }

    .navbar-links {
        justify-content: center;
        gap: 4px;
    }

    .navbar-links a {
        padding: 7px 8px;
        font-size: 13px;
        text-align: center;
    }

    .navbar-right {
        justify-content: center;
    }

    .user-email {
        width: 100%;
        text-align: center;
    }

    .page-header h1 { font-size: 18px; }

    .login-box { padding: 24px; }

    .upload-box { padding: 28px 12px; }

    .upload-box h3 { font-size: 15px; }

    .review-form { padding: 14px; }

    .file-preview-panel { padding: 12px; }

    .review-file-image { max-height: 55vh; }

    .review-file-frame {
        height: 56vh;
        min-height: 320px;
    }

    .section-header .btn,
    #addItemBtn { width: 100%; }

    .items-table,
    .invoices-table { min-width: 620px; }

    .form-actions {
        margin: 18px -14px -14px;
        padding: 10px 14px 14px;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 8px;
    }

    .pagination .btn { flex: 1 1 auto; }

    .detail-section { padding: 14px 16px; }
}
