/* ==========================================================
   DRP Intake Portal — Global Styles
   Global Computer Support
   ========================================================== */

:root,
:root[data-theme="dark"] {
    --bg:           #0b0d10;
    --bg-soft:      #12161c;
    --surface:      #171c23;
    --surface-2:    #1e242d;
    --border:       #262d38;
    --border-soft:  #1f2630;
    --text:         #e6e9ef;
    --text-muted:   #9aa3b2;
    --text-dim:     #6c7484;

    --accent:        #d92235;   /* GCS red */
    --accent-hover:  #ef3a4d;
    --accent-soft:   rgba(217, 34, 53, 0.12);

    --success:       #3ca86a;
    --warn:          #e8a73a;
    --info:          #4e8ef0;

    --radius:       10px;
    --radius-sm:    6px;
    --shadow:       0 1px 2px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.2);
    --shadow-lg:    0 24px 60px rgba(0,0,0,0.5);
    --font-sans:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-serif:   'Playfair Display', Georgia, serif;
    --font-mono:    'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme="light"] {
    --bg:           #ffffff;
    --bg-soft:      #f7f8fa;
    --surface:      #ffffff;
    --surface-2:    #f0f2f6;
    --border:       #dcdfe5;
    --border-soft:  #e7e9ee;
    --text:         #1a1d24;
    --text-muted:   #5a6270;
    --text-dim:     #8a909b;

    --accent:        #c8102e;
    --accent-hover:  #a80d25;
    --accent-soft:   rgba(200, 16, 46, 0.08);

    --success:       #2d7a3e;
    --warn:          #b5761a;
    --info:          #2b6fd1;

    --shadow:       0 1px 2px rgba(15,23,42,0.08), 0 4px 16px rgba(15,23,42,0.06);
    --shadow-lg:    0 24px 60px rgba(15,23,42,0.18);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

button, input, textarea, select {
    font: inherit;
    color: inherit;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn:hover { background: var(--surface); border-color: #333c4a; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: #ff6b7a; }
.btn.danger:hover { background: rgba(217, 34, 53, 0.1); border-color: rgba(217, 34, 53, 0.3); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.icon-only { padding: 7px 8px; }

/* ===== Forms ===== */
.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.field label .req { color: var(--accent); }
.input, .textarea, .select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}
.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg);
}
.textarea { min-height: 88px; resize: vertical; font-family: inherit; }

.help {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
    font-style: italic;
}

/* ===== Layout ===== */
.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-soft);
    border-right: 1px solid var(--border-soft);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar .brand {
    padding: 4px 8px 20px;
    border-bottom: 1px solid var(--border-soft);
    margin-bottom: 16px;
}
.sidebar .brand .logo {
    font-family: var(--font-serif);
    font-size: 20px;
    color: var(--text);
    font-weight: 700;
    line-height: 1.2;
}
.sidebar .brand .sub {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.sidebar .nav-section {
    margin-bottom: 24px;
}
.sidebar .nav-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin: 8px 10px 6px;
}

