/* =====================================================
   Invoice Master — Beetee DA
   Monochrome · Oswald + Inter · Pill buttons · Airy
   ===================================================== */

/* --- CSS Variables --- */
:root {
    --sidebar-width: 260px;
    --topbar-height: 66px;

    /* Sidebar (dark, beetee-style #0a0a0a) */
    --sidebar-bg: #0a0a0a;
    --sidebar-text: rgba(255,255,255,0.45);
    --sidebar-text-active: #ffffff;
    --sidebar-hover: rgba(255,255,255,0.06);
    --sidebar-active-bg: rgba(255,255,255,0.1);
    --sidebar-active-color: #ffffff;
    --sidebar-border: rgba(255,255,255,0.07);

    /* App surface (beetee light: #f5f5f5) */
    --bg: #f5f5f5;
    --surface: #ffffff;
    --border: #e0e0e0;
    --border-dark: #c8c8c8;

    /* Brand — monochrome */
    --primary: #0c0c0c;
    --primary-hover: #333333;
    --primary-light: #f0f0f0;
    --primary-ring: rgba(12,12,12,0.12);

    /* Semantic */
    --success: #18a05a;
    --success-light: #d4f5e3;
    --success-text: #0a5c32;
    --danger: #e03030;
    --danger-light: #fde8e8;
    --danger-text: #8b1a1a;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --warning-text: #7c4a00;

    /* Text */
    --text-primary: #0c0c0c;
    --text-secondary: #555555;
    --text-muted: #999999;

    /* Type */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Oswald', 'Inter', sans-serif;

    /* Shape — more generous radius (beetee: 20px cards, 30px buttons) */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 20px;
    --radius-xl: 24px;
    --radius-btn: 30px;
    --radius-full: 9999px;

    /* Elevation */
    --shadow-xs: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.07);
    --shadow: 0 4px 16px rgba(0,0,0,0.09);
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; }

html {
    font-size: 14px;
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

/* =====================================================
   APP LAYOUT
   ===================================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-header {
    padding: 28px 24px 22px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.sidebar-logo-text {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 500;
    color: #ffffff;
    letter-spacing: 2px;
    text-transform: uppercase;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0 16px;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 8px;
}

.nav-section-label {
    display: block;
    padding: 12px 24px 6px;
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.2);
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 400;
    letter-spacing: 0.3px;
    position: relative;
    transition: background 0.2s, color 0.2s;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-color);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: #ffffff;
    border-radius: 0 2px 2px 0;
}

.nav-icon {
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-footer-text {
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.2);
}

/* =====================================================
   MAIN CONTENT
   ===================================================== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* =====================================================
   TOPBAR
   ===================================================== */
.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 36px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-xs);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.page-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin: 0;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.topbar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: var(--radius);
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    text-decoration: none !important;
}

.topbar-logout:hover {
    background: var(--danger-light);
    color: var(--danger) !important;
    border-color: #f5a5a5;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.topbar-user:hover {
    border-color: var(--primary);
    background: #ffffff;
}

.user-avatar {
    width: 28px; height: 28px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 1px;
}

/* =====================================================
   PAGE CONTENT
   ===================================================== */
.page-content {
    flex: 1;
    padding: 32px 36px 48px;
}

/* =====================================================
   HEADINGS
   ===================================================== */
h1, h2, h3, h4, h5 {
    font-family: var(--font-heading);
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-primary);
    line-height: 1.3;
}

h2 {
    font-size: 20px;
    margin-bottom: 28px;
    margin-top: 0;
}

h3 {
    font-size: 15px;
    margin-bottom: 16px;
    margin-top: 0;
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    padding: 28px;
    margin-bottom: 28px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-primary);
    margin: 0;
}

/* =====================================================
   STATS GRID
   ===================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 18px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 26px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.stat-label {
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1;
}

.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

.stat-sub { font-size: 12px; margin-top: 4px; color: var(--text-muted); font-weight: 500; }
.stat-sub.positive { color: var(--success); }
.stat-sub.negative { color: var(--danger); }

/* =====================================================
   ACTION BAR
   ===================================================== */
