/* ═══════════════════════════════════════════════════════════════
   TRITHER SLU - Billing System Design System
   Elegant, Subtle, Professional
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
    --primary: #1a365d;
    --primary-light: #2a4a7f;
    --primary-lighter: #3d6098;
    --primary-50: rgba(26, 54, 93, 0.05);
    --primary-100: rgba(26, 54, 93, 0.1);

    --accent: #2b6cb0;
    --accent-light: #3182ce;
    --accent-glow: rgba(43, 108, 176, 0.15);

    --success: #276749;
    --success-bg: #f0fff4;
    --warning: #c05621;
    --warning-bg: #fffaf0;
    --danger: #c53030;
    --danger-bg: #fff5f5;
    --info: #2b6cb0;
    --info-bg: #ebf8ff;

    --bg-body: #f7f8fc;
    --bg-sidebar: #0f172a;
    --bg-card: #ffffff;
    --bg-input: #f8fafc;

    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #a0aec0;
    --text-inverse: #e2e8f0;

    --border: #e2e8f0;
    --border-focus: #3182ce;
    --border-light: #edf2f7;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 6px 10px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 50px rgba(0,0,0,0.1);

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --sidebar-width: 260px;
    --header-height: 64px;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── Login Screen ──────────────────────────────────────────── */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1a365d 100%);
    position: relative;
    overflow: hidden;
}

.login-screen::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(43,108,176,0.15), transparent 70%);
    top: -200px; right: -100px;
    border-radius: 50%;
}

.login-screen::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(43,108,176,0.1), transparent 70%);
    bottom: -100px; left: -50px;
    border-radius: 50%;
}

.login-card {
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 420px;
    position: relative;
    z-index: 1;
    box-shadow: 0 25px 80px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo h1 {
    color: #fff;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.login-logo span {
    color: var(--accent-light);
}

.login-logo p {
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    margin-top: 6px;
    font-weight: 300;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.login-field {
    margin-bottom: 20px;
}

.login-field label {
    display: block;
    color: rgba(255,255,255,0.6);
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.login-field input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius);
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    outline: none;
}

.login-field input:focus {
    border-color: var(--accent-light);
    background: rgba(255,255,255,0.08);
    box-shadow: 0 0 0 3px rgba(49,130,206,0.15);
}

.login-field input::placeholder {
    color: rgba(255,255,255,0.25);
}

.login-btn {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
    letter-spacing: 0.3px;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 25px rgba(43,108,176,0.35);
}

.login-error {
    background: rgba(197,48,48,0.15);
    border: 1px solid rgba(197,48,48,0.3);
    color: #feb2b2;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

.login-hint {
    text-align: center;
    margin-top: 24px;
    color: rgba(255,255,255,0.3);
    font-size: 12px;
}

.login-hint code {
    color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.06);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
}

/* ─── App Layout ────────────────────────────────────────────── */
.app-container {
    display: none;
    min-height: 100vh;
}

.app-container.active { display: flex; }

/* ─── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    height: 100vh;
    position: fixed;
    left: 0; top: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition-slow);
    border-right: 1px solid rgba(255,255,255,0.05);
}

.sidebar-brand {
    padding: 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand h2 {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-brand h2 span { color: var(--accent-light); }

.sidebar-brand p {
    color: rgba(255,255,255,0.35);
    font-size: 11px;
    margin-top: 2px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

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

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

.nav-section-title {
    color: rgba(255,255,255,0.3);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: rgba(255,255,255,0.55);
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.85);
}

.nav-item.active {
    background: rgba(43,108,176,0.2);
    color: #90cdf4;
}

.nav-item svg {
    width: 18px; height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    transition: var(--transition);
}

.sidebar-user:hover {
    background: rgba(255,255,255,0.04);
}

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

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

.user-info .name {
    color: rgba(255,255,255,0.85);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .role {
    color: rgba(255,255,255,0.35);
    font-size: 11px;
    text-transform: capitalize;
}

.logout-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.3);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.logout-btn:hover {
    color: #fc8181;
    background: rgba(252,129,129,0.1);
}

/* ─── Main Content ──────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.top-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content-area {
    padding: 32px;
}

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body { padding: 24px; }

/* ─── Stats Cards (Dashboard) ───────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: #ebf8ff; color: #2b6cb0; }
.stat-icon.green { background: #f0fff4; color: #276749; }
.stat-icon.orange { background: #fffaf0; color: #c05621; }
.stat-icon.purple { background: #faf5ff; color: #6b46c1; }

.stat-info h4 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(43,108,176,0.3);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: #edf2f7;
    color: var(--text-primary);
}

.btn-success {
    background: linear-gradient(135deg, #276749, #38a169);
    color: #fff;
}
.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(39,103,73,0.3);
}

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(197,48,48,0.2);
}
.btn-danger:hover {
    background: #fed7d7;
}

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon {
    width: 36px; height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* ─── Form Elements ─────────────────────────────────────────── */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.form-select, .form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
    appearance: none;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a0aec0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-select:focus, .form-input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(49,130,206,0.1);
    background-color: #fff;
}

.form-row {
    display: grid;
    gap: 16px;
}

.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

/* ─── Data Table (Excel-like) ───────────────────────────────── */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    gap: 12px;
    flex-wrap: wrap;
}

.table-search {
    position: relative;
    flex: 1;
    max-width: 320px;
}

.table-search input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.table-search input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(49,130,206,0.1);
}