.sidebar .session-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar .session-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.1s;
    border: 1px solid transparent;
    position: relative;
}
.sidebar .session-item:hover { background: var(--surface); }
.sidebar .session-item.active {
    background: var(--accent-soft);
    border-color: rgba(217, 34, 53, 0.3);
}
.sidebar .session-item .name {
    font-weight: 500;
    font-size: 13px;
    color: var(--text);
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar .session-item .meta {
    font-size: 11px;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
    gap: 8px;
}
.sidebar .session-item .progress-mini {
    height: 2px;
    background: var(--border);
    border-radius: 1px;
    margin-top: 6px;
    overflow: hidden;
}
.sidebar .session-item .progress-mini > div {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
    font-size: 11px;
    color: var(--text-dim);
}
.sidebar-footer .user {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    margin-bottom: 4px;
}

/* ===== Main content ===== */
.main {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(8px);
}
.topbar .title-group h1 {
    font-family: var(--font-serif);
    font-size: 22px;
    margin: 0;
    line-height: 1.2;
}
.topbar .title-group .sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}
.topbar .actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.profile-menu-wrap {
    position: relative;
    padding-left: 12px;
    margin-left: 4px;
    border-left: 1px solid var(--border-soft);
}
.profile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 6px 9px;
    cursor: pointer;
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.profile-btn:hover { background: var(--bg-soft); border-color: var(--border-soft); color: var(--text); }
.profile-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    z-index: 100;
    overflow: hidden;
}
.profile-dropdown.open { display: block; }
.profile-dd-user { padding: 12px 14px 10px; }
.profile-dd-name { font-size: 13px; font-weight: 600; color: var(--text); }
.profile-dd-email { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.profile-dd-sep { height: 1px; background: var(--border-soft); }
.profile-dd-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    text-align: left;
    font-size: 13px;
    font-family: var(--font-sans);
    color: var(--text);
    cursor: pointer;
}
.profile-dd-item:hover { background: var(--bg-soft); }
.profile-dd-danger { color: #ff6b7a; }
.profile-dd-danger:hover { background: rgba(217,34,53,0.1); }

.content {
    padding: 28px 32px 64px;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
}

/* ===== Empty state ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 24px;
    color: var(--text-muted);
}
.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}
.empty-state h2 {
    font-family: var(--font-serif);
    color: var(--text);
    margin: 0 0 8px;
}
.empty-state p { max-width: 420px; margin: 0 0 20px; }

/* ===== Sections in the intake view ===== */
.section-block {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface);
}
.section-header .num {
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 4px;
}
.section-header h3 {
    font-family: var(--font-serif);
    font-size: 20px;
    margin: 0 0 4px;
    color: var(--text);
}
.section-header .desc {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0;
    font-style: italic;
}
.section-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ===== Question row ===== */
.question {
    padding-bottom: 18px;
    border-bottom: 1px dashed var(--border-soft);
}
.question:last-child { border-bottom: none; padding-bottom: 0; }
.question .qhead {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}
.question .qlabel {
    font-weight: 500;
    font-size: 14px;
    color: var(--text);
    flex: 1;
}
.question .qlabel .req { color: var(--accent); margin-left: 4px; }
.question .qhelp {
    font-size: 12px;
    color: var(--text-dim);
    font-style: italic;
    margin-bottom: 8px;
}
.question .qactions {
    display: flex;
    gap: 4px;
    opacity: 0.3;
    transition: opacity 0.15s;
}
.question:hover .qactions { opacity: 1; }

/* Yes/No radio styling */
.yesno-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.yesno-group label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
    color: var(--text);
}
.yesno-group label:hover { border-color: #3a4353; }
.yesno-group input { display: none; }
.yesno-group input:checked + span { color: var(--text); }
.yesno-group label.is-checked,
.yesno-group label:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--text);
}

.multi-group { display: flex; flex-direction: column; gap: 6px; }
.multi-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s;
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
    color: var(--text);
    font-weight: 400;
}
.multi-group label:hover { background: var(--surface); }
.multi-group input { accent-color: var(--accent); }

/* Save indicator */
.save-indicator {
    font-size: 11px;
    color: var(--text-dim);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 100px;
}
.save-indicator .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-dim);
    transition: background 0.2s;
}
.save-indicator.saving .dot { background: var(--warn); animation: pulse 1s infinite; }
.save-indicator.saved .dot { background: var(--success); }
.save-indicator.error .dot { background: var(--accent); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.15s ease-out;
}
.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: min(560px, 92vw);
    max-height: 86vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s ease-out;
}
.modal.wide { width: min(820px, 92vw); }
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 20px;
}
.modal-body { padding: 20px 24px; }
.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--bg-soft);
}
.modal-footer.between { justify-content: space-between; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== Toast / Alert ===== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    min-width: 240px;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.2s ease-out;
    font-size: 13px;
}
.toast.success { border-left-color: var(--success); }
.toast.warn { border-left-color: var(--warn); }
.toast.info { border-left-color: var(--info); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== Progress card ===== */
.progress-card {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
}
.progress-card .stats {
    display: flex;
    gap: 24px;
    font-size: 13px;
}
.progress-card .stat .label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 2px;
}
.progress-card .stat .value { font-weight: 600; color: var(--text); }
.progress-card .progress-track {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    grid-column: 1 / -1;
    margin-top: 4px;
}
.progress-card .progress-track > div {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transition: width 0.3s;
}