.action-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 28px;
    align-items: center;
}

/* =====================================================
   BUTTONS — beetee pill style
   ===================================================== */
.uk-button,
a.uk-button {
    display: inline-flex !important;
    align-items: center !important;
    gap: 7px !important;
    padding: 9px 22px !important;
    border-radius: var(--radius-btn) !important;
    font-family: var(--font-heading) !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    letter-spacing: 1.5px !important;
    text-transform: uppercase !important;
    cursor: pointer !important;
    text-decoration: none !important;
    border: 1px solid transparent !important;
    transition: all 0.25s ease !important;
    white-space: nowrap !important;
    line-height: 1.4 !important;
    width: auto !important;
}

.uk-button:hover, a.uk-button:hover {
    text-decoration: none !important;
    transform: translateY(-2px) !important;
}

.uk-button-primary {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
}
.uk-button-primary:hover {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    color: white !important;
    opacity: 0.9 !important;
}

.uk-button-secondary {
    background: transparent !important;
    color: var(--text-primary) !important;
    border-color: var(--border-dark) !important;
}
.uk-button-secondary:hover {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
}

.uk-button-danger {
    background: var(--danger) !important;
    color: white !important;
    border-color: var(--danger) !important;
}
.uk-button-danger:hover {
    background: #c02020 !important;
    color: white !important;
}

/* Bootstrap button overrides */
.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: var(--radius-btn);
    font-family: var(--font-heading);
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 9px 22px;
    color: white;
    transition: all 0.25s ease;
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
    transform: translateY(-2px);
}
.btn-primary:focus,
.btn-primary:active:focus {
    box-shadow: 0 0 0 3px var(--primary-ring);
}

/* Icon ghost buttons in forms */
button[style*="background:none"],
button[style*="background: none"] {
    background: transparent !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    padding: 5px 8px !important;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

button[style*="background:none"]:hover,
button[style*="background: none"]:hover {
    background: var(--danger-light) !important;
    color: var(--danger) !important;
    border-color: #f5a5a5 !important;
}

/* =====================================================
   TABLE
   ===================================================== */
.table-wrapper {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    margin-bottom: 28px;
}

.uk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 0 !important;
}

.uk-table thead {
    background: #fafafa;
}

.uk-table thead tr {
    border-bottom: 1px solid var(--border) !important;
    background: transparent !important;
}

.uk-table th {
    padding: 13px 18px !important;
    text-align: left !important;
    font-family: var(--font-heading) !important;
    font-size: 9px !important;
    font-weight: 500 !important;
    text-transform: uppercase !important;
    letter-spacing: 2px !important;
    color: var(--text-muted) !important;
    background: transparent !important;
    white-space: nowrap;
}

.uk-table td {
    padding: 14px 18px !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border) !important;
    vertical-align: middle;
    font-size: 13px;
}

.uk-table tbody tr:last-child td {
    border-bottom: none !important;
}

.uk-table-striped tbody tr:nth-of-type(odd) {
    background: transparent !important;
}

.uk-table-striped tbody tr:nth-of-type(even) {
    background: #fafafa !important;
}

.uk-table tbody tr {
    transition: background 0.15s;
}

.uk-table tbody tr:hover {
    background: #f5f5f5 !important;
}

.uk-table tbody tr.row-clickable:hover {
    background: var(--primary-light) !important;
}

/* =====================================================
   BADGES
   ===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success-text); }
.badge-danger  { background: var(--danger-light);  color: var(--danger-text); }
.badge-warning { background: var(--warning-light); color: var(--warning-text); }
.badge-primary { background: var(--primary);       color: #ffffff; }
.badge-neutral { background: #ebebeb; color: #555555; }

/* =====================================================
   ALERTS (UIKit overrides)
   ===================================================== */
.uk-alert {
    border-radius: var(--radius) !important;
    padding: 14px 18px !important;
    margin-bottom: 22px !important;
    border: 1px solid transparent !important;
    font-size: 13px !important;
}

