*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99,102,241,.08);
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #94a3b8;
    --border: #e2e8f0;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --info: #3b82f6;
    --info-light: #eff6ff;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.03);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.08);
    --transition: .2s cubic-bezier(.4,0,.2,1);
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* === Layout === */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 50%, #3730a3 100%);
    color: #fff;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sidebar::-webkit-scrollbar { display: none; }
.sidebar-brand {
    font-size: 1.3rem;
    font-weight: 800;
    padding: 1.5rem 1.5rem 1.25rem;
    letter-spacing: -.025em;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background: rgba(0,0,0,.1);
}
.sidebar-nav { flex: 1; padding: .75rem 0; }
.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .6rem 1.5rem;
    color: rgba(255,255,255,.6);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
    margin: 1px 0;
}
.sidebar-nav a:hover {
    background: rgba(255,255,255,.06);
    color: rgba(255,255,255,.9);
}
.sidebar-nav a.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-left-color: #818cf8;
    font-weight: 600;
}
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: .8rem;
    color: rgba(255,255,255,.5);
    background: rgba(0,0,0,.1);
}
.sidebar-footer button {
    background: none; border: none; color: rgba(255,255,255,.6);
    cursor: pointer; font-size: .8rem; text-decoration: underline;
    transition: var(--transition);
}
.sidebar-footer button:hover { color: #fff; }

.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    max-width: 1400px;
    height: 100vh;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.main-content::-webkit-scrollbar { width: 0; height: 0; display: none;}

/* === Auth === */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #312e81 0%, #6366f1 50%, #818cf8 100%);
}
.auth-card {
    background: var(--card);
    border-radius: 16px;
    padding: 2.75rem 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,.2);
}
.auth-card h1 {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -.025em;
    margin-bottom: .25rem;
}
.auth-card p.subtitle {
    color: var(--muted);
    font-size: .9rem;
    margin-bottom: 2rem;
}

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    margin-bottom: .4rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: .65rem .85rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    background: #fff;
    color: var(--text);
    transition: var(--transition);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group input::placeholder { color: var(--muted); }

/* ── Field validation ────────────────────────────────── */
.form-group input.is-invalid,
.form-group select.is-invalid,
.form-group textarea.is-invalid {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 3px rgba(239,68,68,.12);
}
.field-error {
    display: block;
    color: var(--danger);
    font-size: .78rem;
    margin-top: .25rem;
}

