:root {
  --teal: #0f766e;
  --teal-dark: #115e59;
  --teal-soft: #f0fdfa;
  --teal-border: #99f6e4;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif; background: var(--bg); color: var(--text); height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

/* Top Enterprise Header */
.app-header { height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 20px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.brand-wrap { display: flex; align-items: center; gap: 11px; }
.brand-logo { width: 34px; height: 34px; border-radius: 8px; background: var(--teal); color: #fff; font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; letter-spacing: 0.5px; }
.brand-text h1 { font-size: 14.5px; font-weight: 700; color: var(--text); line-height: 1.2; }
.brand-text span { font-size: 11px; color: var(--muted); display: block; }

.header-right { display: flex; align-items: center; gap: 12px; }
.sync-pill { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.sync-pill.saving { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.sync-pill.err { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.btn-admin { background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 6px 12px; border-radius: 7px; font-size: 11.5px; font-weight: 700; cursor: pointer; transition: 0.15s; }
.btn-admin:hover { background: #f1f5f9; }
.btn-admin.unlocked { background: #dc2626; color: #fff; border-color: #dc2626; }

.user-profile { text-align: right; border-left: 1px solid var(--border); padding-left: 14px; }
.user-profile strong { font-size: 12.5px; color: var(--text); display: block; line-height: 1.2; }
.user-profile span { font-size: 11px; color: var(--muted); }

/* Body Shell */
.app-shell { display: flex; flex: 1; overflow: hidden; position: relative; }

.sidebar { width: 225px; background: var(--surface); border-right: 1px solid var(--border); padding: 14px 12px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; flex-shrink: 0; }
.nav-group-title { font-size: 10px; font-weight: 800; color: #94a3b8; letter-spacing: 0.6px; text-transform: uppercase; padding: 0 10px 6px; }
.nav-list { display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; justify-content: space-between; width: 100%; text-align: left; background: transparent; border: none; padding: 8px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: #334155; cursor: pointer; transition: 0.15s; }
.nav-item:hover { background: #f1f5f9; color: var(--text); }
.nav-item.active { background: var(--teal); color: #ffffff; font-weight: 700; }
.nav-badge { font-size: 10px; padding: 1px 6px; border-radius: 99px; background: rgba(255,255,255,0.2); font-weight: 700; }
.nav-item:not(.active) .nav-badge { background: #f1f5f9; color: var(--muted); }

/* Select Company Trigger Card */
.company-trigger-btn { width: 100%; text-align: left; background: var(--teal-soft); border: 1.5px solid var(--teal-border); border-radius: 8px; padding: 9px 11px; cursor: pointer; transition: 0.15s; }
.company-trigger-btn:hover { background: #ccfbf1; border-color: var(--teal); }
.company-trigger-top { display: flex; justify-content: space-between; align-items: center; font-size: 10px; font-weight: 800; color: var(--teal); text-transform: uppercase; margin-bottom: 3px; }
.company-trigger-name { font-size: 13px; font-weight: 800; color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Slide-Over Company Selector Drawer */
.drawer-backdrop { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35); z-index: 40; }
.drawer-backdrop.open { display: block; }
.company-drawer { position: fixed; top: 56px; left: -340px; width: 320px; height: calc(100vh - 56px); background: var(--surface); border-right: 1px solid var(--border); box-shadow: 8px 0 24px rgba(15,23,42,0.12); z-index: 50; display: flex; flex-direction: column; transition: left 0.22s ease; }
.company-drawer.open { left: 0; }
.cd-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: #fcfcfd; }
.cd-head h3 { font-size: 14px; font-weight: 700; color: var(--text); }
.cd-close { background: #f1f5f9; border: none; width: 26px; height: 26px; border-radius: 6px; font-weight: 700; cursor: pointer; color: #475569; }
.cd-search-wrap { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.cd-list { flex: 1; overflow-y: auto; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.cd-card { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; cursor: pointer; transition: 0.15s; background: #fff; display: flex; justify-content: space-between; align-items: center; }
.cd-card:hover { border-color: var(--teal); background: var(--teal-soft); }
.cd-card.selected { border: 1.5px solid var(--teal); background: var(--teal-soft); }
.cd-card-info strong { font-size: 13px; color: var(--text); display: block; }
.cd-card-info span { font-size: 11px; color: var(--muted); }
.cd-status { font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: #ecfdf5; color: #065f46; }
.cd-status.pending { background: #fffbeb; color: #92400e; }
.cd-foot { padding: 12px 14px; border-top: 1px solid var(--border); background: #fcfcfd; }

/* Admin Sidebar & Modal */
.admin-sidebar-box { display: none; border-top: 1px solid var(--border); padding-top: 10px; }
body.admin-on .admin-sidebar-box { display: block; }
.admin-btn-item { display: block; width: 100%; text-align: left; background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 6px 9px; border-radius: 6px; font-size: 11px; font-weight: 700; cursor: pointer; margin-bottom: 5px; }
.admin-btn-item:hover { background: #fef3c7; }
.admin-btn-item.design-active { background: #dc2626; color: #fff; border-color: #dc2626; }

.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.45); z-index: 60; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal-card { background: #fff; border-radius: 10px; width: 440px; max-width: 94vw; border: 1px solid var(--border); box-shadow: 0 20px 40px rgba(0,0,0,0.2); overflow: hidden; }
.modal-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: #fcfcfd; }
.modal-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; max-height: 75vh; overflow-y: auto; }
.modal-foot { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: #fcfcfd; }

/* Main Workspace */
.workspace { flex: 1; padding: 14px 18px; display: flex; flex-direction: column; gap: 12px; overflow: hidden; }
.workspace-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.ws-title-area h2 { font-size: 17px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.ws-title-area p { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

/* Pill Tabs */
.pill-tabs { display: inline-flex; background: #e2e8f0; padding: 3px; border-radius: 8px; gap: 3px; }
.pill-tab { border: none; background: transparent; padding: 5px 12px; border-radius: 6px; font-size: 11.5px; font-weight: 700; color: #475569; cursor: pointer; transition: 0.15s; }
.pill-tab.active { background: var(--surface); color: var(--teal); box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* Split Cards */
.split-cards { display: flex; gap: 14px; flex: 1; overflow: hidden; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.02); }
.form-card { width: 48%; }
.preview-card { width: 52%; }

.card-head { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; background: #fcfcfd; gap: 8px; flex-wrap: wrap; }
.card-head-title { font-size: 12px; font-weight: 700; color: var(--text); }
.card-body { padding: 12px 14px; overflow-y: auto; flex: 1; }
.card-foot { padding: 10px 14px; border-top: 1px solid var(--border); background: #fcfcfd; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.master-box { background: var(--teal-soft); border: 1px solid var(--teal-border); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.master-box label { color: var(--teal-dark); font-size: 10.5px; font-weight: 800; display: block; margin-bottom: 4px; text-transform: uppercase; }
.master-row { display: flex; gap: 6px; align-items: center; }

.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

.lbl-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; gap: 3px; }
label.fld-lbl { font-size: 10.5px; font-weight: 600; color: #475569; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aim-btn { display: none; background: #f1f5f9; color: #334155; border: 1px solid #94a3b8; border-radius: 4px; padding: 0 5px; font-size: 9.5px; font-weight: 800; cursor: pointer; flex-shrink: 0; }
body.aim-on .aim-btn { display: inline-block; }
.aim-btn.mapped { background: #dcfce7; color: #166534; border-color: #4ade80; }
.aim-btn.targeting { background: #dc2626; color: #fff; border-color: #dc2626; }
.custom-del-btn { display: none; background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; border-radius: 4px; padding: 0 4px; font-size: 9px; font-weight: 800; cursor: pointer; }
body.admin-on .custom-del-btn { display: inline-block; }

input, select { width: 100%; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 11.5px; text-transform: uppercase; font-weight: 600; background: #fff; color: var(--text); }
input.date-input { text-transform: none; font-family: inherit; }
input:focus, select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 2px rgba(15,118,110,0.12); }

.chk-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.chk-item { display: flex; align-items: center; justify-content: space-between; font-size: 11px; font-weight: 600; background: #f8fafc; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; gap: 5px; }
.tick-sel { width: 64px; padding: 3px 4px; font-size: 11px; font-weight: 700; text-align: center; cursor: pointer; }
.tick-sel.val-tick { background: #dcfce7; color: #166534; border-color: #4ade80; }
.tick-sel.val-cross { background: #fee2e2; color: #991b1b; border-color: #f87171; }

.btn-teal { background: var(--teal); color: #fff; border: none; padding: 7px 14px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; }
.btn-teal:hover { background: var(--teal-dark); }
.btn-outline { background: #fff; color: var(--text); border: 1px solid #cbd5e1; padding: 6px 12px; border-radius: 6px; font-size: 11.5px; font-weight: 700; cursor: pointer; }
.btn-outline:hover { background: #f1f5f9; }
.btn-dark { background: #0f172a; color: #fff; border: none; padding: 7px 14px; border-radius: 6px; font-size: 12px; font-weight: 700; cursor: pointer; }
.btn-mini { background: #fff; color: var(--teal-dark); border: 1px solid var(--teal-border); padding: 4px 8px; border-radius: 5px; font-size: 10.5px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn-del-mini { display: none; background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; padding: 4px 7px; border-radius: 5px; font-size: 10.5px; font-weight: 700; cursor: pointer; }
body.admin-on .btn-del-mini { display: inline-block; }

.tune-bar { display: none; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
body.admin-on .tune-bar { display: flex; }
.tune-bar input { width: 48px; padding: 3px 5px; text-align: center; }

.aim-hud { display: none; background: #fefce8; color: #854d0e; padding: 6px 12px; font-size: 11px; font-weight: 700; justify-content: space-between; align-items: center; border-bottom: 1px solid #fde047; }
body.aim-on .aim-hud { display: flex; }

#liveViewWrap { flex: 1; display: flex; background: #334155; }
iframe { width: 100%; height: 100%; border: none; }

#aimViewWrap { display: none; flex: 1; overflow: auto; background: #334155; padding: 14px; text-align: center; }
body.aim-on #liveViewWrap { display: none; }
body.aim-on #aimViewWrap { display: block; }

.canvas-stage { position: relative; display: inline-block; box-shadow: 0 10px 25px rgba(0,0,0,0.45); user-select: none; }
#pdfCanvas { display: block; background: #fff; }
#overlayCanvas { position: absolute; top: 0; left: 0; pointer-events: none; }

.sub-view { display: none; flex: 1; overflow-y: auto; }
.sub-view.active { display: flex; flex-direction: column; gap: 12px; }
.case-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.case-table th { text-align: left; padding: 9px 12px; background: #f8fafc; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 11px; text-transform: uppercase; }
.case-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }