/* ===========================
   shadcn UI Dark Theme
   Inter Font · Accent #ed1a3b
   =========================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* shadcn Dark Palette */
    --background: #09090b;
    --foreground: #fafafa;
    --card: #0a0a0c;
    --card-foreground: #fafafa;
    --popover: #09090b;
    --popover-foreground: #fafafa;

    /* Primary / Accent */
    --primary: #ed1a3b;
    --primary-foreground: #ffffff;
    --primary-hover: #d4162f;
    --primary-light: rgba(237, 26, 59, 0.12);

    /* Secondary */
    --secondary: #27272a;
    --secondary-foreground: #fafafa;

    /* Muted */
    --muted: #27272a;
    --muted-foreground: #a1a1aa;

    /* Accent (UI hover) */
    --accent: #27272a;
    --accent-foreground: #fafafa;

    /* Destructive */
    --destructive: #dc2626;
    --destructive-foreground: #fafafa;

    /* Success */
    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.12);

    /* Warning */
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.12);

    /* Info */
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.12);

    /* Border & Ring */
    --border: #27272a;
    --input: #27272a;
    --ring: #ed1a3b;

    /* Radius */
    --radius: 0.5rem;

    /* Transition */
    --transition: all 0.15s ease;
}

/* ===========================
   Light Theme Override
   =========================== */
[data-theme="light"] {
    --background: #f4f4f5;
    --foreground: #09090b;
    --card: #ffffff;
    --card-foreground: #09090b;
    --popover: #ffffff;
    --popover-foreground: #09090b;

    --primary: #ed1a3b;
    --primary-foreground: #ffffff;
    --primary-hover: #d4162f;
    --primary-light: rgba(237, 26, 59, 0.06);

    --secondary: #e8e8ea;
    --secondary-foreground: #18181b;

    --muted: #ebebed;
    --muted-foreground: #52525b;

    --accent: #ebebed;
    --accent-foreground: #18181b;

    --destructive: #dc2626;
    --destructive-foreground: #fafafa;

    --success: #16a34a;
    --success-light: rgba(22, 163, 74, 0.08);

    --warning: #d97706;
    --warning-light: rgba(217, 119, 6, 0.08);

    --info: #2563eb;
    --info-light: rgba(37, 99, 235, 0.08);

    --border: #d4d4d8;
    --input: #d4d4d8;
    --ring: #ed1a3b;

    /* Light mode specific - neon overrides */
    --neon-blue: #2563eb;
    --neon-cyan: #0891b2;
    --neon-purple: #7c3aed;
    --neon-orange: #d97706;
    --neon-green: #16a34a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background);
    min-height: 100vh;
    padding: 1.5rem;
    color: var(--foreground);
    overflow-x: hidden;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===========================
   Container & Layout
   =========================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* ===========================
   Header
   =========================== */
.header {
    text-align: center;
    color: var(--foreground);
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--foreground);
    letter-spacing: -0.025em;
    margin-bottom: 0.25rem;
}

.header .subtitle {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin-bottom: 1rem;
}

/* ===========================
   Navigation Tabs
   =========================== */
.nav-tabs {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.nav-tab {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted-foreground);
    text-decoration: none;
    border-radius: var(--radius);
    transition: var(--transition);
    border: 1px solid transparent;
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--foreground);
    background: var(--accent);
}

.nav-tab.active {
    color: var(--primary-foreground);
    background: var(--primary);
    border-color: var(--primary);
}