.form-row {
    display: flex;
    gap: .5rem;
    align-items: flex-end;
    margin-bottom: .5rem;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .6rem 1.25rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 600;
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: var,--transition);
    background: #fff;
    color: var(--text);
    white-space: nowrap;
}
.btn:hover { background: var(--bg); border-color: #cbd5e1; }
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); box-shadow: var(--shadow-md); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; border-color: #059669; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; border-radius: 8px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* === Alerts === */
.alert {
    padding: .75rem 1rem;
    border-radius: var(--radius);
    font-size: .85rem;
    margin-bottom: 1rem;
    font-weight: 500;
}
.alert-error { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-info { background: var(--info-light); color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.toast-success {
    background: var(--success) !important;
}

/* === Page Header === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: .75rem;
}
.page-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.025em;
    color: var(--text);
}
.page-header > div { display: flex; gap: .5rem; flex-wrap: wrap; }

/* === Tables === */
.table-wrap {
    background: var(--card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: visible;
    box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem 1rem; font-size: .9rem; }
th {
    background: #f8fafc;
    font-weight: 700;
    color: var(--text-secondary);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 2px solid var(--border);
}
tr:not(:last-child) td { border-bottom: 1px solid #f1f5f9; }
tr:hover td { background: #fafbfd; }

/* === Cards === */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow); }
.card h3 {
    font-size: .8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin-bottom: .5rem;
}

/* === Stat Cards === */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 3px;
}
.stat-card.stat-primary::before { background: linear-gradient(90deg, var(--primary), #818cf8); }
.stat-card.stat-success::before { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card.stat-warning::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stat-card.stat-danger::before { background: linear-gradient(90deg, var(--danger), #f87171); }
.stat-card.stat-info::before { background: linear-gradient(90deg, var(--info), #60a5fa); }
.stat-card .stat-label {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin-bottom: .35rem;
}
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -.03em;
    color: var(--text);
    line-height: 1.2;
}
.stat-card .stat-sub {
    font-size: .8rem;
    color: var(--muted);
    margin-top: .25rem;
}

/* === Section Header === */
.section-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* === Bar Chart === */
.bar-chart { display: flex; flex-direction: column; gap: .5rem; }
.bar-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: .85rem;
}
.bar-label {
    width: 100px;
    flex-shrink: 0;
    text-align: right;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: .8rem;
}
.bar-track {
    flex: 1;
    height: 28px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}
.bar-fill {
    height: 100%;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--primary), #818cf8);
    transition: width .6s cubic-bezier(.4,0,.2,1);
    min-width: 2px;
    display: flex;
    align-items: center;
    padding: 0 .5rem;
}
.bar-fill-success { background: linear-gradient(90deg, var(--success), #34d399); }
.bar-fill-warning { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.bar-fill-danger { background: linear-gradient(90deg, var(--danger), #f87171); }
.bar-fill-info { background: linear-gradient(90deg, var(--info), #60a5fa); }
.bar-value {
    font-size: .75rem;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.bar-value-outside {
    margin-left: .5rem;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* === Tabs === */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.tab-bar::-webkit-scrollbar { width: 0; height: 0; display: none; }
.tab-btn {
    padding: .65rem 1.25rem;
    font-size: .875rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    white-space: nowrap;
}
.tab-btn:hover { color: var(--text-secondary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* === Modal === */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.5);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    animation: fadeIn .15s ease;
}
.modal {
    background: var(--card);
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    max-width: min(520px, 96vw);
    max-height: 90dvh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0,0,0,.15);
    animation: slideUp .2s ease;
    contain: paint;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
}
.modal::-webkit-scrollbar { display: none; }

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: #f1f5f9;
    color: var(--text-secondary);
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
    flex-shrink: 0;
    z-index: 10;
}
.modal-close:hover { background: #e2e8f0; color: var(--text); }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: translateY(0) } }

.hidden { display: none !important; }

/* === Badge === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 6px;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fef2f2; color: var(--danger); }
.badge-info { background: #eff6ff; color: #1e40af; }
.badge-warning { background: #fffbeb; color: #92400e; }

/* === Upload === */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    color: var(--muted);
    cursor: pointer;
    transition: var(--transition);
    background: #fafbfd;
}
.upload-zone:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.upload-zone.dragging,
.upload-area.dragging {
    border-color: var(--primary);
    background: var(--primary-light);
    opacity: 1;
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 999;
        width: 280px;
    }
    .sidebar.sidebar-open { display: flex; }
    .mobile-header { display: flex !important; margin-bottom: 1rem; }
    .main-content { padding: 1rem; }
    .stat-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* === Billing items grid === */
.bl-item input {
    padding: .4rem .5rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .85rem;
}

/* === Notification card === */
.card[style*="border-left"] { transition: background var(--transition); }
.card[style*="border-left"]:hover { background: #fafbfd; }

/* === Contract content === */
.contract-content h2, .contract-content h3, .contract-content h4 { margin-top: 1rem; margin-bottom: .5rem; }
.contract-content p { margin-bottom: .5rem; line-height: 1.6; }
.contract-content hr { margin: 1rem 0; border: none; border-top: 1px solid var(--border); }
.contract-content table { width: 100%; border-collapse: collapse; margin: .75rem 0; }
.contract-content table th, .contract-content table td { padding: 6px 10px; border: 1px solid var(--border); font-size: .875rem; }
.contract-content table th { background: #f8fafc; font-weight: 600; }
.contract-content img { max-width: 100%; }

code {
    background: #f1f5f9;
    padding: .15rem .4rem;
    border-radius: 4px;
    font-size: .8rem;
    color: var(--primary);
}

/* === Two-column layout === */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* === Donut legend === */
.legend { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .75rem; }
.legend-item { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--text-secondary); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state-icon {
    font-size: 2.5rem;
    margin-bottom: .75rem;
    opacity: .6;
}
.empty-state p {
    margin: .25rem 0;
    font-size: .95rem;
}

/* ── Spinner / page loading ─────────────────────────── */
@keyframes spin {
    to { transform: rotate(360deg); }
}
.spinner {
    display: inline-block;
    width: 2rem;
    height: 2rem;
    border: 3px solid rgba(99,102,241,.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.page-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4rem 2rem;
}
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn-loading::after {
    content: '';
    position: absolute;
    inset: 50% 50%;
    width: 1em;
    height: 1em;
    margin: -.5em 0 0 -.5em;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

/* === Template Editor === */
.tpl-editor-wrap {
    display: flex;
    flex-direction: column;
    gap: .75rem;
}
.tpl-editor-toolbar {
    display: flex;
    gap: .25rem;
    flex-wrap: wrap;
    padding: .4rem .5rem;
    background: #f8fafc;
    border: 1.5px solid var(--border);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}
.tpl-editor-toolbar button {
    padding: .3rem .55rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    line-height: 1;
}
.tpl-editor-toolbar button:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.tpl-editor-toolbar .sep { width: 1px; background: var(--border); margin: 0 .25rem; }
.tpl-editor-body {
    min-height: 280px;
    max-height: 420px;
    overflow-y: auto;
    padding: 1rem;
    border: 1.5px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    background: #fff;
    font-size: .9rem;
    line-height: 1.6;
    outline: none;
}
.tpl-editor-body:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.tpl-editor-body table { width: 100%; border-collapse: collapse; margin: .5rem 0; }
.tpl-editor-body table th, .tpl-editor-body table td { padding: 4px 8px; border: 1px solid var(--border); }
.tpl-editor-body img { max-width: 100%; }
.tpl-tags-panel {
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: .75rem;
    background: #fafbfd;
}
.tpl-tags-panel h5 {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin-bottom: .5rem;
}
.tpl-tags-group { margin-bottom: .6rem; }
.tpl-tags-group-label {
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: .3rem;
}
.tpl-tag {
    display: inline-flex;
    align-items: center;
    padding: .2rem .5rem;
    margin: .15rem;
    border-radius: 4px;
    font-size: .72rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
    cursor: grab;
    user-select: none;
    transition: var(--transition);
    white-space: nowrap;
}
.tpl-tag:active { cursor: grabbing; }
.tpl-tag.tag-company { background: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe; }
.tpl-tag.tag-client { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.tpl-tag.tag-package { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.tpl-tag.tag-signature { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.tpl-tag.tag-field { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.tpl-tag:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.tpl-tag.dragging { opacity: .5; }
.tpl-mode-toggle {
    display: flex;
    gap: 0;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: .78rem;
}
.tpl-mode-toggle button {
    padding: .35rem .75rem;
    border: none;
    background: #fff;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
}
.tpl-mode-toggle button.active { background: var(--primary); color: #fff; }
.tpl-mode-toggle button:not(.active):hover { background: var(--bg); }

/* Fullscreen editor modal */
.modal-fullscreen {
    position: fixed;
    inset: 0;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    height: 100%;
    border-radius: 0;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    animation: none;
}
.modal-fullscreen .tpl-editor-body {
    min-height: 0;
    max-height: none;
    flex: 1;
    overflow-y: auto;
}
.modal-fullscreen .tpl-editor-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.modal-fullscreen .tpl-editor-wrap > div:has(.tpl-editor-toolbar) ,
.modal-fullscreen #ct-editor-visual-wrap,
.modal-fullscreen #et-editor-visual-wrap,
.modal-fullscreen #edc-editor-visual-wrap,
.modal-fullscreen [id$="-visual-wrap"] {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.modal-fullscreen .form-group:has(.tpl-editor-wrap) {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.modal-fullscreen .form-group:has(.tpl-editor-wrap) > label { flex-shrink: 0; }
.tpl-fullscreen-btn {
    padding: .3rem .6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition);
    margin-left: .5rem;
}
.tpl-fullscreen-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* Sign-modal tabs & live preview */
.sc-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1rem; }
.sc-tab-btn {
    padding: .55rem 1rem;
    font-size: .82rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: var(--transition);
    white-space: nowrap;
}
.sc-tab-btn:hover { color: var(--text-secondary); }
.sc-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.sc-preview-pane {
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    background: #fff;
    max-height: 60vh;
    overflow-y: auto;
    font-size: .88rem;
    line-height: 1.6;
}
.sc-preview-pane .sc-ph {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    border: 1px dashed #fbbf24;
    border-radius: 4px;
    padding: .1rem .4rem;
    font-size: .8rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', monospace;
    vertical-align: baseline;
}
.sc-preview-pane .sc-ph-filled {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

/* === DataTable toolbar === */
.dt-wrap { }
.dt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.dt-toolbar-left, .dt-toolbar-right { display: flex; align-items: center; gap: .5rem; }
.dt-search {
    padding: .4rem .75rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .82rem;
    min-width: 120px;
    max-width: 220px;
    flex: 1 1 120px;
    background: #fff;
    color: var(--text);
    transition: var(--transition);
}
.dt-search:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.dt-search::placeholder { color: var(--muted); }
.dt-page-size {
    padding: .38rem .6rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .82rem;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
}
.dt-page-size:focus { outline: none; border-color: var(--primary); }
.dt-count {
    font-size: .78rem;
    color: var(--muted);
    white-space: nowrap;
}
.dt-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
    padding: .65rem 1rem;
    border-top: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.dt-pagination { display: flex; gap: .3rem; align-items: center; flex-wrap: wrap; }
.dt-page-btn {
    padding: .3rem .65rem;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 600;
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    min-width: 30px;
    text-align: center;
}
.dt-page-btn:hover:not(:disabled) { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.dt-page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.dt-page-btn:disabled { opacity: .4; cursor: not-allowed; }
/* Sortable column headers */
.dt-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.dt-sortable:hover { color: var(--primary); }
.dt-sort-icon {
    display: inline-block;
    margin-left: .3rem;
    font-size: .65rem;
    opacity: .4;
    vertical-align: middle;
}
.dt-sortable.asc .dt-sort-icon,
.dt-sortable.desc .dt-sort-icon { opacity: 1; color: var(--primary); }
.dt-no-results td {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--muted);
    font-style: italic;
}

/* === Action dropdown (tweaked for compact neatness) === */
.action-dropdown { position: relative; display: inline-block; }
.action-dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px; /* smaller radius */
    box-shadow: 0 6px 20px rgba(15,23,42,.12);
    min-width: 160px;
    z-index: 3000;
    padding: .25rem 0; /* compact padding */
}
.action-dropdown-menu.open { display: block; }
.action-dropdown-menu a,
.action-dropdown-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: .45rem .9rem; /* slightly tighter */
    background: none;
    border: none;
    font-size: .9rem; /* slightly larger for readability */
    color: #0f172a;
    cursor: pointer;
    white-space: nowrap;
}
.action-dropdown-menu a { text-decoration: none; }
.action-dropdown-menu a button { width: 100%; padding: 0; border: none; background: none; }
.action-dropdown-menu button:hover,
.action-dropdown-menu a:hover { background: #f8fafc; }
.action-dropdown-menu button.danger { color: #ef4444; font-weight:600; }
.action-dropdown-menu button.success { color: #059669; font-weight:600; }
.action-dropdown-menu .dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: .25rem 0;
}
.action-dropdown-toggle {
    padding: .25rem .6rem;
    font-size: .9rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    box-shadow: none;
}
.action-dropdown-toggle.btn { /* keep small button look consistent */
    padding: .25rem .6rem;
}

/* ensure dropdown won't be visually clipped by modal rounded corners */
/* overflow-y:auto is set on .modal above; dropdowns escape via z-index */

@media print {
    .sidebar, .mobile-header { display: none !important; }
    .main-content { height: auto; overflow: visible; padding: 0; max-width: 100%; }
    .app { display: block; }
    body { overflow: visible; height: auto; background: #fff; }
    .page-header > div { display: none; }
    .card { box-shadow: none; border: 1px solid #e2e8f0; }
    .table-wrap { box-shadow: none; }
}

/* === Dark Mode === */
[data-theme="dark"] {
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --muted: #64748b;
    --border: #334155;
    --primary-light: rgba(99,102,241,.2);
    --danger-light: rgba(239,68,68,.15);
    --success-light: rgba(16,185,129,.15);
    --warning-light: rgba(245,158,11,.15);
    --info-light: rgba(59,130,246,.15);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow: 0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 6px rgba(0,0,0,.5);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.6);
}
[data-theme="dark"] body { color-scheme: dark; }
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea { background: #0f172a; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .btn { background: #1e293b; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .btn:hover { background: #283548; border-color: #475569; }
[data-theme="dark"] .btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
[data-theme="dark"] .btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
[data-theme="dark"] .btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
[data-theme="dark"] .btn-success { background: var(--success); color: #fff; border-color: var(--success); }
[data-theme="dark"] th { background: #0f172a; color: var(--text-secondary); border-bottom-color: var(--border); }
[data-theme="dark"] tr:not(:last-child) td { border-bottom-color: #1a2840; }
[data-theme="dark"] tr:hover td { background: #1a2840; }
[data-theme="dark"] .dt-toolbar { background: #0f172a; border-bottom-color: var(--border); }
[data-theme="dark"] .dt-footer { background: #0f172a; border-top-color: var(--border); }
[data-theme="dark"] .dt-search { background: #1e293b; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .dt-page-size { background: #1e293b; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .dt-page-btn { background: #1e293b; color: var(--text-secondary); border-color: var(--border); }
[data-theme="dark"] .dt-page-btn.active { background: var(--primary); color: #fff; }
[data-theme="dark"] .auth-card { background: var(--card); }
[data-theme="dark"] .auth-card .form-group input { background: #0f172a; }
[data-theme="dark"] .badge-success { background: rgba(16,185,129,.2); color: #6ee7b7; }
[data-theme="dark"] .badge-danger { background: rgba(239,68,68,.2); color: #fca5a5; }
[data-theme="dark"] .badge-info { background: rgba(59,130,246,.2); color: #93c5fd; }
[data-theme="dark"] .badge-warning { background: rgba(245,158,11,.2); color: #fcd34d; }
[data-theme="dark"] .upload-zone { background: #1a2840; }
[data-theme="dark"] code { background: #283548; }
[data-theme="dark"] .bar-track { background: #283548; }
[data-theme="dark"] .tpl-editor-toolbar { background: #0f172a; }
[data-theme="dark"] .tpl-editor-toolbar button { background: #1e293b; color: var(--text-secondary); border-color: var(--border); }
[data-theme="dark"] .tpl-editor-body { background: #0f172a; color: var(--text); }
[data-theme="dark"] .tpl-tags-panel { background: #0f172a; }
[data-theme="dark"] .tpl-mode-toggle button { background: #1e293b; color: var(--text-secondary); }
[data-theme="dark"] .tpl-fullscreen-btn { background: #1e293b; color: var(--text-secondary); border-color: var(--border); }
[data-theme="dark"] .modal-close { background: #283548; color: var(--text-secondary); }
[data-theme="dark"] .modal-close:hover { background: #334155; }
[data-theme="dark"] .action-dropdown-menu { background: #1e293b; border-color: var(--border); }
[data-theme="dark"] .action-dropdown-menu a,
[data-theme="dark"] .action-dropdown-menu button { color: var(--text); }
[data-theme="dark"] .action-dropdown-menu button:hover,
[data-theme="dark"] .action-dropdown-menu a:hover { background: #283548; }
[data-theme="dark"] .action-dropdown-toggle { background: #1e293b; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .sc-preview-pane { background: #0f172a; color: var(--text); }
[data-theme="dark"] .contract-content table th { background: #0f172a; }

/* === Sidebar Search === */
.sidebar-search { padding: .5rem 1rem .25rem; }
.sidebar-search input {
    width: 100%;
    padding: .45rem .75rem;
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,.15);
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.85);
    font-size: .8rem;
    transition: var(--transition);
}
.sidebar-search input::placeholder { color: rgba(255,255,255,.35); }
.sidebar-search input:focus {
    outline: none;
    border-color: rgba(255,255,255,.3);
    background: rgba(255,255,255,.13);
}

/* === Search Results Page === */
.search-category { margin-bottom: 1.5rem; }
.search-category-title {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
    padding: .5rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: .5rem;
}
.search-result-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .85rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    color: var(--text);
}
.search-result-item:hover { background: var(--primary-light); color: var(--primary); }
.search-result-icon { font-size: 1.1rem; flex-shrink: 0; }
.search-result-main { font-weight: 600; font-size: .875rem; }
.search-result-sub { font-size: .78rem; color: var(--muted); margin-top: .1rem; }

/* === Booking Calendar === */
.calendar-table td[data-cal-day]:hover {
    background: var(--primary-light);
    transition: background .15s;
}
.calendar-table td[data-cal-day].selected {
    background: var(--primary-light);
    outline: 2px solid var(--primary);
}
.cal-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cal-dot-green  { background: #22c55e; }
.cal-dot-orange { background: #f59e0b; }
.cal-dot-red    { background: #ef4444; }

.booking-item:hover {
    background: var(--surface-alt, #f8fafc);
    transition: background .15s;
}

.photographer-tabs .btn { transition: all .15s; }

.avail-grid { gap: 1.5rem; }
@media (max-width: 700px) {
    .avail-grid { grid-template-columns: 1fr !important; }
    .calendar-table th, .calendar-table td { font-size: .75rem; padding: .2rem; }
}

/* Tab bar */
.tab-bar {
    display: flex;
    gap: .5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: .5rem;
    flex-wrap: wrap;
}
.tab-btn {
    background: none;
    border: none;
    padding: .5rem 1rem;
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    font-size: .88rem;
    color: var(--muted);
    font-family: inherit;
    transition: color .15s, background .15s;
}
.tab-btn:hover  { color: var(--primary); background: var(--primary-light); }
.tab-btn.active { color: var(--primary); font-weight: 600; border-bottom: 2px solid var(--primary); margin-bottom: -2px; }