.uk-alert-success {
    background: var(--success-light) !important;
    color: var(--success-text) !important;
    border-color: #a3dfc0 !important;
    border-left: 4px solid var(--success) !important;
}

.uk-alert-danger {
    background: var(--danger-light) !important;
    color: var(--danger-text) !important;
    border-color: #f5a5a5 !important;
    border-left: 4px solid var(--danger) !important;
}

.uk-alert-warning {
    background: var(--warning-light) !important;
    color: var(--warning-text) !important;
    border-color: #fcd34d !important;
    border-left: 4px solid var(--warning) !important;
}

/* =====================================================
   FORMS
   ===================================================== */
label,
.uk-form-label {
    display: block;
    margin-bottom: 6px;
    font-family: var(--font-heading) !important;
    font-size: 10px !important;
    font-weight: 500 !important;
    letter-spacing: 1.5px !important;
    text-transform: uppercase !important;
    color: var(--text-secondary) !important;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="date"],
input[type="search"],
select,
textarea,
.uk-input,
.uk-select,
.uk-textarea {
    width: 100% !important;
    padding: 10px 14px !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    font-size: 13px !important;
    color: var(--text-primary) !important;
    background: var(--surface) !important;
    font-family: var(--font-body) !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
    outline: none !important;
    line-height: 1.5 !important;
}

input:focus,
select:focus,
textarea:focus,
.uk-input:focus,
.uk-select:focus,
.uk-textarea:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px var(--primary-ring) !important;
}

.form-control:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 3px var(--primary-ring);
    border-color: var(--primary);
}

/* =====================================================
   LINKS
   ===================================================== */
a {
    color: var(--text-primary);
    text-decoration: none;
}

a:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}

/* =====================================================
   UIKit container override
   ===================================================== */
.uk-container {
    max-width: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* =====================================================
   FOCUS RING (accessibility)
   ===================================================== */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* =====================================================
   SCROLLBAR
   ===================================================== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaaaaa; }

/* =====================================================
   UTILITY
   ===================================================== */
.text-muted   { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }

/* =====================================================
   INVOICE DETAIL PAGE
   ===================================================== */

/* Full-bleed dark header (extends outside page-content padding) */
.invoice-header {
    background: var(--primary);
    color: white;
    padding: 36px 36px 40px;
    margin: -32px -36px 36px;
}

.invoice-title {
    font-family: var(--font-heading);
    font-size: 30px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: white;
    margin: 0 0 8px;
    line-height: 1.2;
}

.invoice-subtitle {
    font-family: var(--font-body);
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    margin: 0;
    letter-spacing: 0.5px;
}

/* Status badges on dark bg */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 7px 18px;
    border-radius: var(--radius-full);
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    white-space: nowrap;
}