/* ===========================
   Card Component
   =========================== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--card-foreground);
    letter-spacing: -0.025em;
    margin-bottom: 1rem;
}

.form-section.card h2 {
    font-size: 1rem;
    font-weight: 600;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.25rem;
}

.form-section h3 {
    color: var(--muted-foreground);
    font-size: 0.8125rem;
    font-weight: 600;
    margin: 1.25rem 0 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ===========================
   Form Elements
   =========================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--foreground);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.5rem 0.75rem;
    background: var(--background);
    border: 1px solid var(--input);
    border-radius: var(--radius);
    color: var(--foreground);
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    transition: var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 2px rgba(237, 26, 59, 0.2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--muted-foreground);
    opacity: 0.6;
}

.form-group input[readonly] {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-group select option {
    background: var(--background);
    color: var(--foreground);
}

.image-preview {
    margin-top: 0.5rem;
    min-height: 50px;
}

.image-preview img {
    max-width: 300px;
    max-height: 200px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    object-fit: contain;
}

.paste-hint {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

#imagePreview img[role="button"] {
    cursor: zoom-in;
}

.hint {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    margin-bottom: 0.75rem;
}

.note {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* ===========================
   Buttons
   =========================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1.25;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--secondary-foreground);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: #3f3f46;
}

.btn-outline {
    background: transparent;
    color: var(--foreground);
    border-color: var(--border);
}

.btn-outline:hover {
    background: var(--accent);
}

.btn-danger,
.btn-delete {
    background: transparent;
    color: var(--destructive);
    border-color: var(--destructive);
}

.btn-danger:hover,
.btn-delete:hover {
    background: var(--destructive);
    color: var(--destructive-foreground);
}

.btn-invoice {
    background: transparent;
    color: var(--warning);
    border-color: var(--warning);
}

.btn-invoice:hover {
    background: var(--warning);
    color: #000;
}

.btn-sm,
.btn-small {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-large {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.salesperson-field {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.salesperson-field select {
    flex: 1;
}

/* ===========================
   Table Styles
   =========================== */