/* ===== Share URL box ===== */
.share-box {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 12px;
    margin-bottom: 14px;
}
.share-box .url {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
}

/* ===== Status pill ===== */
.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--text-muted);
}
.pill.in_progress { background: rgba(78, 142, 240, 0.15); color: #7ab0ff; }
.pill.complete { background: rgba(60, 168, 106, 0.15); color: #7ad69d; }
.pill.archived { background: var(--surface-2); color: var(--text-dim); }

/* ===== Login page ===== */
.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at 20% 0%, rgba(217,34,53,0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 100%, rgba(217,34,53,0.05) 0%, transparent 40%),
        var(--bg);
}
.login-card {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}
.login-card .brand {
    text-align: center;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-soft);
}
.login-card .brand .logo {
    font-family: var(--font-serif);
    font-size: 28px;
    color: var(--text);
    font-weight: 700;
}
.login-card .brand .tag {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 6px;
}
.login-card h1 {
    font-family: var(--font-serif);
    font-size: 22px;
    margin: 0 0 8px;
}
.login-card .subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 0 24px;
}

/* ===== Client view (read-only) ===== */
.client-shell {
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% 0%, rgba(217,34,53,0.06) 0%, transparent 50%),
        var(--bg);
    padding: 24px 16px 64px;
}
.client-container {
    max-width: 820px;
    margin: 0 auto;
}
.client-banner {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 28px 32px;
    margin-bottom: 24px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 24px;
    align-items: center;
}
.client-banner .brand-tag {
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.client-banner h1 {
    font-family: var(--font-serif);
    font-size: 28px;
    margin: 0 0 4px;
}
.client-banner .client-name {
    color: var(--accent);
    font-weight: 600;
}
.client-banner .live-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(60, 168, 106, 0.08);
    border: 1px solid rgba(60, 168, 106, 0.3);
    border-radius: 100px;
    font-size: 12px;
    color: #7ad69d;
    font-weight: 500;
}
.client-banner .live-dot {
    width: 8px; height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: livePulse 1.8s infinite;
}
@keyframes livePulse {
    0% { box-shadow: 0 0 0 0 rgba(60, 168, 106, 0.5); }
    70% { box-shadow: 0 0 0 8px rgba(60, 168, 106, 0); }
    100% { box-shadow: 0 0 0 0 rgba(60, 168, 106, 0); }
}

.client-view .question {
    pointer-events: none;
    opacity: 0.95;
}
.client-view .input,
.client-view .textarea,
.client-view .select,
.client-view .yesno-group label,
.client-view .multi-group label {
    cursor: default;
}
.client-view .answer-display {
    padding: 10px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    min-height: 20px;
}
.client-view .answer-display.empty {
    color: var(--text-dim);
    font-style: italic;
}

/* Small screens */
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .sidebar.open { display: flex; position: fixed; inset: 0; z-index: 50; }
    .content { padding: 20px 16px 48px; }
    .topbar { padding: 14px 16px; }
    .client-banner { grid-template-columns: 1fr; }
}

/* Print-friendly */
@media print {
    .sidebar, .topbar, .qactions, .btn { display: none !important; }
    .app-shell { grid-template-columns: 1fr; }
    body { background: #fff; color: #000; }
}

/* ===== Scrollbar polish ===== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #374050; }

/* ==========================================================
   v3 additions — nav, tables, priority pills, danger zone
   ========================================================== */

/* Sidebar nav list */
.nav-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    transition: background 0.1s, color 0.1s;
    border: 1px solid transparent;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--accent-soft); border-color: rgba(217,34,53,0.3); color: var(--text); }
