*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-bg:       #f4f6f9;
    --color-sidebar:  #1e2533;
    --color-sidebar-text: #c9d1e0;
    --color-sidebar-active: #3b82f6;
    --color-white:    #ffffff;
    --color-primary:  #3b82f6;
    --color-danger:   #ef4444;
    --color-success:  #22c55e;
    --color-text:     #1f2937;
    --color-muted:    #6b7280;
    --color-border:   #e5e7eb;
    --sidebar-width:  220px;
    --radius:         6px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--color-text); background: var(--color-bg); }

/* ── Login ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--color-bg); }
.login-card { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 40px; width: 360px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--color-text); margin-bottom: 4px; }
.login-subtitle { color: var(--color-muted); margin-bottom: 24px; font-size: 13px; }
.login-form .form-group { margin-bottom: 16px; }

/* ── Admin layout ── */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-width); background: var(--color-sidebar); color: var(--color-sidebar-text); display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto; }
.sidebar-header { padding: 20px 16px 12px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-app-name { font-size: 15px; font-weight: 700; color: #fff; }
.sidebar-nav { list-style: none; padding: 12px 0; flex: 1; }
.sidebar-nav li a { display: block; padding: 9px 16px; color: var(--color-sidebar-text); text-decoration: none; border-radius: 0; transition: background .15s; font-size: 13px; }
.sidebar-nav li a:hover, .sidebar-nav li a.active { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav li a.active { border-left: 3px solid var(--color-sidebar-active); }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; display: flex; justify-content: space-between; align-items: center; }
.sidebar-footer a { color: var(--color-sidebar-text); text-decoration: none; }
.sidebar-footer a:hover { color: #fff; }
.admin-content { margin-left: var(--sidebar-width); flex: 1; padding: 32px; }
.admin-inner { max-width: 1100px; }

/* ── Components ── */
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 20px; font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 20px; }
.stat-label { font-size: 12px; color: var(--color-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--color-text); }

.dashboard-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Forms ── */
label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: var(--color-text); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"],
select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--color-border); border-radius: var(--radius);
    font-size: 14px; background: var(--color-white); color: var(--color-text);
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary); }
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius); border: none; cursor: pointer; font-size: 13px; font-weight: 500; text-decoration: none; transition: opacity .15s; }
.btn:hover { opacity: .85; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-secondary { background: var(--color-white); color: var(--color-text); border: 1px solid var(--color-border); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-full { width: 100%; justify-content: center; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 13px; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--color-white); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--color-border); }
th { background: #f9fafb; padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600; color: var(--color-muted); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--color-border); }
td { padding: 11px 14px; font-size: 13px; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

/* ── Card ── */
.card { background: var(--color-white); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 18px; padding-bottom: 12px; border-bottom: 1px solid var(--color-border); }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-gray  { background: #f3f4f6; color: #6b7280; }
.badge-blue  { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red   { background: #fee2e2; color: #991b1b; }

/* ── Page header row ── */
.page-header-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.back-link { display: block; font-size: 12px; color: var(--color-muted); text-decoration: none; margin-bottom: 2px; }
.back-link:hover { color: var(--color-primary); }
.required { color: var(--color-danger); }
.field-error { display: block; font-size: 12px; color: var(--color-danger); margin-top: 4px; }
.field-hint  { font-size: 12px; color: var(--color-muted); margin-top: 4px; }
.form-actions { display: flex; gap: 12px; margin-top: 4px; padding-bottom: 40px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; font-weight: normal; }
.checkbox-label input[type="checkbox"] { width: auto; }

/* ── Color picker group ── */
.branding-colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 24px; }
.color-input-group { display: flex; align-items: center; gap: 8px; }
.color-swatch-input { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--color-border); border-radius: var(--radius); cursor: pointer; flex-shrink: 0; background: none; }
.color-hex-input { flex: 1; font-family: monospace; }

/* ── Color preview bar ── */
.color-preview-bar { display: flex; border-radius: var(--radius); overflow: hidden; height: 40px; margin: 8px 0 0; }
.color-preview-bar > div { flex: 1; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: rgba(255,255,255,.85); letter-spacing: .04em; }

/* ── Logo upload ── */
.logo-upload-area { display: flex; align-items: flex-start; gap: 20px; }
.logo-current { width: 120px; height: 60px; border: 1px solid var(--color-border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; background: #f9fafb; flex-shrink: 0; overflow: hidden; }
.logo-current img { max-width: 110px; max-height: 52px; object-fit: contain; }

/* ── Agency initials avatar ── */
.agency-initials { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0; }

/* ── Color dots (table) ── */
.color-dots { display: flex; gap: 6px; align-items: center; }
.color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.1); }

/* ── Palette chips (preview page) ── */
.palette-chip { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 130px; height: 72px; border-radius: var(--radius); gap: 4px; }
.palette-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.palette-hex   { font-size: 13px; font-family: monospace; font-weight: 600; }

/* ── Mock report cover ── */
.mock-cover { display: flex; min-height: 540px; border-top: 1px solid var(--color-border); }
.mock-sidebar { width: 220px; flex-shrink: 0; padding: 28px 20px; display: flex; flex-direction: column; }
.mock-logo-area { margin-bottom: 20px; }
.mock-logo { max-width: 160px; max-height: 60px; object-fit: contain; }
.mock-logo-placeholder { width: 56px; height: 56px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; }
.mock-sidebar-divider { height: 3px; width: 40px; border-radius: 2px; margin: 16px 0; }
.mock-sidebar-label { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .65; margin-bottom: 4px; }
.mock-sidebar-value { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
.mock-sidebar-sub   { font-size: 12px; opacity: .75; line-height: 1.6; }
.mock-main { flex: 1; display: flex; flex-direction: column; }
.mock-accent-bar { height: 5px; flex-shrink: 0; }
.mock-main-inner { flex: 1; padding: 36px 40px 20px; }
.mock-report-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; margin-bottom: 24px; }
.mock-client-name { font-size: 32px; font-weight: 700; color: #1f2937; margin-bottom: 4px; }
.mock-client-url  { font-size: 14px; color: #6b7280; margin-bottom: 28px; }
.mock-divider { height: 2px; width: 60px; border-radius: 2px; margin-bottom: 24px; }
.mock-meta-row { display: flex; gap: 32px; flex-wrap: wrap; }
.mock-meta-item { display: flex; flex-direction: column; gap: 4px; }
.mock-meta-label { font-size: 11px; color: #6b7280; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.mock-meta-value { font-size: 16px; font-weight: 600; color: #1f2937; }
.mock-footer { padding: 12px 40px; font-size: 12px; flex-shrink: 0; }

/* ── Sidebar user block (Phase 4) ── */
.sidebar-footer { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-user { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-name:hover { color: #fff; }
.sidebar-user-role { font-size: 10px; color: rgba(255,255,255,.45); letter-spacing: .05em; text-transform: lowercase; }
.sidebar-signout { font-size: 16px; color: rgba(255,255,255,.4); text-decoration: none; flex-shrink: 0; padding: 2px; }
.sidebar-signout:hover { color: #fff; }

/* ── User avatar ── */
.user-avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.you-tag { display: inline-block; margin-left: 6px; padding: 1px 6px; background: #f3f4f6; color: #6b7280; border-radius: 10px; font-size: 10px; font-weight: 600; vertical-align: middle; }

/* ── Profile page ── */
.profile-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-border); font-size: 13px; }
.profile-row:last-of-type { border-bottom: none; }
.profile-label { width: 90px; flex-shrink: 0; font-size: 12px; font-weight: 600; color: var(--color-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ── Phase 5: Industry Language ── */
.slug-code { font-family: monospace; font-size: 12px; background: #f3f4f6; padding: 2px 6px; border-radius: 3px; color: #374151; }
.industry-sample-label { display: inline-block; padding: 2px 10px; background: #eff6ff; color: #1d4ed8; border-radius: 20px; font-size: 12px; font-weight: 600; }
.term-count { font-size: 12px; font-weight: 600; }
.term-count-full    { color: #166534; }
.term-count-partial { color: #854d0e; }

/* Comparison table */
.comparison-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.comparison-table th { background: #f9fafb; padding: 8px 12px; text-align: left; font-weight: 600; color: #6b7280; border-bottom: 1px solid #e5e7eb; white-space: nowrap; }
.comparison-table td { padding: 7px 12px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.comparison-table tr:last-child td { border-bottom: none; }
.comparison-value { font-weight: 500; color: #1f2937; }

/* Terms editor two-column layout */
.terms-layout { display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; }
.terms-preview-sticky { position: sticky; top: 24px; }
.term-field-group { margin-bottom: 14px; }
.term-field-group:last-child { margin-bottom: 0; }
.term-field-group label { font-size: 12px; color: #6b7280; font-weight: 500; margin-bottom: 4px; }
.term-field-group input { font-size: 13px; }

/* KPI preview grid */
.preview-kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.preview-kpi { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 5px; padding: 10px 12px; }
.preview-kpi-label { font-size: 10px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px; min-height: 28px; }
.preview-kpi-value { font-size: 18px; font-weight: 700; color: #1f2937; }

/* Contribution preview */
.preview-contrib-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.preview-contrib-row:last-child { border-bottom: none; }
.preview-contrib-label { color: #6b7280; }
.preview-contrib-value { font-weight: 600; }
.preview-contrib-highlight .preview-contrib-label { color: #1f2937; font-weight: 600; }
.preview-contrib-highlight .preview-contrib-value { color: var(--color-primary); font-size: 15px; }

/* ── Phase 6: Client Registry ── */

/* Client initial avatar */
.client-initial { width: 28px; height: 28px; border-radius: 5px; background: #e0e7ff; color: #4338ca; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }

/* Industry tag */
.industry-tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; background: #f3f4f6; color: #374151; }
.industry-tag--hospitality   { background: #fef3c7; color: #92400e; }
.industry-tag--ecommerce     { background: #d1fae5; color: #065f46; }
.industry-tag--real_estate   { background: #dbeafe; color: #1e40af; }
.industry-tag--general_services { background: #f3e8ff; color: #6b21a8; }
.industry-tag--tours_events  { background: #fce7f3; color: #9d174d; }

/* Connection pills */
.conn-pill { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.conn-pill--on  { background: #dcfce7; color: #166534; }
.conn-pill--off { background: #f3f4f6; color: #9ca3af; }

/* Currency input */
.currency-input-wrap { position: relative; display: flex; align-items: center; }
.currency-prefix { position: absolute; left: 10px; color: #6b7280; font-size: 14px; pointer-events: none; }
.currency-input-wrap input { padding-left: 24px; }

/* Client tabs */
.client-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--color-border); margin-bottom: 24px; }
.ctab-btn { padding: 10px 18px; border: none; background: none; font-size: 13px; font-weight: 500; color: var(--color-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s, border-color .15s; }
.ctab-btn:hover  { color: var(--color-text); }
.ctab-btn.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }

/* Connection rows */
.connection-row { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 10px; }
.remove-row-btn { flex-shrink: 0; width: 30px; height: 38px; border: 1px solid var(--color-border); background: var(--color-white); border-radius: var(--radius); color: var(--color-muted); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; margin-bottom: 0; transition: color .15s, border-color .15s; }
.remove-row-btn:hover { color: var(--color-danger); border-color: var(--color-danger); }

/* Report settings checklist */
.settings-check-list { display: flex; flex-direction: column; gap: 0; }
.settings-check-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--color-border); cursor: pointer; }
.settings-check-row:last-child { border-bottom: none; }
.settings-check-row input[type="checkbox"] { margin-top: 2px; width: auto; flex-shrink: 0; }
.settings-check-label { font-size: 13px; font-weight: 600; color: var(--color-text); margin-bottom: 3px; }
.settings-check-hint  { font-size: 12px; color: var(--color-muted); line-height: 1.5; }

/* Override sections */
.override-section { margin-bottom: 24px; }
.override-section:last-child { margin-bottom: 0; }
.override-section-title { font-size: 11px; font-weight: 700; color: var(--color-muted); text-transform: uppercase; letter-spacing: .07em; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--color-border); }

/* Always-visible save bar */
.client-save-bar { display: flex; gap: 12px; padding: 20px 0 40px; }

/* ── Module Settings sections (Phase 3B) ── */
.module-settings-section { border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden; }
.module-settings-section--disabled { opacity: .7; }
.module-settings-section .card { border: none; border-radius: 0; border-top: 1px solid #e2e8f0; margin: 0; }
.module-settings-header { padding: 16px 20px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; }
.module-settings-title { font-weight: 600; font-size: 15px; color: #0f172a; }
.module-settings-note { font-size: 12px; color: #64748b; margin-top: 3px; }
.module-placeholder { padding: 12px 0 4px; }
/* Inline link button — looks like <a> but is a <button> (avoids form submit) */
.link-btn { background: none; border: none; padding: 0; color: #2563eb; font-size: inherit; cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: #1d4ed8; }

/* ── Sidebar section labels ── */
.sidebar-nav li.sidebar-section { padding: 14px 16px 4px; font-size: 10px; font-weight: 700; color: rgba(255,255,255,.35); letter-spacing: .08em; text-transform: uppercase; cursor: default; }
.sidebar-nav li.sidebar-section:first-child { padding-top: 8px; }

/* ── Collapsible card (API credentials) ── */
.collapsible-card { padding: 0; overflow: hidden; }
.collapsible-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; background: none; border: none; padding: 18px 20px; cursor: pointer; text-align: left; font-size: 14px; }
.collapsible-toggle:hover { background: #f8fafc; }
.collapsible-title { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--color-text); }
.collapsible-chevron { font-size: 12px; color: var(--color-muted); transition: transform .2s; flex-shrink: 0; }
.collapsible-body { padding: 0 20px 20px; }