.table-section {
    overflow: hidden;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.date-filter {
    padding: 0.375rem 0.75rem;
    background: var(--background);
    border: 1px solid var(--input);
    border-radius: var(--radius);
    color: var(--foreground);
    font-size: 0.8125rem;
    font-family: 'Inter', sans-serif;
}

.order-table,
.material-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.order-table {
    table-layout: fixed;
}

.order-table thead,
.material-table thead {
    background: var(--muted);
}

.order-table th,
.material-table th {
    padding: 0.375rem 0.375rem;
    text-align: left;
    font-weight: 600;
    color: var(--muted-foreground);
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
}

.order-table td,
.material-table td {
    padding: 0.375rem 0.375rem;
    border-bottom: 1px solid var(--border);
    color: var(--foreground);
    vertical-align: middle;
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Order table column widths */
.order-table th:nth-child(1),
.order-table td:nth-child(1) {
    width: 28px;
}

/* checkbox */
.order-table th:nth-child(2),
.order-table td:nth-child(2) {
    width: 210px;
}

/* status */
.order-table th:nth-child(3),
.order-table td:nth-child(3) {
    width: 4%;
}

/* order no */
.order-table th:nth-child(4),
.order-table td:nth-child(4) {
    width: 5%;
}

/* client code */
.order-table th:nth-child(5),
.order-table td:nth-child(5) {
    width: 5%;
}

/* material type */
.order-table th:nth-child(6),
.order-table td:nth-child(6) {
    width: 4%;
}

/* date */
.order-table th:nth-child(7),
.order-table td:nth-child(7) {
    width: 14%;
}

/* order number */
.order-table th:nth-child(8),
.order-table td:nth-child(8) {
    width: 5%;
}

/* services */
.order-table th:nth-child(9),
.order-table td:nth-child(9) {
    width: 10%;
}

/* materials */
.order-table th:nth-child(10),
.order-table td:nth-child(10) {
    width: 6%;
}

/* price 1 */
.order-table th:nth-child(11),
.order-table td:nth-child(11) {
    width: 6%;
}

/* price 2 */
.order-table th:nth-child(12),
.order-table td:nth-child(12) {
    width: 6%;
}

/* total */
.order-table th:nth-child(13),
.order-table td:nth-child(13) {
    width: 7%;
}

/* salesperson */
.order-table th:nth-child(14),
.order-table td:nth-child(14) {
    width: 8%;
}

/* remark */
.order-table th:nth-child(15),
.order-table td:nth-child(15) {
    width: 6%;
}

/* actions */

.order-table tbody tr:hover,
.order-table tbody tr.last-edited-order,
.material-table tbody tr:hover {
    background: var(--accent);
}

.order-table th:first-child,
.order-table td:first-child,
.material-table th:first-child,
.material-table td:first-child {
    width: 40px;
    text-align: center;
}

/* Smaller text for Email and Description columns */
.order-table td:nth-child(1),
.order-table td:nth-child(5) {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* Status Styles */
.status-dropdown {
    padding: 0.375rem 0.5rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--foreground);
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
}

.status-dropdown option {
    background: var(--background);
    color: var(--foreground);
}

/* Status colors */
.order-table .status-dropdown {
    width: 100%;
}

.status-place-order {
    color: var(--info);
}

.status-cutting {
    color: var(--warning);
}

.status-done-cutting {
    color: var(--primary);
}

.status-delivered {
    color: var(--success);
}

.status-invoiced {
    color: var(--muted-foreground);
}

.status-ready-to-create-invoice {
    color: var(--success);
    font-weight: 600;
}

/* Invoice Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: calc(var(--radius) * 10);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.025em;
}

.status-created {
    background: rgba(107, 114, 128, 0.15);
    color: #9ca3af;
}

.status-sent {
    background: var(--info-light);
    color: #60a5fa;
}

.status-paid {
    background: var(--success-light);
    color: #34d399;
}

.status-overdue {
    background: rgba(237, 26, 59, 0.12);
    color: var(--primary);
}

/* Sortable Headers */
.sortable {
    cursor: pointer;
    user-select: none;
}

.sortable:hover {
    color: var(--foreground);
}

.sort-indicator {
    margin-left: 0.25rem;
    opacity: 0.5;
}

/* Service Image in Table */
.service-img {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: calc(var(--radius) / 2);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.service-img:hover {
    border-color: var(--primary);
    opacity: 0.8;
}

/* Action Buttons */
.action-btns {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.action-btn {
    padding: 0.3rem 0.6rem;
    font-size: 0.6875rem;
    border: 1px solid var(--border);
    background: transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    color: var(--muted-foreground);
}

.action-btn:hover {
    background: var(--accent);
    color: var(--foreground);
    border-color: var(--muted-foreground);
}

.action-btn.edit {
    color: var(--info);
    border-color: rgba(59, 130, 246, 0.3);
}

.action-btn.edit:hover {
    background: var(--info-light);
    border-color: var(--info);
}

.action-btn.delete {
    color: var(--destructive);
    border-color: rgba(220, 38, 38, 0.3);
}

.action-btn.delete:hover {
    background: rgba(220, 38, 38, 0.12);
    border-color: var(--destructive);
}

.action-btn.pdf {
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.3);
}

.action-btn.pdf:hover {
    background: var(--success-light);
    border-color: var(--success);
}

.action-btn.print {
    color: #8b5cf6;
    border-color: rgba(139, 92, 246, 0.3);
}

.action-btn.print:hover {
    background: rgba(139, 92, 246, 0.12);
    border-color: #8b5cf6;
}

.action-btn.invoice-btn {
    color: var(--warning);
    border-color: rgba(245, 158, 11, 0.3);
}

.action-btn.invoice-btn:hover {
    background: var(--warning-light);
    border-color: var(--warning);
}

/* ===========================
   Modal
   =========================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.15s ease-out;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    animation: scaleIn 0.15s ease-out;
}

.modal-content h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.modal-content h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.modal-content .close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: var(--transition);
    border: none;
    background: none;
    line-height: 1;
}

.modal-content .close:hover {
    color: var(--foreground);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    position: relative;
}

.modal-body {
    margin-bottom: 1rem;
}

.modal-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--background);
    border: 1px solid var(--input);
    border-radius: var(--radius);
    color: var(--foreground);
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
}

.modal-content p {
    margin-bottom: 1rem;
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.image-viewer-content {
    max-width: 90%;
}

.image-viewer-body img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* Salesperson Modal */
.salesperson-add {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.salesperson-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.salesperson-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ===========================
   Loading Overlay
   =========================== */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    z-index: 2000;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 500;
    z-index: 3000;
    animation: slideUp 0.3s ease-out;
    border: 1px solid var(--border);
}

.toast-success {
    background: var(--success-light);
    color: var(--success);
    border-color: rgba(34, 197, 94, 0.3);
}

.toast-error {
    background: rgba(220, 38, 38, 0.12);
    color: var(--destructive);
    border-color: rgba(220, 38, 38, 0.3);
}

/* Filter inputs */
.filter-input,
.search-input {
    padding: 0.375rem 0.75rem;
    background: var(--background);
    border: 1px solid var(--input);
    border-radius: var(--radius);
    color: var(--foreground);
    font-size: 0.8125rem;
    font-family: 'Inter', sans-serif;
    min-width: 200px;
}

.filter-input:focus,
.search-input:focus {
    border-color: var(--ring);
    outline: none;
    box-shadow: 0 0 0 2px rgba(237, 26, 59, 0.2);
}

/* Editable Hint */
.editable-hint {
    font-size: 0.625rem;
    color: var(--muted-foreground);
    opacity: 0.6;
}

/* ===========================
   Animations
   =========================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(1rem);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===========================
   Scrollbar
   =========================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--muted);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3f3f46;
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
    body {
        padding: 0.75rem;
    }

    .header h1 {
        font-size: 1.125rem;
    }

    .nav-tabs {
        gap: 0.25rem;
    }

    .nav-tab {
        padding: 0.375rem 0.5rem;
        font-size: 0.6875rem;
    }

    .card {
        padding: 1rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .table-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .order-table,
    .material-table {
        font-size: 0.75rem;
    }

    .order-table th,
    .order-table td,
    .material-table th,
    .material-table td {
        padding: 0.375rem 0.5rem;
    }

    .action-btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.625rem;
    }

    .modal-content {
        width: 95%;
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 0.5rem;
    }

    .header h1 {
        font-size: 1rem;
    }

    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.75rem;
    }
}

/* ===========================
   Print Styles
   =========================== */
@media print {
    body {
        background: #fff;
        color: #000;
        padding: 0;
    }

    .header,
    .nav-tabs,
    .form-section,
    .btn,
    .action-btns,
    .loading-overlay,
    .modal {
        display: none !important;
    }

    .card {
        border: 1px solid #ccc;
        box-shadow: none;
    }

    .order-table th,
    .order-table td {
        border: 1px solid #ccc;
        color: #000;
    }
}

/* ===========================
   Utility Classes
   =========================== */
.text-muted {
    color: var(--muted-foreground);
}

.text-primary {
    color: var(--primary);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--destructive);
}

.text-sm {
    font-size: 0.8125rem;
}

.text-xs {
    font-size: 0.75rem;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.gap-1 {
    gap: 0.5rem;
}

/* ===========================
   Materials Calculator (compact, side-by-side)
   =========================== */
.bottom-row {
    grid-column: 1 / -1;
    display: flex;
    gap: 1rem;
}

.bottom-row>.form-section {
    flex: 0 0 auto;
}

.bottom-row>.calculator-section {
    flex: 1 1 0;
    min-width: 0;
}

@media (max-width: 768px) {
    .bottom-row {
        flex-direction: column;
    }
}

.calculator-stack {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 900px) {
    .calculator-stack {
        flex-direction: column;
    }
}



.calc-panel {
    flex: 1;
    background: var(--card);
    border: 1px solid var(--border);
    border-top: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 0.625rem;
}

.calc-column > .calc-panel {
    flex: 0 0 auto;
}

.calc-panel-header {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted-foreground);
    margin-bottom: 0.5rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--border);
}

.calc-panel .form-group {
    margin-bottom: 0.375rem;
}

.calc-panel .form-group label {
    font-size: 0.625rem;
    margin-bottom: 0.125rem;
}

.calc-panel .form-group input,
.calc-panel .form-group select {
    padding: 0.25rem 0.375rem;
    font-size: 0.75rem;
    height: auto;
}

.calc-input-sm {
    margin-bottom: 0.25rem;
}

.unit-toggle {
    display: flex;
    gap: 0.125rem;
}

.unit-option {
    cursor: pointer;
    display: flex;
}

.unit-option input[type="radio"] {
    display: none;
}

.unit-option span {
    padding: 0.2rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--muted-foreground);
    transition: all 0.15s ease;
    cursor: pointer;
}

.unit-option input[type="radio"]:checked+span {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.calc-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.calc-dims-inline {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}

.calc-dims-inline input {
    width: 100%;
    padding: 0.25rem 0.375rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--foreground);
}

.dim-quick-btns {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.btn-dim-quick {
    padding: 0.15rem 0.3rem;
    font-size: 0.625rem;
    font-weight: 600;
    background: var(--secondary);
    color: var(--muted-foreground);
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    flex: 1;
}

.btn-dim-quick:hover {
    background: var(--accent);
    color: var(--foreground);
    border-color: var(--primary);
}

.cutting-method-toggle {
    display: flex;
    gap: 0.375rem;
    width: 100%;
}

.btn-toggle-method {
    flex: 1;
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--muted-foreground);
    cursor: pointer;
    transition: var(--transition);
}

.btn-toggle-method.active {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.btn-toggle-method.active[onclick*="setCuttingMethod(2, '8')"],
.btn-toggle-method.active[onclick*="setCuttingMethod(3, '8')"] {
    background: #f97316; /* Orange highlight for Fibre Laser in CC2 & CC3 */
    color: #ffffff;
    border-color: #ea580c;
}

.btn-toggle-method:hover:not(.active) {
    background: var(--accent);
    color: var(--foreground);
    border-color: var(--primary);
}

.calc-x {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted-foreground);
    flex-shrink: 0;
}