.status-completed  { background: rgba(24,160,90,0.2);  color: #6ee7b7; border: 1px solid rgba(24,160,90,0.3); }
.status-processing { background: rgba(217,119,6,0.2);  color: #fcd34d; border: 1px solid rgba(217,119,6,0.3); }
.status-pending    { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.7); border: 1px solid rgba(255,255,255,0.15); }

/* Section dividers */
.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 14px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.section-header h3 {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

/* Info cards grid */
.info-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    margin-bottom: 16px;
    transition: box-shadow 0.2s;
}

.info-card:hover { box-shadow: var(--shadow-sm); }

.info-label {
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin: 0 0 6px;
}

.info-value {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.4;
}

/* Order block */
.order-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.order-title {
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.order-badge {
    background: var(--primary);
    color: white;
    padding: 4px 14px;
    border-radius: var(--radius-full);
    font-size: 10px;
    letter-spacing: 1px;
}

/* Address block inside order */
.address-section {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-top: 20px;
}

.address-title {
    font-family: var(--font-heading);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin: 0 0 12px;
}

/* Totals block */
.totals-summary {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    margin: 32px 0;
}

.total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.total-row:last-child { border-bottom: none; }

.total-label {
    font-family: var(--font-heading);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

.total-amount {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.grand-total .total-label {
    font-size: 11px;
    color: var(--text-primary);
}

.grand-total .total-amount {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 500;
    letter-spacing: 1px;
}

/* Tracking */
.tracking-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    margin-bottom: 12px;
    transition: box-shadow 0.2s;
}

.tracking-item:hover { box-shadow: var(--shadow-sm); }

.tracking-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-heading);
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-primary) !important;
    text-decoration: none !important;
    padding: 7px 18px;
    border: 1px solid var(--primary);
    border-radius: var(--radius-btn);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.tracking-link:hover {
    background: var(--primary) !important;
    color: white !important;
    transform: translateY(-1px);
    text-decoration: none !important;
}

/* Action buttons row */
.action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* =====================================================
   INVOICE FORM SECTIONS
   ===================================================== */

/* Visual section within a card */
.form-section {
    margin-bottom: 32px;
}

.form-section:last-child { margin-bottom: 0; }

.form-section-title {
    font-family: var(--font-heading);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

/* Products block inside form */
.product-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 10px;
    position: relative;
}

/* Totals strip at bottom of form */
.invoice-totals-strip {
    background: var(--primary);
    color: white;
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    margin-top: 8px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: center;
}

.invoice-totals-strip label,
.invoice-totals-strip .uk-form-label {
    color: rgba(255,255,255,0.6) !important;
}

.invoice-totals-strip input,
.invoice-totals-strip .uk-input {
    background: rgba(255,255,255,0.08) !important;
    border-color: rgba(255,255,255,0.15) !important;
    color: white !important;
    font-size: 16px !important;
    font-weight: 600 !important;
}

/* =====================================================
   HAMBURGER BUTTON
   ===================================================== */
.hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 38px;
    height: 38px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s;
}

.hamburger-btn:hover {
    background: var(--primary-light);
    border-color: var(--border-dark);
}

.hamburger-line {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform 0.25s ease, opacity 0.25s ease;
    transform-origin: center;
}

/* Animation croix quand actif */
.hamburger-btn.is-active .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.is-active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}
.hamburger-btn.is-active .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* =====================================================
   SIDEBAR OVERLAY (mobile)
   ===================================================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* =====================================================
   COMPACT TABLE BUTTONS (.btn-sm)
   Used in table rows where full padding would be too large on desktop,
   but we can scale them up on mobile for touch targets.
   ===================================================== */
.btn-sm {
    padding: 5px 12px !important;
    font-size: 11px !important;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */

/* -------- ≤ 900px: sidebar goes off-canvas -------- */
@media (max-width: 900px) {
    .hamburger-btn { display: flex; }
    .sidebar-overlay { display: block; }

    .sidebar {
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 200 !important;
    }

    .sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }

    .main-content { margin-left: 0; }
    .page-content { padding: 20px; }
    .topbar { padding: 0 20px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }

    /* Tables: horizontal scroll instead of overflow-hidden clipping */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .uk-table { min-width: 480px; }

    /* Invoice header: recalculate negative margins for 20px page padding */
    .invoice-header {
        margin: -20px -20px 24px;
        padding: 24px 20px 28px;
    }

    /* Invoice form layout: collapse 2-col to single column */
    .invoice-form-cols {
        grid-template-columns: 1fr !important;
    }

    /* Table action buttons: bigger touch targets */
    .btn-sm {
        padding: 8px 16px !important;
        font-size: 11px !important;
        min-height: 36px;
    }
}

/* -------- ≤ 640px: tighter spacing -------- */
@media (max-width: 640px) {
    /* Form grids: collapse to single column */
    .client-addr-grid,
    .client-name-grid {
        grid-template-columns: 1fr !important;
    }
    .card { padding: 18px 16px; }
    .card-header { margin-bottom: 16px; padding-bottom: 14px; }

    /* Invoice totals strip: single column */
    .invoice-totals-strip {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    /* Product block: left-border visual grouping */
    .product-block {
        border-left: 3px solid var(--border-dark);
        padding: 14px 12px;
        margin-bottom: 14px;
    }

    /* Color entry grid (AddProduct): collapse inline 3-col grid */
    .color-entry {
        grid-template-columns: 1fr !important;
    }

    /* Action buttons (detail pages): stack vertically */
    .action-buttons {
        flex-direction: column;
        gap: 10px;
    }
    .action-buttons .uk-button,
    .action-buttons a.uk-button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Totals summary: more compact */
    .totals-summary { padding: 18px 20px; }
    .grand-total .total-amount { font-size: 20px; }
}

/* =====================================================
   EXTRACT PDF — Loader overlay
   ===================================================== */
.extract-loader-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    z-index: 200;
}

.extract-loader-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 201;
    background: var(--surface);
    border-radius: var(--radius-xl);
    padding: 40px 48px;
    text-align: center;
    box-shadow: var(--shadow);
    min-width: 260px;
}

.extract-loader-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.extract-loader-title {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.extract-loader-sub {
    font-size: 12px;
    color: var(--text-muted);
}

/* =====================================================
   DASHBOARD — Unpaid invoices
   ===================================================== */
.status-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--primary-light) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E") no-repeat right 10px center;
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    padding: 5px 28px 5px 12px;
    font-size: 12px;
    font-family: var(--font-body);
    color: var(--text-primary);
    cursor: pointer;
    height: auto;
    min-width: 130px;
    transition: border-color 0.15s;
}

.status-select:focus { outline: none; border-color: var(--primary); }
.status-select:disabled { opacity: 0.5; cursor: wait; }

.status-saving {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 6px;
    animation: pulse 0.8s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.unpaid-ref {
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
}
.unpaid-ref:hover { text-decoration: underline; }

/* =====================================================
   CLIENTS — Index toolbar
   ===================================================== */
.clients-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    padding: 4px;
}

.filter-tab {
    background: none;
    border: none;
    padding: 6px 16px;
    border-radius: var(--radius-btn);
    font-size: 13px;
    font-family: var(--font-body);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.filter-tab:hover { background: var(--primary-light); color: var(--text-primary); }
.filter-tab.active { background: var(--primary); color: #fff; }

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    padding: 0 14px;
    color: var(--text-muted);
    min-width: 220px;
}

.search-box .uk-input {
    border: none !important;
    background: none !important;
    box-shadow: none !important;
    padding: 8px 0 !important;
    font-size: 13px;
}

.filter-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E") no-repeat right 12px center;
    border: 1px solid var(--border);
    border-radius: var(--radius-btn);
    padding: 7px 32px 7px 14px;
    font-size: 13px;
    font-family: var(--font-body);
    color: var(--text-primary);
    cursor: pointer;
    height: auto;
    transition: border-color 0.15s;
    white-space: nowrap;
}

.filter-select:focus { outline: none; border-color: var(--primary); }
.filter-select:hover { border-color: var(--border-dark); }

/* Avatar small (index list) */
.client-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    flex-shrink: 0;
}

/* =====================================================
   CLIENTS — Profile page
   ===================================================== */
.client-profile-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-bottom: 28px;
    box-shadow: var(--shadow-xs);
}

.client-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 2px;
    flex-shrink: 0;
}

.client-profile-info { flex: 1; min-width: 0; }

.client-profile-name {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 500;
    letter-spacing: 1px;
    margin: 0 0 8px;
    text-transform: uppercase;
}

.client-profile-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.client-profile-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.client-profile-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: flex-start;
}

/* Info rows inside cards */
.client-info-row {
    display: flex;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    align-items: baseline;
}

.client-info-row:last-child { border-bottom: none; }

.client-info-label {
    width: 80px;
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 12px;
}

/* -------- ≤ 480px: small phones -------- */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    h2 { font-size: 17px; }

    /* Topbar: hide user name (keep avatar), tighten spacing */
    .topbar-user > span { display: none; }
    .topbar-user { padding: 4px; gap: 0; }

    /* Page title: truncate long titles */
    .page-title {
        font-size: 14px;
        letter-spacing: 0.8px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 150px;
    }

    /* Action bar: tighten gap */
    .action-bar { gap: 8px; }

    /* Stat cards: reduce padding */
    .stat-card { padding: 18px 16px; }
    .stat-value { font-size: 22px; }
}

