:root {
    --bg: #0a0806;
    --panel: #15110c;
    --panel-border: #2e2415;
    --gold: #e8b84b;
    --gold-dim: #5c4720;
    --text: #ede6d6;
    --text-dim: #9c9184;
    --danger: #ff5b5b;
    --ok: #58e08a;
}

* { box-sizing: border-box; }

/* Guardrail: this bit twice now (.modal-backdrop, .attachment-chip) - a
   class with an unconditional "display: flex/block" beats the browser's
   default [hidden] { display: none }, since that UA rule isn't !important.
   This makes [hidden] unconditionally win instead, so toggling the hidden
   attribute in JS always actually hides the element, no matter what other
   display rule a class sets. Keep individual :not([hidden]) scoping too
   where it exists - this is just the backstop. */
[hidden] { display: none !important; }

/* Themed scrollbars - Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--gold-dim) var(--bg);
}

/* Themed scrollbars - Chrome/Safari/Edge */
::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--gold-dim);
    border-radius: 5px;
    border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold);
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "SF Mono", "Menlo", ui-monospace, monospace;
    height: 100%;
}

.shell {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--panel-border);
    padding: 24px 0;
}

.brand {
    color: var(--gold);
    font-weight: 700;
    letter-spacing: 4px;
    font-size: 14px;
    padding: 0 24px 24px;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 12px;
    text-shadow: 0 0 12px rgba(232, 184, 75, 0.6);
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    letter-spacing: 1px;
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
}

.nav-link:hover:not(.disabled) {
    color: var(--text);
    background: rgba(232, 184, 75, 0.06);
}

.nav-link.active {
    color: var(--gold);
    border-left-color: var(--gold);
    background: rgba(232, 184, 75, 0.08);
}

.nav-link.disabled {
    pointer-events: none;
    opacity: 0.35;
}

.soon {
    font-size: 9px;
    border: 1px solid var(--text-dim);
    border-radius: 3px;
    padding: 1px 4px;
}

/* --- Content --- */
.content {
    flex: 1;
    padding: 32px 40px;
}

h1, h2, h3 {
    font-weight: 600;
    letter-spacing: 1px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 20px;
}

/* --- Orb page --- */
.home-page {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.attention-panel {
    width: 100%;
}

.attention-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
}

.attention-card {
    display: block;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 18px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease;
}

.attention-card:hover {
    border-color: var(--gold-dim);
}

.attention-card.has-items {
    border-color: var(--gold-dim);
    box-shadow: 0 0 14px rgba(232, 184, 75, 0.15);
}

.attention-value {
    font-size: 28px;
    color: var(--gold);
    font-weight: 700;
}

.attention-card:not(.has-items) .attention-value {
    color: var(--text-dim);
}

.attention-label {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 4px;
}

/* --- Floating chat widget (Hermes), shared across every page --- */

#chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
}

#chat-widget-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 22px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

#chat-widget-panel:not([hidden]) {
    display: flex;
}

#chat-widget-panel {
    flex-direction: column;
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 48px);
    height: 480px;
    max-height: calc(100vh - 120px);
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.chat-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--panel-border);
    color: var(--gold);
    font-weight: 700;
    letter-spacing: 2px;
    font-size: 13px;
    flex-shrink: 0;
}

.chat-widget-header button {
    padding: 2px 8px;
    font-size: 16px;
    line-height: 1;
}

.chat-widget-controls {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-top: 1px solid var(--panel-border);
    flex-shrink: 0;
}

.chat-widget-controls input[type="text"] {
    flex: 1;
    min-width: 0;
}

.chat-widget-controls button {
    padding: 8px 10px;
    font-size: 13px;
    flex-shrink: 0;
}

#widget-transcript {
    flex: 1;
    max-width: none;
    padding: 12px 16px;
    margin: 0;
}

#widget-attachment-chip {
    max-width: none;
    margin: 0 12px;
    border-radius: 6px;
}

.transcript {
    width: 100%;
    max-width: 640px;
    flex: 1;
    overflow-y: auto;
    margin: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 4px;
}

.msg {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.4;
}

