/* ============================================================
   Form Generator & Submitter - Application stylesheet
   ============================================================ */

* { box-sizing: border-box; }

:root {
    --primary: #b08d3e;
    --primary-dark: #8a6d2c;
    --gold: #c9a961;
    --gold-soft: #d4b87a;
    --navy-900: #0a1628;
    --navy-800: #0f1e35;
    --navy-700: #142440;
    --navy-600: #1c3054;
    --sidebar-bg: #0a1628;
    --sidebar-text: rgba(253, 252, 248, 0.72);
    --body-bg: #f7f4ec;
    --card-bg: #fdfcf8;
    --border: #e9e1cf;
    --text: #1a2332;
    --muted: #6b7789;
    --success: #109e79;
    --error: #c4384d;
}

html, body { margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--body-bg);
    background-image:
        radial-gradient(ellipse at 0% 0%, rgba(201, 169, 97, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 100% 100%, rgba(20, 36, 64, 0.06) 0%, transparent 50%);
    line-height: 1.5;
    letter-spacing: -0.011em;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- App layout ---- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 20px; font-size: 16px; font-weight: 700; color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); display: inline-block; }

.sidebar-nav { padding: 12px 0; }
.nav-label { padding: 16px 20px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #64748b; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px; color: var(--sidebar-text); cursor: pointer;
    border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: rgba(37,99,235,.15); color: #fff; border-left-color: var(--primary); }
.nav-item.disabled { opacity: .45; cursor: not-allowed; }
.nav-icon { width: 16px; text-align: center; font-size: 12px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    display: flex; align-items: center; gap: 16px;
    background: var(--card-bg); border-bottom: 1px solid var(--border);
    padding: 12px 20px; position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-name { font-weight: 600; }
.icon-btn {
    background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--text);
    display: none; padding: 4px 8px;
}

.content { padding: 24px; max-width: 1200px; width: 100%; }

.page-title { margin: 0 0 4px; font-size: 22px; }
.page-sub { margin: 0 0 20px; color: var(--muted); }

/* ---- Cards ---- */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 20px; }
.card-header { padding: 14px 18px; font-weight: 600; border-bottom: 1px solid var(--border); }
.card-body { padding: 18px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 20px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
.table-fit th, .table-fit td { padding: 12px 16px; font-size: 13px; white-space: nowrap; vertical-align: middle; }
.table-fit th { font-size: 12px; }

/* ---- RTL (Arabic) ---- */
[dir="rtl"] body { font-family: 'Cairo', 'Inter', system-ui, sans-serif; }
[dir="rtl"] .sidebar { border-right: 0; border-left: 1px solid rgba(201, 169, 97, 0.1); }
[dir="rtl"] .nav-item.active { box-shadow: inset -3px 0 0 var(--gold); }

/* ---- Signature name note + timestamp ---- */
.ff-sig-meta { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.ff-sig-name { width: 100%; max-width: 260px; }
.ff-sig-stamp { font-size: 12px; color: var(--muted); }
.ff-sig-result-name { margin-top: 6px; font-weight: 600; }
.ff-sig-result-stamp { margin-top: 2px; font-size: 12px; color: var(--muted); }

/* ---- QR code generator ---- */
.qr-tools { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.qr-tools-form { flex: 1 1 320px; min-width: 280px; }
.qr-tools-output { flex: 0 0 auto; text-align: center; }
.qr-tools-output canvas { border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.qr-note { margin-top: 8px; font-size: 13px; color: var(--text); }

/* ---- Tools tabs ---- */
.tools-tabs { display: flex; gap: 8px; flex-wrap: wrap; border-bottom: 2px solid var(--border); margin-bottom: 18px; }
.tools-tabs .tab { border: 1px solid var(--border); border-bottom: none; background: var(--body-bg); color: var(--muted); padding: 9px 18px; border-radius: 10px 10px 0 0; cursor: pointer; font-weight: 700; font-size: 14px; font-family: inherit; }
.tools-tabs .tab:hover { color: var(--text); }
.tools-tabs .tab.active { background: var(--card-bg); color: var(--primary-dark); border-color: var(--primary); box-shadow: inset 0 2px 0 var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
table.table { width: 100%; border-collapse: collapse; }
table.table th, table.table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
table.table th { background: #f8fafc; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=time], select, textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; font-family: inherit; background: #fff;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
textarea { min-height: 90px; resize: vertical; }
textarea.ff-textarea-grid {
    line-height: 30px;
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 29px,
        var(--border) 29px,
        var(--border) 30px
    );
    background-attachment: local;
    background-color: #fff;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    background: var(--primary); color: #fff; border: 1px solid var(--primary);
    padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
    text-decoration: none; transition: background .15s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: #f1f5f9; }

/* ---- Alerts ---- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }

/* ---- Auth / guest pages ---- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0f172a, #1e3a8a); padding: 20px; }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card { background: #fff; border-radius: 14px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-brand { font-size: 22px; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.auth-title { margin: 0 0 6px; font-size: 22px; }
.auth-sub { color: var(--muted); margin: 0 0 22px; }
.auth-foot { color: var(--muted); font-size: 12px; text-align: center; margin: 18px 0 0; }
.error-code { font-size: 56px; font-weight: 800; color: var(--primary); line-height: 1; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { position: fixed; left: -260px; transition: left .2s; z-index: 50; }
    .sidebar.open { left: 0; }
    .icon-btn { display: inline-block; }
    .content { padding: 16px; }
    .user-name { display: none; }
}

/* ---- Form builder ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.builder-topbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 16px; }
.builder-topbar input[type=text] { flex: 1; min-width: 140px; }
.builder-topbar select { width: auto; }
.builder-grid { display: grid; grid-template-columns: 220px 1fr 280px; gap: 16px; align-items: start; }
.builder-left, .builder-right { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px; position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
.builder-center { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px; min-height: 400px; }
.builder-section-title { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.field-lib { display: block; width: 100%; text-align: left; padding: 8px 12px; margin-bottom: 6px; background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 13px; }
.field-lib:hover { background: #eef2ff; border-color: var(--primary); }
.builder-empty { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 13px; }
.fb-field { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.fb-field.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.15); }
.fb-field-toolbar { display: flex; justify-content: space-between; align-items: center; background: #f8fafc; padding: 4px 8px; border-bottom: 1px solid var(--border); }
.fb-field-type { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.fb-field-actions button { border: 0; background: none; cursor: pointer; font-size: 14px; padding: 2px 6px; color: #64748b; }
.fb-field-actions button:hover { color: var(--error); }
.fb-field-preview { padding: 12px; }
.fb-preview-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.fb-preview-box { background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 10px; color: var(--muted); font-size: 13px; }
.fb-preview-heading { margin: 0; font-size: 18px; }
.fb-preview-options span { display: inline-block; margin-right: 10px; font-size: 13px; }
label.cb { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.cb input { width: auto; }
@media (max-width: 992px) { .builder-grid { grid-template-columns: 1fr; } .builder-left, .builder-right { position: static; max-height: none; } }

/* ---- Live form fields ---- */
.ff-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.ff-field { grid-column: span 12; }
.ff-w-12 { grid-column: span 12; }
.ff-w-6 { grid-column: span 6; }
.ff-w-4 { grid-column: span 4; }
.ff-w-3 { grid-column: span 3; }
@media screen and (max-width: 768px) { .ff-w-6, .ff-w-4, .ff-w-3 { grid-column: span 12; } }
.ff-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.ff-required { color: #dc2626; }
.ff-help { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.ff-heading { margin: 0; border: 1px solid transparent; border-radius: 8px; }
.ff-heading h3 { margin: 0; padding: 8px 12px; font-weight: 700; line-height: 1.4; }
.ff-options { display: flex; flex-direction: column; gap: 6px; }
.ff-option { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.ff-option input { width: auto; }
.ff-option-text { flex: 1 1 auto; min-width: 0; }

/* Custom tick boxes (checkbox fields) */
.ff-option input.ff-cbox {
    -webkit-appearance: none;
    appearance: none;
    width: var(--cbox-size, 16px);
    height: var(--cbox-size, 16px);
    flex: 0 0 auto;
    margin: 0;
    border: 2px solid var(--cbox-color, var(--primary));
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    position: relative;
    transition: background .12s, border-color .12s, box-shadow .12s;
    vertical-align: middle;
}
.ff-option input.ff-cbox:hover { box-shadow: 0 0 0 3px rgba(201, 169, 97, 0.14); }
.ff-option input.ff-cbox:focus-visible { box-shadow: 0 0 0 3px rgba(201, 169, 97, 0.25); }
.ff-option input.ff-cbox:checked {
    background: var(--cbox-color, var(--primary));
    border-color: var(--cbox-color, var(--primary));
}
.ff-option input.ff-cbox:checked::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46%;
    height: 26%;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: translate(-50%, -62%) rotate(-45deg);
}
.ff-option input.ff-cbox.ff-cbox-round { border-radius: 50%; }
.ff-option input.ff-cbox.ff-cbox-square { border-radius: 2px; }
.ff-option input.ff-cbox.ff-cbox-rounded { border-radius: 4px; }

/* Tick box group + spacing */
.ff-cbox-group { display: inline-flex; align-items: center; gap: var(--cbox-gap, 6px); flex: 0 0 auto; }

/* Tick box column headers (notes above each tick box) */
.ff-cbox-headers { display: flex; align-items: center; gap: 8px; margin: 0 0 2px; }
.ff-cbox-head {
    flex: 0 0 auto;
    width: var(--cbox-size, 16px);
    min-width: var(--cbox-size, 16px);
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    overflow: visible;
}
.ff-cbox-head-spacer { flex: 1 1 auto; }

/* Tick styles (check is the default; cross / dot / fill overrides) */
.ff-option input.ff-cbox.ff-cbox-tick-cross:checked::after,
.ff-cbox-readonly.ff-cbox-tick-cross.is-checked::after {
    content: '\2715';
    border: 0;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 11px;
    line-height: 1;
    font-weight: 700;
}
.ff-option input.ff-cbox.ff-cbox-tick-dot:checked::after,
.ff-cbox-readonly.ff-cbox-tick-dot.is-checked::after {
    content: '';
    border: 0;
    width: 44%;
    height: 44%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 50%;
}
.ff-option input.ff-cbox.ff-cbox-tick-fill:checked::after,
.ff-cbox-readonly.ff-cbox-tick-fill.is-checked::after {
    content: none;
}

/* Day-of-week checkboxes (builder: off days) */
.day-checks { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.day-checks label { font-weight: 400; font-size: 12px; }

/* Read-only tick boxes (re-check / print view) */
.ff-cbox-readonly {
    display: inline-block;
    width: var(--cbox-size, 16px);
    height: var(--cbox-size, 16px);
    flex: 0 0 auto;
    margin: 0;
    border: 2px solid var(--cbox-color, var(--primary));
    border-radius: 4px;
    background: #fff;
    position: relative;
    vertical-align: middle;
}
.ff-cbox-readonly.is-checked {
    background: var(--cbox-color, var(--primary));
    border-color: var(--cbox-color, var(--primary));
}
.ff-cbox-readonly.is-checked::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46%;
    height: 26%;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: translate(-50%, -62%) rotate(-45deg);
}
.ff-cbox-readonly.ff-cbox-round { border-radius: 50%; }
.ff-cbox-readonly.ff-cbox-square { border-radius: 2px; }
.ff-cbox-readonly.ff-cbox-rounded { border-radius: 4px; }
.ff-option-readonly { cursor: default; }

/* ---- File / photo uploader ---- */
.ff-uploader-input { display: block; width: 100%; margin-bottom: 8px; }
.ff-uploader-input::file-selector-button {
    background: linear-gradient(145deg, var(--navy-800), var(--navy-900));
    color: var(--gold-soft);
    border: 1px solid rgba(201, 169, 97, 0.2);
    border-radius: 8px;
    padding: 8px 14px;
    font-weight: 600;
    cursor: pointer;
    margin-right: 10px;
}
.ff-uploader-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ff-uploader-list { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.ff-upload-card {
    width: 168px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.ff-upload-thumb {
    width: 100%;
    height: 118px;
    background: #f1eee4;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
}
.ff-upload-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ff-upload-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.ff-upload-name { font-size: 11px; color: var(--muted); word-break: break-all; }
.ff-upload-note { width: 100%; font-size: 12px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; resize: vertical; min-height: 34px; }
.ff-upload-remove { align-self: flex-end; }

/* ---- Submitted file list ---- */
.ff-files { display: flex; flex-direction: column; gap: 8px; }
.ff-file-item { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.ff-file-note { margin-top: 4px; font-size: 12px; color: var(--muted); white-space: pre-wrap; }

/* ---- Submitted file viewer lightbox ---- */
.ff-file-item-link .ff-file-link { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; cursor: pointer; }
.ff-file-item-link .ff-file-link:hover { text-decoration: underline; }
.ff-file-ic { opacity: .7; }
.ff-viewer { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 24px; }
.ff-viewer-backdrop { position: absolute; inset: 0; background: rgba(10, 22, 40, 0.75); }
.ff-viewer-panel { position: relative; background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 860px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px -20px rgba(10, 22, 40, 0.5); }
.ff-viewer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.ff-viewer-title { font-weight: 700; font-size: 15px; word-break: break-all; }
.ff-viewer-close { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.ff-viewer-close:hover { color: var(--error); }
.ff-viewer-body { padding: 16px; overflow: auto; display: flex; align-items: center; justify-content: center; background: #0b1220; }
.ff-viewer-img { max-width: 100%; max-height: 66vh; display: block; object-fit: contain; transform-origin: center center; transition: transform .18s ease; }
.ff-viewer-file { text-align: center; color: #e2e8f0; padding: 40px 20px; }
.ff-viewer-file-ic { font-size: 56px; margin-bottom: 12px; }
.ff-viewer-file-name { font-size: 15px; word-break: break-all; margin-bottom: 6px; }
.ff-viewer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ff-viewer-tools { display: flex; align-items: center; gap: 6px; }
.ff-viewer-tools .btn { padding: 4px 10px; font-size: 14px; line-height: 1.2; }
.ff-viewer-zoom { min-width: 52px; text-align: center; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- Terms & conditions ---- */
.ff-terms { display: flex; flex-direction: column; gap: 10px; }
.ff-terms-content {
    max-height: 180px;
    overflow-y: auto;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
    white-space: normal;
}
.ff-terms-accept { font-weight: 500; }
.ff-terms-accept span { flex: 1 1 auto; }
.ff-terms-status { font-weight: 600; padding: 6px 10px; border-radius: 6px; display: inline-block; }
.ff-terms-status.agreed { color: #0d7a5f; background: #d9f2ea; }
.ff-terms-status.not-agreed { color: #a32a3d; background: #fce4e8; }

/* ---- Technician portal ---- */
.tech-card {
    max-width: 640px;
    margin: 0 auto;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 12px 30px rgba(10, 22, 40, 0.08);
}
.tech-card-wide { max-width: 920px; }
.tech-title { margin: 0 0 6px; font-family: 'Playfair Display', Georgia, serif; }
.tech-sub { color: var(--muted); margin: 0 0 20px; }
.tech-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.tech-head .tech-sub { margin: 4px 0 0; }
.tech-search { display: flex; gap: 8px; margin-bottom: 20px; }
.tech-search input { flex: 1; min-width: 0; }
.tech-summary {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg);
    margin-bottom: 18px;
}
.tech-summary-total { display: flex; flex-direction: column; min-width: 90px; }
.tech-summary-num { font-size: 26px; font-weight: 700; font-family: 'Playfair Display', Georgia, serif; color: var(--navy-900); line-height: 1; }
.tech-summary-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tech-summary-types { display: flex; gap: 8px; flex-wrap: wrap; }
.tech-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: #eef2f8;
    color: var(--navy-800);
    font-size: 13px;
    font-weight: 600;
}
.tech-chip strong { color: var(--primary); font-size: 15px; }
.nav-badge { display: inline-block; min-width: 18px; padding: 1px 6px; margin-left: 6px; border-radius: 999px; background: #c4384d; color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.lang-ar { font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif; }
html[dir="rtl"] .public-nav { margin-left: 0; margin-right: auto; }
.tech-results-title { margin: 20px 0 10px; font-size: 16px; }
.tech-result {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px;
    background: #fff;
}
.tech-result-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.tech-id {
    display: inline-block;
    font-weight: 700;
    background: var(--gold-soft);
    color: var(--navy-800);
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 13px;
    line-height: 1.5;
    white-space: nowrap;
}
.tech-card form input[type=text] { width: 100%; }
.tech-empty { margin: 4px 0 20px; }
.tech-review {
    margin-top: 8px;
    border-top: 1px solid var(--border);
    padding-top: 22px;
}
.tech-review-head { margin-bottom: 16px; }
.tech-review-title { margin: 0 0 4px; font-family: 'Playfair Display', Georgia, serif; font-size: 22px; }
.tech-locked {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    border-radius: 10px;
    color: #991b1b;
}
.tech-locked-icon { font-size: 24px; line-height: 1; }
.ff-readonly {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    min-height: 38px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}
.ff-readonly .muted { color: var(--muted); }
.ff-signature, .ff-drawing-canvas { border: 1px solid var(--border); border-radius: 8px; background: #fff; touch-action: none; max-width: 100%; display: block; }
.ff-signature-actions { margin-top: 6px; }
.ff-drawing-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; align-items: center; }
.ff-tool { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 5px 10px; cursor: pointer; font-size: 14px; }
.ff-tool.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.ff-drawing-stroke { width: 34px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.ff-drawing-undo, .ff-drawing-clear { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 5px 10px; cursor: pointer; }

/* ---- Barcode/QR scan (text fields) ---- */
.ff-scan-wrap { display: flex; gap: 8px; align-items: stretch; }
.ff-scan-wrap > input,
.ff-scan-wrap > select,
.ff-scan-wrap > textarea { flex: 1 1 auto; min-width: 0; }
.ff-scan {
    flex: 0 0 auto;
    background: linear-gradient(145deg, var(--navy-800), var(--navy-900));
    color: var(--gold-soft);
    border: 1px solid rgba(201, 169, 97, 0.25);
    border-radius: 8px;
    padding: 0 16px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.ff-scan:hover { background: linear-gradient(145deg, var(--navy-600), var(--navy-800)); color: #e0cb9a; }
.ff-scan-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(10, 22, 40, 0.85);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.ff-scan-box {
    width: 100%; max-width: 460px;
    background: var(--card-bg); border-radius: 12px; overflow: hidden;
    border: 1px solid rgba(201, 169, 97, 0.25);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
.ff-scan-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
    color: var(--gold-soft); font-weight: 700;
}
.ff-scan-close {
    background: transparent; border: 0; color: var(--gold-soft);
    font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.ff-scan-video { display: block; width: 100%; height: auto; background: #000; }
.ff-scan-stage { position: relative; background: #000; }
.ff-scan-aim {
    position: absolute;
    left: 50%; top: 50%;
    width: 62%; height: 62%;
    transform: translate(-50%, -50%);
    border: 2px solid var(--gold);
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.28);
    pointer-events: none;
}
.ff-scan-toolbar {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.ff-scan-manual { flex: 1 1 130px; min-width: 0; }

/* ---- Outline image upload (builder) ---- */
.outline-upload-row { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.outline-thumb { margin-top: 8px; }
.outline-thumb img { max-width: 100%; max-height: 140px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.builder-hint { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }

/* ---- Bulk import (technicians) ---- */
.bulk-import .bulk-note { color: var(--muted); font-size: 13px; margin: 0 0 8px; }
.bulk-import .bulk-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 12px 0; }
.bulk-import .bulk-row:last-child { margin-bottom: 0; }
.bulk-import textarea { width: 100%; min-height: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; line-height: 1.5; }
.bulk-import input[type="file"] { max-width: 100%; }

/* ---- Team members assignment ---- */
.members-head { margin: 16px 0 8px; font-size: 15px; }
.member-check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.member-check { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-weight: 400; }
.member-check input { width: auto; }

/* ---- Installation condition (Handover portal) ---- */
.inst-good { background: #16a34a; color: #fff; }
.inst-recheck { background: #f97316; color: #fff; animation: instBlink 1.1s ease-in-out infinite; }
@keyframes instBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.install-condition { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.install-condition-title { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.install-option { display: inline-flex; align-items: center; gap: 8px; margin-right: 20px; font-size: 14px; cursor: pointer; }
.install-option input { width: auto; }
.install-alert { margin-bottom: 10px; padding: 10px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; background: #ffedd5; color: #c2410c; }
.install-condition.is-recheck .install-alert { animation: instBlink 1.1s ease-in-out infinite; }

/* ---- Installation Recheck bell (topbar notification) ---- */
.install-bell-wrap { position: relative; }
.install-bell {
    position: relative;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 8px;
    width: 38px; height: 38px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 18px; line-height: 1; cursor: pointer;
    color: var(--text); padding: 0;
}
.install-bell:hover { background: #f8fafc; }
.install-bell.has-alerts { color: #c2410c; border-color: #fdba74; background: #fff7ed; animation: installBellBlink 1s ease-in-out infinite; }
@keyframes installBellBlink {
    0%, 100% { box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.45); }
    50%      { box-shadow: 0 0 0 8px rgba(249, 115, 22, 0); }
}
.install-bell-badge {
    position: absolute; top: -7px; right: -7px;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px; background: #dc2626; color: #fff;
    font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
[dir="rtl"] .install-bell-badge { right: auto; left: -7px; }
.install-bell-pop {
    position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-width: 90vw;
    background: #fff; border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 14px 40px rgba(15, 30, 53, 0.2);
    display: none; z-index: 60; overflow: hidden; text-align: left;
}
[dir="rtl"] .install-bell-pop { right: auto; left: 0; text-align: right; }
.install-bell-pop.open { display: block; }
.install-bell-pop-head {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 14px; border-bottom: 1px solid var(--border); background: #fff7ed;
    font-size: 14px;
}
.install-bell-count {
    margin-left: auto; background: #f97316; color: #fff; border-radius: 999px;
    padding: 2px 8px; font-size: 12px; font-weight: 700;
}
[dir="rtl"] .install-bell-count { margin-left: 0; margin-right: auto; }
.install-bell-pop-body { max-height: 330px; overflow: auto; }
.install-bell-item {
    display: flex; flex-direction: column; gap: 2px;
    padding: 10px 14px; border-bottom: 1px solid var(--border);
    text-decoration: none; color: var(--text); font-size: 13px;
}
.install-bell-item:hover { background: #f8fafc; text-decoration: none; }
.install-bell-item-ref { font-weight: 700; }
.install-bell-item-vin { font-size: 12px; color: var(--muted); }
.install-bell-item-time { font-size: 11px; color: #c2410c; font-weight: 600; }
.install-bell-empty { padding: 20px 14px; color: var(--muted); font-size: 13px; text-align: center; }
.install-bell-pop-foot { padding: 9px 14px; border-top: 1px solid var(--border); text-align: center; }
.install-bell-pop-foot a { font-size: 13px; font-weight: 600; text-decoration: none; }

/* ---- Vehicle outline ---- */
.vehicle-outline { position: relative; display: inline-block; max-width: 100%; }
.vo-img { display: block; max-width: 100%; height: auto; cursor: crosshair; }
.vo-markers { position: absolute; inset: 0; pointer-events: none; }
.vo-marker { position: absolute; transform: translate(-50%,-50%); width: 26px; height: 26px; border-radius: 50%; background: #dc2626; color: #fff; font-weight: 700; font-size: 13px; text-align: center; line-height: 26px; cursor: pointer; pointer-events: auto; box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(0,0,0,.4); }
.vo-tools { margin-top: 6px; }
.vo-editor { position: absolute; z-index: 20; width: 220px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 12px; }
.vo-editor-title { font-weight: 700; margin-bottom: 8px; font-size: 13px; }
.vo-editor select, .vo-editor input { width: 100%; margin-bottom: 8px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.vo-editor-actions { display: flex; gap: 6px; }
.vo-editor-actions button { flex: 1; border: 0; border-radius: 6px; padding: 6px; cursor: pointer; font-size: 12px; font-weight: 600; }
.vo-e-save { background: var(--primary); color: #fff; }
.vo-e-del { background: #fee2e2; color: #b91c1c; }
.vo-e-close { background: #f1f5f9; color: var(--text); flex: 0 0 auto; }

/* ---- Public pages ---- */
.public-body { background: #f1f5f9; min-height: 100vh; }
.public-header { background: #0f172a; color: #fff; }
.public-header-inner { max-width: 860px; margin: 0 auto; padding: 14px 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.public-nav { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.public-nav a { color: #fff; text-decoration: none; font-size: 14px; font-weight: 600; padding: 6px 12px; border-radius: 8px; }
.public-nav a:hover { background: rgba(255,255,255,0.12); }
.public-container { max-width: 860px; margin: 0 auto; padding: 24px 20px 60px; }
.form-page-title { margin: 0 0 6px; }
.form-page-desc { color: var(--muted); margin: 0 0 20px; }
.form-page-actions { margin-top: 20px; }
.thankyou-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 40px; text-align: center; }
.thankyou-icon { width: 60px; height: 60px; border-radius: 50%; background: #d1fae5; color: #059669; font-size: 30px; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.thankyou-ref { margin: 16px 0; font-size: 16px; }
.thankyou-status { color: var(--muted); }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-published { background: #d1fae5; color: #065f46; }
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-archived { background: #e5e7eb; color: #374151; }
.badge-locked { background: #fee2e2; color: #991b1b; }
.badge-submitted { background: #dbeafe; color: #1d4ed8; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-returned { background: #ffedd5; color: #c2410c; }

/* ---- Utilities ---- */
.muted { color: var(--muted); }
.mt-2 { margin-top: 8px; }
.sub-meta { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); font-size: 13px; }

/* ---- Print ---- */
.print-only { display: none; }
.print-grid { display: none; }
@page { size: A4; margin: 8mm; }

@media print {
    /* Hide all UI chrome and interactive toolbars, keep the form itself. */
    .sidebar, .topbar, .no-print, .public-header, .form-page-actions,
    .ff-scan, .ff-camera-actions, .ff-drawing-tools, .ff-signature-actions,
    .vo-tools { display: none !important; }

    .print-only { display: block !important; }
    .ff-grid.screen-only { display: none !important; }
    .ff-grid.print-grid { display: grid !important; }

    /* Fixed page-count scaling: zoom the whole printout to fit N pages. */
    .print-pages-1 { zoom: 0.5 !important; }
    .print-pages-2 { zoom: 0.68 !important; }
    .print-pages-3 { zoom: 0.82 !important; }
    .print-pages-4 { zoom: 0.92 !important; }

    /* Force backgrounds, borders and theme colors to print exactly as designed
       (Chrome/Safari strip colors by default unless this is set). */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* Drop decorative gradients but keep the theme background color. */
    html, body { background-image: none !important; }

    .main { display: block; }
    .content { padding: 0; max-width: 100%; }

    .card { border: none; box-shadow: none; }
    .card-body { padding: 0; }

    /* Keep section headings glued to their content, but let fields flow so
       large checkbox lists / outlines don't create half-empty pages. */
    .ff-heading { break-inside: avoid; page-break-inside: avoid; }
    .ff-field { break-inside: auto; page-break-inside: auto; }
    .ff-readonly { border-color: #ccc; }

    /* Preserve the exact field widths designed in the form (the responsive
       collapse rule is screen-only, but re-assert widths here for safety). */
    .ff-grid { display: grid !important; grid-template-columns: repeat(12, 1fr) !important; }
    .ff-w-12 { grid-column: span 12 !important; }
    .ff-w-6  { grid-column: span 6 !important; }
    .ff-w-4  { grid-column: span 4 !important; }
    .ff-w-3  { grid-column: span 3 !important; }

    /* Compact the form to fit fewer pages (tune these values as needed). */
    .print-area { font-size: 8.5px !important; line-height: 1.25 !important; }
    .print-area .card-header { font-size: 13px !important; padding: 6px 0 !important; }
    .print-area .ff-grid { gap: 4px !important; }
    .print-area .ff-label { font-size: 8.5px !important; margin-bottom: 1px !important; line-height: 1.2 !important; }
    .print-area .ff-heading { height: auto !important; }
    .print-area .ff-heading h3 { padding: 3px 8px !important; font-size: 9px !important; line-height: 1.2 !important; }
    .print-area .ff-readonly { padding: 3px 6px !important; font-size: 8.5px !important; min-height: 0 !important; line-height: 1.25 !important; }
    .print-area .ff-options { gap: 1px !important; }
    .print-area .ff-option { gap: 4px !important; font-size: 8.5px !important; line-height: 1.2 !important; }
    .print-area .ff-option input.ff-cbox { width: 8px !important; height: 8px !important; }
    .print-area .ff-control img { max-height: 45px !important; width: auto !important; }
    .print-area .ff-type-vehicle_outline .ff-control { text-align: center !important; }
    .print-area .ff-control .vo-img { height: auto !important; width: auto !important; max-width: 100% !important; max-height: 280px !important; }
    .print-area .vo-marker { width: 20px !important; height: 20px !important; font-size: 11px !important; line-height: 20px !important; }
    .print-area .sub-meta { font-size: 8.5px !important; gap: 8px !important; }
    .print-area table { font-size: 8.5px !important; }
    .print-area .form-page-desc { font-size: 8.5px !important; }
    .print-area .ff-terms-content { font-size: 8.5px !important; line-height: 1.25 !important; max-height: none !important; overflow: visible !important; }
}

/* ---- Print design builder ---- */
.pd-layout { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
@media screen and (max-width: 900px) { .pd-layout { grid-template-columns: 1fr; } }

.pd-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.pd-pages-label { font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; gap: 8px; }
.pd-preview-card { position: sticky; top: 70px; }

.pd-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: #fff; cursor: grab; }
.pd-row.dragging { opacity: .45; }
.pd-row.is-hidden { opacity: .55; }
.pd-row.is-hidden .pd-label { text-decoration: line-through; }
.pd-row.is-heading-row { border-left: 4px solid #1d4ed8; }
.pd-row.is-heading-row .pd-label { color: #1d4ed8; }
.pd-drag { color: #94a3b8; font-size: 18px; line-height: 1; user-select: none; cursor: grab; }
.pd-eye { background: none; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; padding: 4px 6px; font-size: 14px; line-height: 1; color: #334155; }
.pd-eye.off { opacity: .35; }
.pd-row .pd-label { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: #0f172a; }
.pd-row .pd-type { display: block; font-size: 11px; font-weight: 400; color: #64748b; }
.pd-width { width: 74px; flex: none; }

.pd-preview-canvas { background: #f8fafc; border: 1px dashed var(--border); border-radius: 10px; padding: 16px; min-height: 320px; max-height: calc(100vh - 170px); overflow: auto; }
.pd-preview-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; }
.pd-pv-item { border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; background: #fff; }
.pd-pv-item .pd-pv-label { font-size: 10px; font-weight: 700; color: #334155; margin-bottom: 4px; }
.pd-pv-type { font-weight: 400; color: #94a3b8; font-size: 9px; margin-left: 5px; }
.pd-pv-item .pd-pv-value { height: 15px; background: #e2e8f0; border-radius: 4px; }
.pd-pv-item.is-image .pd-pv-value { height: 64px; }
.pd-pv-item.is-heading { border: none; background: #1d4ed8; color: #fff; padding: 8px 10px; font-weight: 700; font-size: 12px; }
.pd-w-12 { grid-column: span 12; }
.pd-w-6  { grid-column: span 6; }
.pd-w-4  { grid-column: span 4; }
.pd-w-3  { grid-column: span 3; }
.pd-empty { color: #94a3b8; font-size: 13px; margin: 0; }

/* ---- Workflow editor + approvals ---- */
.wf-step { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.wf-num { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.wf-step input[type=text] { flex: 1; min-width: 120px; }
.wf-step select { width: auto; min-width: 140px; }
.wf-step button { border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; padding: 6px 10px; }
.approval-item { border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.approval-item-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---- Form builder: visibility conditions ------------------------------ */
.cond-row { display: flex; gap: 5px; align-items: center; margin-bottom: 6px; }
.cond-row select, .cond-row input { flex: 1; min-width: 0; }
.cond-row .cond-del { flex: 0 0 auto; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; padding: 6px 8px; color: var(--error); }
.builder-hint { font-size: 12px; color: #64748b; margin: 0 0 8px; }

/* ---- Templates grid ---- */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.template-card { margin-bottom: 0; display: flex; flex-direction: column; }
.template-card .card-body { flex: 1; }

/* ---- Camera capture field ---- */
.ff-camera-video { width: 100%; max-width: 480px; border-radius: 8px; background: #000; }
.ff-camera-preview { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); }
.ff-camera-actions { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.ff-camera-file { display: block; margin-top: 8px; }

/* ---- Builder live preview modal ---- */
.preview-modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; }
.preview-modal-backdrop { position: absolute; inset: 0; background: rgba(10, 22, 40, 0.55); }
.preview-modal-panel { position: relative; background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 860px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 30px 80px -20px rgba(10, 22, 40, 0.4); }
.preview-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.preview-modal-title { font-weight: 700; font-family: 'Playfair Display', Georgia, serif; font-size: 17px; }
.preview-modal-close { border: 0; background: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
.preview-modal-close:hover { color: var(--error); }
.preview-modal-body { padding: 20px; overflow-y: auto; }

/* ---- Builder canvas: inline live controls (non-interactive) ---- */
.builder-center .fb-field-preview { padding: 12px; }
.builder-center .fb-field-preview input,
.builder-center .fb-field-preview select,
.builder-center .fb-field-preview textarea,
.builder-center .fb-field-preview .ff-options {
    pointer-events: none;
}

/* ---- Builder canvas: 12-column grid so field widths show inline ---- */
.builder-center { display: grid; grid-template-columns: repeat(12, 1fr); gap: 10px; align-items: start; }
.builder-center .builder-empty { grid-column: span 12; }
.fb-field { grid-column: span 12; margin-bottom: 0; }
.fb-field.ff-w-6 { grid-column: span 6; }
.fb-field.ff-w-4 { grid-column: span 4; }
.fb-field.ff-w-3 { grid-column: span 3; }
@media screen and (max-width: 768px) {
    .fb-field.ff-w-6, .fb-field.ff-w-4, .fb-field.ff-w-3 { grid-column: span 12; }
}

/* ---- Form themes ---- */
.theme-green { --primary: #059669; --primary-dark: #047857; }
.theme-orange { --primary: #ea580c; --primary-dark: #c2410c; }
.theme-purple { --primary: #7c3aed; --primary-dark: #6d28d9; }
.theme-red { --primary: #dc2626; --primary-dark: #b91c1c; }
.theme-teal { --primary: #0d9488; --primary-dark: #0f766e; }
.theme-dark { --primary: #38bdf8; --primary-dark: #0ea5e9; --body-bg: #0f172a; --card-bg: #1e293b; --border: #334155; --text: #e2e8f0; --muted: #94a3b8; }

/* ---- Submission comments ---- */
.comment { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
.comment-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.comment-head .btn { margin-left: auto; }
.comment-body { white-space: pre-wrap; }

/* ============================================================
   Elegant theme — deep navy, warm gold, soft ivory
   ============================================================ */

/* Serif display face for primary headings / values */
.page-title, .sidebar-brand, .stat-value, .auth-brand, .form-page-title {
    font-family: 'Playfair Display', Georgia, serif;
    letter-spacing: -0.02em;
}
.page-title { color: var(--navy-900); font-size: 24px; }
.stat-value { color: var(--navy-900); }

/* ---- Sidebar ---- */
.sidebar {
    background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-800) 100%);
    border-right: 1px solid rgba(201, 169, 97, 0.1);
}
.sidebar-brand {
    color: #fdfcf8;
    border-bottom: 1px solid rgba(201, 169, 97, 0.12);
    font-size: 17px;
}
.brand-dot {
    width: 11px; height: 11px;
    background: linear-gradient(145deg, var(--gold-soft), var(--gold));
    box-shadow: 0 0 12px rgba(201, 169, 97, 0.5);
}
.nav-label { color: rgba(201, 169, 97, 0.65); letter-spacing: 1.4px; }
.nav-item {
    margin: 0 10px 3px;
    padding: 10px 14px;
    border-left: 0;
    border-radius: 12px;
    color: var(--sidebar-text);
    font-weight: 500;
}
.nav-item:hover { background: rgba(201, 169, 97, 0.08); color: #fdfcf8; }
.nav-item.active {
    background: linear-gradient(135deg, rgba(201, 169, 97, 0.18), rgba(201, 169, 97, 0.06));
    color: #fdfcf8;
    box-shadow: inset 3px 0 0 var(--gold);
}
.nav-icon { color: rgba(201, 169, 97, 0.75); }

/* ---- Topbar ---- */
.topbar {
    background: rgba(253, 252, 248, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}
.user-avatar {
    background: linear-gradient(145deg, var(--navy-700), var(--navy-900));
    color: var(--gold-soft);
}

/* ---- Cards & panels ---- */
.card {
    border-radius: 16px;
    box-shadow: 0 2px 10px -4px rgba(10, 22, 40, 0.06);
}
.stat-card { border-radius: 16px; }
.card-header { letter-spacing: -0.01em; }

/* ---- Tables ---- */
table.table th {
    background: linear-gradient(180deg, transparent, rgba(201, 169, 97, 0.05));
    border-bottom: 1px solid var(--border);
}

/* ---- Inputs ---- */
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=time], select, textarea {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 4px rgba(201, 169, 97, 0.12);
}

/* ---- Buttons ---- */
.btn {
    background: linear-gradient(145deg, var(--navy-800), var(--navy-900));
    color: var(--gold-soft);
    border: 1px solid rgba(201, 169, 97, 0.2);
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 8px 20px -8px rgba(10, 22, 40, 0.45), inset 0 1px 0 rgba(201, 169, 97, 0.2);
}
.btn:hover {
    background: linear-gradient(145deg, var(--navy-600), var(--navy-800));
    color: #e0cb9a;
    box-shadow: 0 14px 28px -10px rgba(10, 22, 40, 0.5);
}
.btn-outline {
    background: rgba(255, 255, 255, 0.7);
    color: var(--text);
    border-color: var(--border);
    box-shadow: none;
}
.btn-outline:hover { background: #fff; border-color: var(--gold); color: var(--navy-900); }

/* ---- Alerts ---- */
.alert { border-radius: 12px; }
.alert-error { background: #fce4e8; color: #a32a3d; border: 1px solid rgba(196, 56, 77, 0.2); }
.alert-success { background: #d9f2ea; color: #0d7a5f; border: 1px solid rgba(16, 158, 121, 0.2); }

/* ---- Badges ---- */
.badge-published { background: #d9f2ea; color: #0d7a5f; }
.badge-draft { background: #fdf3dc; color: #b8760e; }
.badge-archived { background: #eef1f5; color: #3d4a5c; }

/* ---- Auth / guest pages ---- */
.auth-body { background: linear-gradient(135deg, #0a1628 0%, #142440 100%); }
.auth-card { background: var(--card-bg); border: 1px solid var(--border); }
.auth-brand { color: var(--gold); }
.auth-title { color: var(--navy-900); }
.error-code { color: var(--gold); }

/* ---- Public form pages ---- */
.public-body { background: var(--body-bg); }
.public-header {
    background: linear-gradient(180deg, var(--navy-900), var(--navy-800));
    color: #fdfcf8;
    border-bottom: 1px solid rgba(201, 169, 97, 0.15);
}
.public-header-inner { font-family: 'Playfair Display', Georgia, serif; letter-spacing: 0; }
.public-header-inner .brand-dot { box-shadow: 0 0 12px rgba(201, 169, 97, 0.5); }
.thankyou-card { background: var(--card-bg); }
.thankyou-icon { background: #d9f2ea; color: #0d7a5f; }

/* ---- Form builder ---- */
.builder-topbar, .builder-left, .builder-right, .builder-center {
    background: var(--card-bg);
    border-radius: 12px;
}
.field-lib { background: #f7f4ec; border-radius: 8px; }
.field-lib:hover { background: #fdfcf8; border-color: var(--gold); color: var(--navy-900); }
.fb-field.selected { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(201, 169, 97, 0.18); }
.fb-field-toolbar { background: #f7f4ec; }
.fb-preview-box { background: #f7f4ec; border-color: var(--border); }

/* ---- Required marker ---- */
.ff-required { color: var(--error); }

/* ---- Dark form theme aligned to navy ---- */
.theme-dark { --primary: #c9a961; --primary-dark: #b08d3e; --body-bg: #0f1e35; --card-bg: #142440; --border: rgba(201, 169, 97, 0.2); --text: #eef1f5; --muted: #94a3b8; }






/* ---- Dashboard ---- */
.stat-card { display: flex; flex-direction: column; position: relative; overflow: hidden; }
.stat-icon { font-size: 22px; line-height: 1; margin-bottom: 10px; }
.stat-primary .stat-icon { color: var(--primary); }
.stat-accent .stat-icon { color: #109e79; }
.stat-teal .stat-icon { color: #0d9488; }
.stat-navy .stat-icon { color: var(--navy-700); }
.stat-gold .stat-icon { color: var(--gold); }
.stat-purple .stat-icon { color: #7c6bb0; }
.stat-red .stat-icon { color: #c4384d; }
.dash-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 20px; }
.chart-box { position: relative; height: 260px; }
@media (max-width: 1100px) { .dash-charts { grid-template-columns: 1fr; } }

/* ---- Avatars ---- */
.user-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
img.user-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.user-cell { display: inline-flex; align-items: center; gap: 8px; }
.avatar-sm { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; }
.avatar-init { background: linear-gradient(145deg, var(--navy-700), var(--navy-900)); color: var(--gold-soft); font-weight: 700; font-size: 12px; }
.avatar-lg { width: 96px; height: 96px; border-radius: 50%; overflow: hidden; margin: 0 auto; display: flex; align-items: center; justify-content: center; background: linear-gradient(145deg, var(--navy-700), var(--navy-900)); color: var(--gold-soft); font-size: 36px; font-weight: 700; }
.avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.profile-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
@media (max-width: 900px) { .profile-grid { grid-template-columns: 1fr; } }

/* ---- Branding ---- */
.brand-logo { max-height: 34px; max-width: 180px; object-fit: contain; }
.brand-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .brand-grid { grid-template-columns: 1fr; } }
.brand-item { border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.brand-preview { height: 90px; display: flex; align-items: center; justify-content: center; border-radius: 8px; margin-bottom: 12px; }
.brand-preview.dark { background: var(--navy-900); }
.brand-preview img { max-width: 100%; max-height: 80px; object-fit: contain; }
.brand-guide { margin-top: 8px; background: #f7f4ec; border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; font-size: 12px; color: var(--muted); }
.brand-guide ul { margin: 6px 0 0 16px; padding: 0; }
.brand-guide li { margin-bottom: 3px; }
input[type="range"] { width: 100%; padding: 0; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(10, 22, 40, 0.5); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 20px; }
.modal-box { background: var(--card-bg); border-radius: 16px; padding: 20px; width: 100%; max-width: 420px; box-shadow: 0 20px 50px rgba(10, 22, 40, 0.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; font-size: 16px; }
.modal-close { background: none; border: 0; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }

/* ---- Auth background logo ---- */
.auth-bg { position: fixed; inset: 0; background-size: cover; background-position: center; background-repeat: no-repeat; z-index: 0; }
.auth-wrap { position: relative; z-index: 1; }

/* ---- Permission checkboxes ---- */
.perm-checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.perm-checks label { font-weight: 500; font-size: 13px; }

/* ---- Permission matrix ---- */
.perm-matrix th, .perm-matrix td { text-align: center; }
.perm-matrix th { vertical-align: middle; }
.perm-col input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.perm-actions { display: flex; gap: 8px; }