.calc-results-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.375rem;
    padding-top: 0.375rem;
    border-top: 1px solid var(--border);
}

.calc-chip {
    font-size: 0.625rem;
    font-weight: 500;
    color: var(--muted-foreground);
    background: var(--secondary);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius);
}

.calc-chip b {
    color: var(--foreground);
    font-weight: 700;
    margin-left: 0.125rem;
}

.calc-chip-price {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 700;
}

.calc-chip-price span {
    font-weight: 700;
}

/* ===========================
   Cutting Fees Calculator
   =========================== */
.cutting-calculator-section {
    grid-column: 1 / -1;
    margin-top: 0.25rem;
}

.cutting-tab-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-left: 3px solid #f59e0b;
    border-radius: var(--radius);
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--foreground);
}

.cutting-tab-header:hover {
    background: var(--accent);
    border-color: #f59e0b;
}

.cutting-toggle-arrow {
    font-size: 0.625rem;
    color: var(--muted-foreground);
    transition: transform 0.2s ease;
}

.cutting-toggle-arrow.open {
    transform: rotate(90deg);
}

.cutting-calc-body {
    padding-top: 0.5rem;
}

.cutting-calc-stack {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 900px) {
    .cutting-calc-stack {
        flex-direction: column;
    }
}

.cutting-panel {
    border-top-color: #f59e0b !important;
}

.cutting-formula {
    margin-top: 0.5rem;
    padding: 0.5rem 0.625rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.6875rem;
    color: var(--muted-foreground);
    line-height: 1.5;
    word-break: break-all;
    min-height: 2.5rem;
}

.cutting-price {
    margin-top: 0.375rem;
    padding: 0.375rem 0.625rem;
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    font-size: 0.8125rem;
    font-weight: 700;
    border-radius: var(--radius);
    text-align: right;
}