.table-search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--text-muted);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-input);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: var(--transition);
}

.data-table th:hover {
    background: #edf2f7;
    color: var(--text-primary);
}

.data-table th .sort-icon {
    display: inline-block;
    margin-left: 4px;
    opacity: 0.3;
    font-size: 10px;
}

.data-table th.sorted .sort-icon { opacity: 1; color: var(--accent); }

.data-table td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    transition: var(--transition);
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--primary-50);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table .cell-editable {
    cursor: pointer;
    position: relative;
}

.data-table .cell-editable:hover {
    background: var(--accent-glow);
}

.data-table .cell-editing {
    padding: 4px 8px;
}

.data-table .cell-editing input,
.data-table .cell-editing select {
    width: 100%;
    padding: 6px 10px;
    border: 2px solid var(--border-focus);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: #fff;
}

.table-actions {
    display: flex;
    gap: 6px;
}

.table-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-secondary);
}

.pagination-btns {
    display: flex;
    gap: 4px;
}

.pagination-btns button {
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.pagination-btns button:hover {
    background: var(--primary-50);
    border-color: var(--accent);
    color: var(--accent);
}

.pagination-btns button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ─── Status Badges ─────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-pending { background: #fefcbf; color: #975a16; }
.badge-completed { background: #c6f6d5; color: #22543d; }
.badge-invoiced { background: #bee3f8; color: #2a4365; }
.badge-cancelled { background: #fed7d7; color: #9b2c2c; }

/* ─── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.97);
    transition: var(--transition-slow);
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ─── Albaran / Factura Preview ─────────────────────────────── */
.doc-preview {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 800px;
    margin: 0 auto;
    box-shadow: var(--shadow-md);
}

.doc-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--primary);
}

.doc-company h2 {
    font-size: 22px;
    color: var(--primary);
    font-weight: 700;
}

.doc-company p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.doc-number {
    text-align: right;
}

.doc-number h3 {
    font-size: 18px;
    color: var(--primary);
    font-weight: 600;
}

.doc-number p {
    font-size: 13px;
    color: var(--text-secondary);
}

.doc-parties {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-bottom: 32px;
}

.doc-party h4 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.doc-party p {
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.doc-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.doc-items-table th {
    padding: 10px 12px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
}

.doc-items-table th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.doc-items-table th:last-child { border-radius: 0 var(--radius-sm) 0 0; text-align: right; }

.doc-items-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.doc-items-table td:last-child { text-align: right; }

.doc-totals {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 32px;
}

.doc-totals table {
    width: 280px;
    border-collapse: collapse;
}

.doc-totals td {
    padding: 8px 12px;
    font-size: 13px;
}

.doc-totals td:last-child {
    text-align: right;
    font-weight: 500;
}

.doc-totals tr.total {
    border-top: 2px solid var(--primary);
}

.doc-totals tr.total td {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    padding-top: 12px;
}

.doc-footer {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* ─── Line Items Editor ─────────────────────────────────────── */
.line-items {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 20px;
}

.line-items-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 1px;
    background: var(--bg-input);
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.line-items-header span {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.line-item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    align-items: center;
}

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

.line-item-row select, .line-item-row input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-input);
    outline: none;
    transition: var(--transition);
}

.line-item-row select:focus, .line-item-row input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(49,130,206,0.1);
}

.line-item-total {
    font-weight: 600;
    color: var(--text-primary);
    text-align: right;
    min-width: 80px;
}

.line-item-remove {
    width: 28px; height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.line-item-remove:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.add-line-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    width: 100%;
    border: 1px dashed var(--border);
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    border-radius: 0 0 var(--radius) var(--radius);
    transition: var(--transition);
}

.add-line-btn:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

/* ─── Tabs ──────────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0;
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* ─── Profile ───────────────────────────────────────────────── */
.profile-card {
    max-width: 560px;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    border-bottom: 1px solid var(--border-light);
}

.profile-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
    font-weight: 700;
}

.profile-name h3 {
    font-size: 20px;
    font-weight: 600;
}

.profile-name p {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 2px;
}

/* ─── Empty State ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 56px; height: 56px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h4 {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 13px;
    max-width: 320px;
    margin: 0 auto;
}

/* ─── Toast Notifications ───────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toastIn 0.3s ease;
    max-width: 360px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ─── Print Styles ──────────────────────────────────────────── */
@media print {
    .sidebar, .top-header, .table-toolbar, .table-pagination,
    .btn, .modal-overlay, .toast-container { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-area { padding: 0 !important; }
    .doc-preview { box-shadow: none; border: none; padding: 20px; }
    body { background: #fff; }
}

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .form-row.cols-3 { grid-template-columns: 1fr 1fr; }
    .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 {
        grid-template-columns: 1fr;
    }
    .doc-parties { grid-template-columns: 1fr; }
    .line-items-header, .line-item-row {
        grid-template-columns: 1fr;
    }
}

/* ─── Animations ────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-section {
    animation: fadeIn 0.3s ease;
}

/* ─── Confirm Dialog ────────────────────────────────────────── */
.confirm-dialog {
    max-width: 400px;
    text-align: center;
}

.confirm-dialog .modal-body {
    padding: 32px 24px;
}

.confirm-dialog .confirm-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    background: var(--danger-bg);
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.confirm-dialog h4 {
    font-size: 16px;
    margin-bottom: 8px;
}

.confirm-dialog p {
    color: var(--text-secondary);
    font-size: 13px;
}