.nav-item.danger { color: #ff6b7a; }
.nav-item.danger:hover { background: rgba(217,34,53,0.1); color: #ff8a96; }

/* Priority pills (used in both tech view and client view) */
.prio-pill {
    display: inline-block;
    padding: 1px 7px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-radius: 3px;
    margin-left: 8px;
    vertical-align: middle;
}
.prio-pill.high     { background: rgba(217,34,53,0.18); color: #ff8a96; }
.prio-pill.moderate { background: rgba(232,167,58,0.18); color: #f0bd6a; }
.prio-pill.low      { background: rgba(108,116,132,0.18); color: #aab3c2; }

:root[data-theme="light"] .prio-pill.high     { background: #fde5ea; color: #c8102e; }
:root[data-theme="light"] .prio-pill.moderate { background: #fff3dc; color: #b5761a; }
:root[data-theme="light"] .prio-pill.low      { background: #eef1f5; color: #6a6a6a; }

/* Data tables (users list, audit log, company assessments) */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow: hidden;
}
.data-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    background: var(--surface);
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 13px;
    color: var(--text);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface); }
.data-table td.actions { text-align: right; white-space: nowrap; }
.data-table td.actions .btn { margin-left: 4px; }
.data-table td .meta { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* Card grid (companies list) */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 18px 20px;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card .card-title { font-family: var(--font-serif); font-size: 20px; color: var(--text); margin: 0; line-height: 1.2; }
.card .card-meta { font-size: 12px; color: var(--text-dim); display: flex; gap: 12px; flex-wrap: wrap; }
.card .card-meta span { display: flex; align-items: center; gap: 4px; }

/* Role pills */
.role-pill {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-radius: 100px;
    background: var(--surface-2);
    color: var(--text-muted);
}
.role-pill.master_admin { background: rgba(217,34,53,0.18); color: #ff8a96; }
.role-pill.admin        { background: rgba(217,34,53,0.08); color: #ff8a96; }
.role-pill.tech         { background: rgba(78,142,240,0.15); color: #7ab0ff; }
.role-pill.company_manager, .role-pill.company_viewer { background: rgba(60,168,106,0.15); color: #7ad69d; }

:root[data-theme="light"] .role-pill.master_admin { background: #fde5ea; color: #c8102e; }
:root[data-theme="light"] .role-pill.admin        { background: #fde5ea; color: #c8102e; opacity: 0.8; }
:root[data-theme="light"] .role-pill.tech         { background: #e7f1fb; color: #2b6fd1; }
:root[data-theme="light"] .role-pill.company_manager, .role-pill.company_viewer { background: #e6f4eb; color: #2d7a3e; }

/* Danger zone (master admin master-delete) */
.danger-zone {
    border: 1px solid rgba(217,34,53,0.3);
    background: rgba(217,34,53,0.04);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.danger-zone h3 { color: var(--accent); margin: 0 0 8px; font-size: 16px; }
.danger-zone p { color: var(--text-muted); font-size: 13px; margin: 0 0 12px; }

/* Audit log row */
.audit-row {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 13px;
    display: grid;
    grid-template-columns: 150px 120px 1fr;
    gap: 14px;
    align-items: baseline;
}
.audit-row:hover { background: var(--surface); }
.audit-row .ts { color: var(--text-dim); font-family: var(--font-mono); font-size: 11px; }
.audit-row .actor { font-weight: 500; }
.audit-row .action { color: var(--text-muted); }
.audit-row .action strong { color: var(--text); }
.audit-row pre { background: var(--bg); border: 1px solid var(--border-soft); padding: 6px 10px; margin: 4px 0 0; font-size: 11px; color: var(--text-muted); border-radius: 4px; overflow-x: auto; }


/* ==========================================================
   Action items — flag dropdown, visible indicators, list page
   ========================================================== */

/* Flag dropdown row under each question */
.action-flag-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    font-size: 12px;
}
.action-flag-row .label {
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    font-size: 10px;
}
.action-flag-row select {
    padding: 4px 8px;
    font-size: 12px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
}
.action-flag-row .stamp {
    margin-left: auto;
    color: var(--text-dim);
    font-size: 11px;
}

/* Visible flag indicator — left-border accent + background tint on the whole question */
.question.flagged-client { border-left: 3px solid var(--info); padding-left: 12px; background: rgba(78,142,240,0.04); }
.question.flagged-tech   { border-left: 3px solid var(--accent); padding-left: 12px; background: rgba(217,34,53,0.04); }
:root[data-theme="light"] .question.flagged-client { background: rgba(43,111,209,0.04); }
:root[data-theme="light"] .question.flagged-tech   { background: rgba(200,16,46,0.03); }

/* Badge next to the Action Items nav item */
.nav-item .badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 7px;
    font-size: 10px;
    font-weight: 700;
    background: var(--accent);
    color: #fff;
    border-radius: 10px;
    line-height: 1.4;
}
.nav-item .badge.zero { display: none; }

/* Action Items page layout */
.actions-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    flex-wrap: wrap;
}
.actions-toolbar .spacer { flex: 1; }
.actions-toolbar .tab {
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-muted);
    border: 1px solid transparent;
    background: transparent;
}
.actions-toolbar .tab:hover { color: var(--text); }
.actions-toolbar .tab.active { background: var(--surface); color: var(--text); border-color: var(--border); }
.actions-toolbar .tab .count {
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 10px;
    background: var(--surface-2);
    color: var(--text-muted);
    border-radius: 8px;
    font-weight: 600;
}
.actions-toolbar .tab.active .count { background: var(--accent); color: #fff; }

/* Grouped action list */
.action-group { margin-bottom: 28px; }
.action-group-title {
    font-family: var(--font-serif);
    font-size: 20px;
    color: var(--text);
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.action-group-title .chip {
    font-family: var(--font-sans);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.action-group.tech   .action-group-title .chip { background: rgba(217,34,53,0.18); color: #ff8a96; }
.action-group.client .action-group-title .chip { background: rgba(78,142,240,0.18); color: #7ab0ff; }
:root[data-theme="light"] .action-group.tech   .action-group-title .chip { background: #fde5ea; color: #c8102e; }
:root[data-theme="light"] .action-group.client .action-group-title .chip { background: #e7f1fb; color: #2b6fd1; }

.action-company {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 12px;
}
.action-company-name {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-item {
    padding: 10px 12px;
    margin: 6px 0;
    background: var(--surface);
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 1px solid transparent;
    transition: border-color 0.1s;
}
.action-item:hover { border-color: var(--accent); }
.action-item .breadcrumb {
    font-size: 11px;
    color: var(--text-dim);
    margin-bottom: 4px;
}
.action-item .q {
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
    line-height: 1.4;
}
.action-item .details {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.5;
}
.action-item .details strong { color: var(--text); font-weight: 500; }
.action-item .notes {
    margin-top: 6px;
    padding: 8px 10px;
    background: var(--bg);
    border-left: 2px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    white-space: pre-wrap;
    border-radius: 0 4px 4px 0;
}

/* v4: client-editable badge on questions */
.ce-badge {
    display: inline-block;
    margin-left: 6px;
    font-size: 11px;
    opacity: 0.7;
    vertical-align: middle;
}
.ce-badge:hover { opacity: 1; }

/* Breadcrumbs in the topbar subtitle */
.breadcrumb-link {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}
.breadcrumb-link:hover { color: var(--accent); text-decoration: underline; }

/* ==========================================================
   Project editor — data entry (deliverables / hardware / recurring,
   scope & overview forms). Scoped with .pe- prefix.
   ========================================================== */
.pe-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.pe-toolbar h3 { font-family: var(--font-serif); font-size: 18px; margin: 0; }
.pe-hint { font-size: 12px; color: var(--text-muted); margin: 0 0 12px; max-width: 760px; line-height: 1.5; }

/* Inline editable inputs inside data-entry tables */
.pe-in {
    width: 100%;
    padding: 7px 9px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    transition: border-color 0.15s, background 0.15s;
}
.pe-in:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.pe-in:disabled { opacity: 0.6; cursor: not-allowed; }
.pe-in.num { text-align: right; font-variant-numeric: tabular-nums; }
.pe-money { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* Data-entry table */
.pe-table { width: 100%; border-collapse: collapse; background: var(--bg-soft); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; }
.pe-table th {
    text-align: left; padding: 9px 12px;
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-dim); font-weight: 600;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.pe-table th.r, .pe-table td.r { text-align: right; }
.pe-table td { padding: 8px 12px; border-bottom: 1px solid var(--border-soft); font-size: 13px; color: var(--text); vertical-align: middle; }
.pe-table tbody tr:hover { background: var(--surface); }
.pe-table tfoot td { background: var(--surface); font-weight: 600; border-top: 1px solid var(--border); border-bottom: none; }
.pe-actions { text-align: right; white-space: nowrap; }
.pe-actions .btn { margin-left: 2px; }
.pe-ovr { color: var(--warn, #b06000); cursor: help; margin-left: 4px; }

/* Hardware two-tier rows: main row + a sub-row of sourcing/logistics fields */
.pe-row-main td { border-bottom: none; padding-bottom: 4px; }
.pe-row-sub td { padding-top: 0; padding-bottom: 12px; }
.pe-row-sub:hover { background: transparent; }
.pe-sub {
    display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
}
.pe-field { display: flex; flex-direction: column; gap: 3px; flex: 1 1 130px; }
.pe-field > span { font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); }
.pe-field input {
    padding: 5px 8px; font-size: 12px;
    background: var(--bg-soft); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text); width: 100%;
}
.pe-field input:focus { outline: none; border-color: var(--accent); }
.pe-field input:disabled { opacity: 0.6; cursor: not-allowed; }
.pe-flags { display: flex; gap: 14px; align-items: center; flex: 0 0 auto; padding-bottom: 5px; }
.pe-chk { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-muted); cursor: pointer; white-space: nowrap; }
.pe-chk input { margin: 0; }

/* Project-builder field labels use <label class="field"><span>…</span> (not a nested label) */
.field > span {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.pe-help {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-dim);
    text-transform: none;
    letter-spacing: normal;
    margin: -2px 0 6px;
}
/* Settings page grouped cards */
.pe-settings-card {
    background: var(--bg-soft);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 18px 20px;
}

/* Scope & overview forms */
.pe-form { max-width: 720px; display: flex; flex-direction: column; gap: 16px; }
.pe-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pe-section-title { font-family: var(--font-serif); font-size: 15px; margin: 20px 0 2px; padding-bottom: 6px; border-bottom: 1px solid var(--border-soft); color: var(--text); }
@media (max-width: 720px) { .pe-grid2 { grid-template-columns: 1fr; } }

/* Inline Syncro product lookup dropdown (appended to body, fixed-positioned over inputs/modals) */
.pe-typeahead {
    position: fixed; z-index: 9999;
    max-height: 280px; overflow-y: auto;
    background: var(--bg); border: 1px solid var(--accent);
    border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(0,0,0,0.30);
}
.pe-ta-item { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border-soft); }
.pe-ta-item:last-child { border-bottom: none; }
.pe-ta-item:hover, .pe-ta-item.active { background: var(--surface); }
.pe-ta-name { color: var(--text); }
.pe-ta-meta { color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pe-ta-empty { padding: 8px 12px; font-size: 12px; color: var(--text-dim); }