.cutting-price-row {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.cutting-price-row .cutting-price {
    flex: 1;
}

/* Copy-to-Price Button */
.btn-copy-price {
    padding: 0.2rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: var(--primary);
    background: var(--primary-light);
    border: 1px solid rgba(237, 26, 59, 0.25);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-copy-price:hover {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.btn-copy-price.copied {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
}

/* ===========================
   Pagination Controls
   =========================== */
.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 0;
    flex-wrap: wrap;
}

.pagination-btn {
    background: var(--secondary);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Inter', sans-serif;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.pagination-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    padding: 0 0.5rem;
}

/* ===========================
   Material Order Tags
   =========================== */
.material-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    margin: 0.125rem 0;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.6875rem;
    line-height: 1.3;
    color: var(--foreground);
}

.material-tag .mat-name {
    font-weight: 600;
    color: var(--foreground);
}

.material-tag .mat-detail {
    color: var(--muted-foreground);
}

.material-tag .mat-qty {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.125rem 0.375rem;
    border-radius: calc(var(--radius) * 10);
    font-weight: 700;
    font-size: 0.625rem;
    margin-left: 0.125rem;
}

.materials-cell {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* ===========================
   Material Orders Table Override
   =========================== */
#materialOrderTable {
    table-layout: auto;
}

#materialOrderTable th,
#materialOrderTable td {
    white-space: nowrap;
}

#materialOrderTable td:nth-child(5) {
    white-space: normal;
    min-width: 200px;
}

#materialOrderTable td:nth-child(10) {
    white-space: normal;
    max-width: 150px;
}

/* ===========================
   Invoice Table Override
   =========================== */
#invoiceTable {
    table-layout: auto;
}

#invoiceTable th,
#invoiceTable td {
    white-space: nowrap;
    padding: 0.5rem 0.5rem;
}

#invoiceTable td:nth-child(6) {
    white-space: normal;
}

/* Compact email column */
#invoiceTable td:nth-child(2) {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.625rem;
}

/* ===========================
   Calculator Accumulator and Frequent Materials
   =========================== */

/* Frequent Materials */
.frequent-materials-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border);
}

.btn-frequent-material {
    background: var(--secondary);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-family: 'Inter', sans-serif;
}

.btn-frequent-material:hover {
    background: var(--accent);
    border-color: var(--primary);
    color: var(--foreground);
}

.btn-frequent-material.active {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

/* Accumulator Panel */
.accumulator-panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.accumulator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--foreground);
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.375rem;
}

.accumulator-list {
    max-height: 140px;
    overflow-y: auto;
    font-size: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    padding-right: 0.25rem;
}

.accumulator-list > div {
    background: var(--card);
    border-radius: var(--radius);
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.accumulator-list > div:hover {
    transform: translateX(2px);
    background: var(--secondary);
    border-color: rgba(237, 26, 59, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.accumulator-item-remove {
    background: transparent;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    font-size: 1.125rem;
    line-height: 1;
    padding: 0 0.25rem;
    transition: color 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.accumulator-item-remove:hover {
    color: var(--destructive);
}

.accumulator-empty {
    color: var(--muted-foreground);
    text-align: center;
    padding: 0.5rem;
    font-size: 0.6875rem;
    font-style: italic;
}

.accumulator-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    border-top: 1px solid var(--border);
    padding-top: 0.375rem;
    margin-top: 0.25rem;
}

/* Button additions */
.btn-add-acc {
    padding: 0.2rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: var(--foreground);
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-add-acc:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

/* Collapsible Sub-panels */
.cutting-toggle-arrow {
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 0.625rem;
    margin-left: 0.375rem;
    color: var(--muted-foreground);
}

.cutting-toggle-arrow.open {
    transform: rotate(90deg);
}

/* Compact layout helpers */
.cutting-calc-stack {
    display: flex;
    gap: 0.75rem;
}

@media (max-width: 900px) {
    .cutting-calc-stack {
        flex-direction: column;
    }
}

/* Table Filter Styles */
.table-filter-select,
.table-filter-input {
    padding: 0.375rem 0.75rem;
    background: var(--background);
    border: 1px solid var(--input);
    border-radius: var(--radius);
    color: var(--foreground);
    font-size: 0.8125rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.15s ease;
    height: 36px;
    box-sizing: border-box;
}

.table-filter-select:focus,
.table-filter-input:focus {
    border-color: var(--primary);
}

.table-filter-input {
    width: 160px;
}