/* =====================================================
   FORM GRID HELPERS
   ===================================================== */
.form-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* =====================================================
   GLOBAL OVERFLOW FIX
   Prevents flex child from overflowing the viewport.
   ===================================================== */
.main-content {
    min-width: 0;
    overflow-x: hidden;
}

/* =====================================================
   RESPONSIVE ADDITIONS
   ===================================================== */

/* -------- ≤ 900px additions -------- */
@media (max-width: 900px) {
    /* Better table min-width for 5-6 col tables */
    .uk-table { min-width: 600px; }

    /* Collapse invoice form inner 2-col grids */
    .form-2col { grid-template-columns: 1fr !important; }

    /* Filter toolbar: allow full-width stacking */
    .clients-toolbar { flex-wrap: wrap; gap: 10px; }
}

/* -------- ≤ 640px additions -------- */
@media (max-width: 640px) {
    /* Toolbar: stack vertically, stretch all children */
    .clients-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .clients-toolbar > div { width: 100%; }

    /* Search box: full width, no min-width cap */
    .search-box { min-width: unset; width: 100%; box-sizing: border-box; }

    /* Filter select: full width */
    .filter-select { width: 100%; }

    /* Filter tabs: allow horizontal scroll so they don't break to lines */
    .filter-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-shrink: 0;
    }
    .filter-tabs::-webkit-scrollbar { display: none; }

    /* Card headers: wrap on small screens */
    .card-header { flex-wrap: wrap; gap: 10px; }

    /* Action bar: 2 buttons per row on small screens */
    .action-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .action-bar .uk-button,
    .action-bar a.uk-button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Client profile header: stack on mobile */
    .client-profile-header { flex-direction: column; }
    .client-profile-actions { flex-direction: row; }

    /* ExtractInvoicePdf: multi-col grids collapse */
    .form-grid-approve { grid-template-columns: 1fr 1fr !important; }
}

/* -------- ≤ 480px additions -------- */
@media (max-width: 480px) {
    /* Action bar: single column */
    .action-bar { grid-template-columns: 1fr; }

    /* Reduce card padding further */
    .card { padding: 14px 12px; }

    /* Product lines in extract: collapse grid */
    .form-grid-approve { grid-template-columns: 1fr !important; }

    /* Stats values: slightly smaller on very small phones */
    .stat-value { font-size: 20px; }
}

/* =====================================================
   TOAST NOTIFICATIONS
   ===================================================== */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { min-width: 280px; max-width: 400px; padding: 14px 18px; border-radius: 8px; box-shadow: 0 4px 24px rgba(0,0,0,0.12); display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 500; animation: toastIn 0.3s ease; pointer-events: all; }