.msg.user {
    align-self: flex-end;
    background: rgba(232, 184, 75, 0.12);
    border: 1px solid var(--gold-dim);
}

.msg.assistant {
    align-self: flex-start;
    background: var(--panel);
    border: 1px solid var(--panel-border);
}

.controls {
    width: 100%;
    max-width: 640px;
    display: flex;
    gap: 10px;
    padding-bottom: 24px;
}

.attachment-chip {
    width: 100%;
    max-width: 640px;
    background: var(--panel);
    border: 1px solid var(--gold-dim);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 12px;
    color: var(--text);
}

/* Same [hidden]-vs-unconditional-"display" conflict as .modal-backdrop -
   scope the flex layout to when it's actually shown. */
.attachment-chip:not([hidden]) {
    display: flex;
    align-items: center;
    gap: 8px;
}

.attachment-chip #attachment-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-chip button {
    padding: 2px 8px;
    font-size: 14px;
    line-height: 1;
}

#text-input {
    flex: 1;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
}

#text-input:focus {
    outline: none;
    border-color: var(--gold-dim);
}

button {
    background: var(--panel);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    padding: 10px 18px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    letter-spacing: 1px;
    transition: all 0.15s ease;
}

button:hover {
    background: rgba(232, 184, 75, 0.1);
}

button.mic-active {
    background: var(--gold);
    color: #1a1206;
    box-shadow: 0 0 16px rgba(232, 184, 75, 0.6);
}

.badge {
    font-size: 10px;
    letter-spacing: 1px;
    padding: 3px 8px;
    border-radius: 10px;
    border: 1px solid var(--panel-border);
    color: var(--text-dim);
}

.badge.live { color: var(--ok); border-color: var(--ok); }
.badge.sample { color: var(--text-dim); }

/* --- Cold Email page --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin: 20px 0 28px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 18px;
}

.stat-value {
    font-size: 28px;
    color: var(--gold);
    font-weight: 700;
}

.stat-label {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--panel-border);
}

th {
    color: var(--text-dim);
    font-weight: 500;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-size: 10px;
}

.status-pill {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-sent, .status-pending, .status-delivered, .status-new { color: var(--text-dim); border: 1px solid var(--text-dim); }
.status-running, .status-opened, .status-qualified, .status-emailed { color: var(--gold); border: 1px solid var(--gold-dim); }
.status-replied, .status-completed, .status-interested, .status-booked { color: var(--ok); border: 1px solid var(--ok); }
.status-bounced, .status-failed, .status-disqualified, .status-not_interested, .status-lost, .status-invalid { color: var(--danger); border: 1px solid var(--danger); }
.status-valid { color: var(--ok); border: 1px solid var(--ok); }
.status-catch_all, .status-unverified, .status-unknown { color: var(--text-dim); border: 1px solid var(--text-dim); }

#timeline-canvas {
    width: 100%;
    height: 160px;
}

/* --- Tabs --- */
.tab-bar {
    display: flex;
    gap: 4px;
    margin: 18px 0 20px;
    border-bottom: 1px solid var(--panel-border);
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--text-dim);
    padding: 10px 14px;
    font-size: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.tab-btn:hover {
    color: var(--text);
    background: none;
}

.tab-btn.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

.empty-note {
    color: var(--text-dim);
    font-size: 12px;
    padding: 14px 0 2px;
}

/* --- Forms --- */
.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: var(--text-dim);
}

/* Base control styling. Applies whether the input/select IS a .field
   itself (e.g. the leads search box, the date-range dropdowns) or sits
   nested inside a .field label (e.g. the add-account form) - a plain
   ".field input" descendant rule missed the first case, which is why
   some dropdowns/search boxes were showing raw browser defaults. */
input, select, textarea {
    background: var(--bg);
    border: 1px solid var(--panel-border);
    color: var(--text);
    padding: 9px 12px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold-dim);
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%239c9184' stroke-width='1.5' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 30px;
    cursor: pointer;
}

select option {
    background: var(--panel);
    color: var(--text);
}

.link-btn {
    background: none;
    border: none;
    color: var(--gold);
    padding: 0;
    font-size: 12px;
    text-decoration: underline;
    cursor: pointer;
}

/* --- Modal --- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 50;
}

/* [hidden]'s UA default is display:none, but that's not !important, so an
   unconditional "display: flex" here would beat it every time regardless of
   the hidden attribute. Scope it to :not([hidden]) so hiding actually works. */
.modal-backdrop:not([hidden]) {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-box {
    width: min(640px, 90vw);
    max-height: 80vh;
    overflow-y: auto;
}

.modal-field-label {
    color: var(--text-dim);
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 14px;
}

.modal-field-value {
    white-space: pre-wrap;
    margin-top: 4px;
}

/* --- "Managed by" agent badge --- */
.agent-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-dim);
    font-size: 13px;
}

.agent-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--panel);
    border: 2px solid var(--gold);
    box-shadow: 0 0 10px rgba(232, 184, 75, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    color: var(--gold);
    overflow: hidden;
    flex-shrink: 0;
}

.agent-avatar img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.agent-name {
    color: var(--text);
    font-weight: 600;
}

/* --- Timeline / lifecycle pipeline --- */
.timeline {
    position: relative;
    padding-left: 34px;
}

.timeline::before {
    content: "";
    position: absolute;
    left: 13px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--panel-border);
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -34px;
    top: 0;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: var(--panel);
    border: 2px solid var(--gold-dim);
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
}

.timeline-item-exception .timeline-marker {
    border-color: var(--danger);
    color: var(--danger);
}

.timeline-title {
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
}

.timeline-item-exception .timeline-title {
    color: var(--danger);
}

.timeline-desc {
    color: var(--text-dim);
    font-size: 12px;
    margin-top: 2px;
}

/* Per-client progress states (Fulfillment tab) */
.timeline-item.done .timeline-marker {
    background: var(--ok);
    border-color: var(--ok);
    color: var(--bg);
}

.timeline-item.done .timeline-title {
    color: var(--text-dim);
}

.timeline-item.active .timeline-marker {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--bg);
    box-shadow: 0 0 10px rgba(232, 184, 75, 0.6);
}

.timeline-item.active .timeline-title {
    color: var(--gold);
}

.timeline-item.pending .timeline-marker {
    opacity: 0.4;
}

.timeline-item.pending .timeline-title,
.timeline-item.pending .timeline-desc {
    opacity: 0.4;
}

.plain-list {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.8;
}

/* --- Fulfillment: quick links + per-category logs --- */
.quick-link-btn {
    font-size: 12px;
}

.log-entries {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.log-entry {
    background: var(--bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.log-entry-body {
    font-size: 13px;
    color: var(--text);
    white-space: pre-wrap;
}

.log-entry-meta {
    font-size: 11px;
    color: var(--text-dim);
    flex-shrink: 0;
    white-space: nowrap;
}

/* --- Fulfillment: per-client asset library + chat --- */
.asset-entries {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.asset-entry {
    background: var(--bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.asset-entry-name {
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asset-entry-meta {
    font-size: 11px;
    color: var(--text-dim);
    flex-shrink: 0;
}

.asset-entry-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.asset-entry-actions button {
    padding: 4px 10px;
    font-size: 11px;
}

.client-chat-controls {
    margin-top: 12px;
    padding-bottom: 0;
}

/* --- SEO tab: visualized initial audit report --- */
.seo-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.seo-stat-tile {
    background: var(--bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}

.seo-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--gold);
}

.seo-stat-label {
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 4px;
}

.seo-section {
    background: var(--bg);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 16px 18px;
    margin-bottom: 14px;
}

.seo-section h3 {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--gold);
}

.seo-section p {
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
    margin: 0 0 8px;
}

.seo-section.summary {
    border-color: var(--gold-dim);
    box-shadow: 0 0 14px rgba(232, 184, 75, 0.1);
}

.seo-section.blocked h3 {
    color: var(--danger);
}

.seo-subsection {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--panel-border);
}

.seo-subsection h4 {
    margin: 0 0 6px;
    font-size: 13px;
    color: var(--text);
}