.toast.success { background: #18a05a; color: white; }
.toast.error   { background: #e03030; color: white; }
.toast.warning { background: #d97706; color: white; }
.toast.info    { background: #0c0c0c; color: white; }
@keyframes toastIn  { from { opacity:0; transform: translateY(16px); } to { opacity:1; transform: translateY(0); } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform: translateY(8px); } }

/* =====================================================
   CONFIRM MODAL
   ===================================================== */
.confirm-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 9998; display: none; align-items: center; justify-content: center; }
.confirm-modal-overlay.active { display: flex; }
.confirm-modal { background: #ffffff; border-radius: 12px; padding: 32px; max-width: 420px; width: 90%; box-shadow: 0 12px 40px rgba(0,0,0,0.16); }
.confirm-modal h3 { font-family: 'Oswald', sans-serif; font-size: 1.2rem; margin: 0 0 8px; }
.confirm-modal p { color: #999; margin: 0 0 24px; font-size: 14px; }
.confirm-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* =====================================================
   GLOBAL SPINNER
   ===================================================== */
#globalSpinner { position: fixed; inset: 0; background: rgba(255,255,255,0.8); z-index: 9997; display: none; align-items: center; justify-content: center; }
#globalSpinner.active { display: flex; }
.spinner-ring { width: 48px; height: 48px; border: 4px solid #e0e0e0; border-top-color: #0c0c0c; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* =====================================================
   KPI CARDS (DASHBOARD)
   ===================================================== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: #ffffff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); border-left: 4px solid #e0e0e0; }
.kpi-card.danger  { border-left-color: #e03030; }
.kpi-card.success { border-left-color: #18a05a; }
.kpi-card.warning { border-left-color: #d97706; }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #999; margin-bottom: 6px; }
.kpi-value { font-family: 'Oswald', sans-serif; font-size: 1.8rem; font-weight: 700; color: #0c0c0c; }
.kpi-sub { font-size: 11px; color: #999; margin-top: 4px; }

/* =====================================================
   KANBAN BOARD
   ===================================================== */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.kanban-column { min-width: 240px; max-width: 280px; background: #f8f8f8; border-radius: 10px; padding: 16px; }
.kanban-column-header { font-family: 'Oswald', sans-serif; font-size: 0.9rem; letter-spacing: 0.05em; text-transform: uppercase; color: #999; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.kanban-column-count { background: #e0e0e0; border-radius: 999px; padding: 2px 8px; font-size: 11px; }
.kanban-column-body { min-height: 60px; }
.kanban-card { background: #ffffff; border-radius: 8px; padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); cursor: grab; border-left: 3px solid transparent; transition: box-shadow 0.15s, transform 0.15s; }
.kanban-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }
.kanban-card-client { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.kanban-card-ref { font-size: 11px; color: #999; }
.kanban-card-amount { font-family: 'Oswald', sans-serif; font-size: 1rem; margin-top: 8px; }
.pipeline-stage-won  { background: #d4f5e3; }
.pipeline-stage-lost { background: #fde8e8; }

/* =====================================================
   PAGINATION
   ===================================================== */
.pagination-container { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; flex-wrap: wrap; gap: 10px; }
.pagination-info { font-size: 12px; color: #999; }
.pagination { display: flex; gap: 4px; }
.page-btn { padding: 6px 12px; border-radius: 6px; border: 1px solid #e0e0e0; background: #ffffff; color: #0c0c0c; font-size: 13px; text-decoration: none; transition: all 0.15s; }
.page-btn:hover { background: #f0f0f0; border-color: #0c0c0c; }
.page-btn.active { background: #0c0c0c; color: white; border-color: #0c0c0c; }

/* =====================================================
   CALENDAR PLANNING
   ===================================================== */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: #e0e0e0; border-radius: 10px; overflow: hidden; }
.calendar-day-header { background: #0c0c0c; color: white; text-align: center; padding: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.calendar-day { background: #ffffff; min-height: 90px; padding: 8px; font-size: 12px; }
.calendar-day.other-month { background: #fafafa; color: #ccc; }
.calendar-day.today { background: #fffbf0; }
.calendar-day-number { font-weight: 600; margin-bottom: 4px; }
.calendar-event { display: block; font-size: 10px; padding: 2px 6px; border-radius: 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; text-decoration: none; }
.calendar-event.order    { background: #dbeafe; color: #1d4ed8; }
.calendar-event.invoice  { background: #fef3c7; color: #92400e; }
.calendar-event.delivery { background: #d1fae5; color: #065f46; }

/* =====================================================
   TAB SYSTEM
   ===================================================== */
.tabs { display: flex; border-bottom: 2px solid #e0e0e0; margin-bottom: 24px; gap: 0; overflow-x: auto; }
.tab-btn { padding: 12px 20px; font-size: 13px; font-weight: 500; color: #999; border: none; background: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; white-space: nowrap; }
.tab-btn.active { color: #0c0c0c; border-bottom-color: #0c0c0c; }
.tab-content { display: none; }
.tab-content.active { display: block; }
