﻿/* ============================================================
   layout.css — App shell, sidebar, topbar, page structure
   Built against the real tokens extracted from the Claude
   Design mockups (Marketing, Invoice Builder v2, Auth).
   ============================================================ */

/* ── App Shell ── */
.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--color-bg);
}

/* ── Sidebar (dark — matches the mockup's navy-purple sidebar) ── */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--color-sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
/* Deliberately no overflow-y here — .sidebar-nav (below) owns its own
   scroll via flex:1 + overflow-y:auto. Setting it on the outer aside too
   would clip anything absolutely-positioned that extends past the aside's
   own box (e.g. the business switcher dropdown), the same overflow-x/
   overflow-y clipping quirk noted on .table-container. */

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-4);
}

.sidebar-logo-icon {
    width: 34px;
    height: 34px;
    background: var(--color-primary);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.sidebar-logo-name {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    color: var(--color-white);
}

/* ── Business switcher (below the app logo) ── */
.sidebar-business-switcher-wrap {
    position: relative;
    padding: 0 var(--space-3) var(--space-3);
}

.sidebar-business-switcher {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.06);
    transition: background var(--transition-fast);
}

    .sidebar-business-switcher:hover {
        background: rgba(255, 255, 255, 0.1);
    }

.sidebar-business-avatar {
    width: 28px;
    height: 28px;
    background: var(--color-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    color: var(--color-white);
    flex-shrink: 0;
    overflow: hidden;
}

.business-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-business-switcher-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.sidebar-business-switcher-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-white);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-business-switcher-hint {
    font-size: 11px;
    color: var(--color-sidebar-item);
}

.sidebar-business-switcher-chevron {
    color: var(--color-sidebar-item);
    flex-shrink: 0;
    transition: transform var(--transition-fast);
}

    .sidebar-business-switcher-chevron.open {
        transform: rotate(180deg);
    }

.sidebar-business-dropdown {
    left: 0;
    right: 0;
    top: calc(100% + var(--space-2));
    max-height: 340px;
    overflow-y: auto;
}

.business-dropdown-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3) var(--space-3);
}

.business-dropdown-avatar-lg {
    width: 40px;
    height: 40px;
    background: var(--color-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    color: var(--color-white);
    flex-shrink: 0;
    overflow: hidden;
}

.business-dropdown-current-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 2px;
}

.business-dropdown-upload-btn {
    display: inline-block;
    border: none;
    background: none;
    padding: 0;
    font-size: var(--font-size-xs);
    color: var(--color-primary);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
}

    .business-dropdown-upload-btn.disabled {
        color: var(--color-text-muted);
        cursor: not-allowed;
        pointer-events: none;
    }

.business-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.business-dropdown-avatar {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: var(--font-weight-bold);
    flex-shrink: 0;
}

.business-dropdown-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.business-dropdown-check {
    color: var(--color-primary);
    flex-shrink: 0;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-3) var(--space-3);
    overflow-y: auto;
    /* Stops the scroll CHAINING to the page underneath. Without this, reaching
       the bottom of the nav list hands the remaining scroll to the document,
       which moves the page behind the open drawer -- and .app-topbar is
       position:sticky, so the top bar visibly travels up while the nav is
       still covering it. On a phone that reads as the nav itself sliding away.
       Nothing locks body scroll while the sidebar is open, so this is what
       holds the boundary. */
    overscroll-behavior: contain;
}

.sidebar-nav-label {
    display: block;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-sidebar-item);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.6;
    padding: 0 var(--space-3);
    margin-bottom: var(--space-2);
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-medium);
    color: var(--color-sidebar-item);
    transition: all var(--transition-fast);
    text-decoration: none;
    margin-bottom: 2px;
}

    .sidebar-nav-item:hover {
        background: rgba(255, 255, 255, 0.06);
        color: var(--color-white);
        text-decoration: none;
    }

    .sidebar-nav-item.active {
        background: var(--color-sidebar-active);
        color: var(--color-white);
    }

/* Promo/reminder card at the bottom of the sidebar
   (e.g. "VAT return due" shown in the dashboard mockup) */
.sidebar-promo-card {
    margin: var(--space-3);
    padding: var(--space-4);
    background: var(--color-sidebar-active);
    border-radius: var(--radius-lg);
}

.sidebar-promo-title {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-white);
    margin-bottom: 2px;
}

.sidebar-promo-subtitle {
    font-size: var(--font-size-xs);
    color: var(--color-sidebar-item);
}

.sidebar-promo-progress {
    margin-top: var(--space-3);
    height: 4px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.sidebar-promo-progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-full);
}

/* User footer at the very bottom of the sidebar */
.sidebar-footer {
    padding: var(--space-3);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

    .sidebar-user:hover {
        background: rgba(255, 255, 255, 0.06);
    }

.sidebar-user-avatar {
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    color: var(--color-white);
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}

.sidebar-user-name {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-white);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-role {
    font-size: var(--font-size-xs);
    color: var(--color-sidebar-item);
}

/* ── Main Area ── */
.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ── Top Bar ── */
.app-topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 0 var(--space-8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

/* THE TOPBAR CAPS ITS OWN POPOVERS, which is the price of the arrangement
   MainLayout explains: the notification panel and the user menu live INSIDE
   .app-topbar so they share its stacking context with their click-outside
   overlay. That context is z-index 40, and z-index cannot escape an ancestor
   context, so both panels are pinned at 40 whatever they ask for -- and every
   picker dropdown on the page is at --z-modal (200) to clear the drawer.
   Measured: with the notification panel open on a phone and a catalogue picker
   open on the invoice behind it, the picker painted through the panel.

   Raising the whole bar, but only while a panel is open, so the sticky header
   keeps its ordinary 40 the rest of the time. Same +5 as the Nova launcher: over
   dropdowns and the drawer overlay, under .modal-overlay and its confirm. */
.app-topbar.has-popover {
    z-index: calc(var(--z-modal) + 5);
}

.topbar-left {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.topbar-eyebrow {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.topbar-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
}

.topbar-search {
    flex: 1;
    max-width: 360px;
    margin: 0 var(--space-6);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    position: relative;
    flex-shrink: 0;
}

.topbar-icon-btn {
    position: relative;
    width: 38px;
    height: 38px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: all var(--transition-fast);
}

    .topbar-icon-btn:hover {
        background: var(--color-bg);
    }

.topbar-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--color-danger);
    color: var(--color-white);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: var(--font-weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--color-surface);
    animation: topbar-badge-pulse 2s ease-in-out infinite;
}

@keyframes topbar-badge-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
    50%      { box-shadow: 0 0 0 5px rgba(220, 38, 38, 0); }
}

.topbar-avatar {
    width: 36px;
    height: 36px;
    background: var(--color-primary);
    color: var(--color-white);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    flex-shrink: 0;
    cursor: pointer;
}

/* ── Notification Dropdown Panel ── */
.notif-panel {
    position: absolute;
    top: calc(100% + var(--space-3));
    right: 0;
    width: 400px;
    max-height: 520px;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: var(--z-dropdown);
}

.notif-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5);
    border-bottom: 1px solid var(--color-border-light);
}

.notif-panel-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
}

.notif-panel-mark-all {
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    cursor: pointer;
}

.notif-section-label {
    padding: var(--space-4) var(--space-5) var(--space-2);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.notif-item {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--color-border-light);
}

    .notif-item:last-child {
        border-bottom: none;
    }

    .notif-item:hover {
        background: var(--color-bg);
    }

    .notif-item.unread {
        background: var(--color-primary-light);
    }

        .notif-item.unread:hover {
            background: #e4e6fc;
        }

.notif-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--color-primary-light);
    color: var(--color-primary);
}

    .notif-icon.warning {
        background: var(--color-warning-light);
        color: var(--color-warning);
    }

    .notif-icon.danger {
        background: var(--color-danger-light);
        color: var(--color-danger);
    }

    .notif-icon.success {
        background: var(--color-success-light);
        color: var(--color-success);
    }

.notif-content {
    flex: 1;
    min-width: 0;
}

.notif-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-primary);
    line-height: var(--line-height-normal);
}

.notif-time {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: 2px;
}

.notif-unread-dot {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    flex-shrink: 0;
    margin-top: 6px;
}

.notif-panel-footer {
    padding: var(--space-4) var(--space-5);
    text-align: center;
    border-top: 1px solid var(--color-border-light);
}

/* ── Agent Chat: floating trigger + drawer ──
   Fixed to the viewport (not the topbar) so it's reachable from anywhere
   on the page, not just when scrolled to the top. */
.agent-chat-fab-wrap {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-dropdown);
}

/* THE LAUNCHER AND THE OPEN PANEL ARE NOT THE SAME LAYER.

   Closed, the wrap stays at --z-dropdown, which is what keeps the button
   BEHIND the slide-in drawer. That matters: the button is fixed to the
   bottom-right corner and the drawer's footer puts Save in the same corner,
   so a launcher floating above an open drawer would sit on top of it.

   Open, it has to clear --z-modal. Every picker dropdown is set to --z-modal
   to escape that same drawer overlay (see .searchable-select-dropdown), so at
   --z-dropdown the panel rendered UNDERNEATH any list that happened to be
   open on the page behind it -- reported as a catalogue dropdown from the
   invoice builder floating over Nova's suggestions.

   +5 clears dropdowns and the drawer overlay while staying under .modal-overlay
   (+10) and .modal-overlay.is-confirm (+20), so a dialog opened from anywhere
   is still answerable, and under --z-toast so Nova's own toasts are readable. */
.agent-chat-fab-wrap.is-open {
    z-index: calc(var(--z-modal) + 5);
}

.agent-chat-fab {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--color-primary);
    color: var(--color-white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-xl);
    cursor: pointer;
    transition: transform var(--transition-fast);
}

    .agent-chat-fab:hover {
        transform: scale(1.06);
    }

.agent-chat-panel {
    position: absolute;
    bottom: calc(100% + var(--space-3));
    right: 0;
    width: 420px;
    height: 520px;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

/* Expanded. 420x520 is fine for "what's my balance" and cramped for the work
   the drawer is actually used for — reading a report table or building a
   purchase order, where the reply wraps badly and the owner loses the page
   they were working from. Capped against the viewport so it can never grow
   past the window on a laptop, and the height leaves the launcher visible. */
.agent-chat-panel.is-expanded {
    width: min(760px, calc(100vw - var(--space-6)));
    height: min(760px, calc(100vh - 140px));
}

.agent-chat-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.agent-chat-header-identity {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.agent-chat-close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

    .agent-chat-close:hover {
        background: var(--color-bg);
        color: var(--color-text-primary);
    }

.agent-chat-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--color-primary), var(--color-admin));
    color: var(--color-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
}

.agent-chat-title-group {
    display: flex;
    flex-direction: column;
    line-height: var(--line-height-tight);
}

.agent-chat-title {
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-bold);
    color: var(--color-text-primary);
}

.agent-chat-subtitle {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
}

.agent-chat-usage {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-5);
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.agent-chat-usage-bar {
    flex: 1;
    height: 4px;
    border-radius: var(--radius-full);
    background: var(--color-border-light);
    overflow: hidden;
}

.agent-chat-usage-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

.agent-chat-usage-label {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.agent-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.agent-chat-empty {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    line-height: var(--line-height-normal);
    padding: var(--space-4) 0 var(--space-3);
}

.agent-chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.agent-chat-suggestion {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

    .agent-chat-suggestion:hover {
        background: var(--color-primary-light);
        border-color: var(--color-primary);
        color: var(--color-primary);
    }

    .agent-chat-suggestion:disabled {
        opacity: 0.6;
        cursor: default;
    }

.agent-chat-message {
    max-width: 85%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
}

.agent-chat-message-user {
    align-self: flex-end;
    background: var(--color-primary);
    color: var(--color-white);
    white-space: pre-wrap;
}

.agent-chat-message-assistant {
    align-self: flex-start;
    background: var(--color-bg);
    color: var(--color-text-primary);
}

/* The record's own state, printed beside what Nova said about it. Styled to
   read as a label rather than prose — it is the app talking, not the
   assistant, and the difference has to be visible at a glance. */
.agent-chat-status-chip {
    display: inline-block;
    margin-top: var(--space-2);
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    letter-spacing: 0.02em;
    font-variant-numeric: tabular-nums;
}

.agent-chat-status-good {
    background: var(--color-success-light);
    border-color: var(--color-success);
    color: var(--color-success-text);
}

/* Draft, or ordered-but-never-sent. Not an error — just not what "done"
   sounds like, which is exactly when it needs to be legible. */
.agent-chat-status-warn {
    background: var(--color-warning-light);
    border-color: var(--color-warning);
    color: var(--color-warning-text);
}

.agent-chat-status-neutral {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text-secondary);
}

    .agent-chat-message-assistant p,
    .agent-chat-message-assistant ul,
    .agent-chat-message-assistant ol {
        margin: 0 0 var(--space-2);
    }

    .agent-chat-message-assistant ul,
    .agent-chat-message-assistant ol {
        padding-left: var(--space-5);
    }

    .agent-chat-message-assistant p:last-child,
    .agent-chat-message-assistant ul:last-child,
    .agent-chat-message-assistant ol:last-child {
        margin-bottom: 0;
    }

    .agent-chat-message-assistant a {
        color: var(--color-primary);
        font-weight: 600;
        text-decoration: underline;
    }

    .agent-chat-message-assistant strong {
        font-weight: 700;
    }

    .agent-chat-message-assistant table {
        border-collapse: collapse;
        font-size: var(--font-size-xs);
        margin-bottom: var(--space-2);
    }

    .agent-chat-message-assistant th,
    .agent-chat-message-assistant td {
        padding: var(--space-1) var(--space-2);
        border: 1px solid var(--color-border-light);
    }

/* A reply carrying a report-engine table takes the drawer's full width:
   a table squeezed into 85% scrolls sideways for no reason. */
.agent-chat-message-wide {
    max-width: 100%;
    width: 100%;
    /* Padding inside the 100%, or the bubble overhangs the drawer by its own
       padding and the whole conversation scrolls sideways. */
    box-sizing: border-box;
    min-width: 0;
}

.nova-report {
    margin: var(--space-2) 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    overflow: hidden;
}

.nova-report-note {
    padding: var(--space-3);
    color: var(--color-text-secondary);
}

.nova-report-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-2);
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border-light);
}

.nova-report-title {
    font-weight: 700;
}

.nova-report-meta {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

.nova-report-actions {
    display: flex;
    gap: var(--space-1);
    flex-shrink: 0;
}

.nova-report-scroll {
    overflow: auto;
    max-height: 460px;
}

.agent-chat-message-assistant .nova-report-table,
.nova-report .nova-report-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin: 0;
    font-size: var(--font-size-xs);
    font-variant-numeric: tabular-nums;
}

    .agent-chat-message-assistant .nova-report-table th,
    .nova-report .nova-report-table th,
    .agent-chat-message-assistant .nova-report-table td,
    .nova-report .nova-report-table td {
        border: none;
        border-bottom: 1px solid var(--color-border-light);
        padding: var(--space-1) var(--space-2);
        white-space: nowrap;
        text-align: left;
    }

    .nova-report-table th {
        position: sticky;
        top: 0;
        z-index: 2;
        background: var(--color-surface);
        font-weight: 700;
    }

    /* The name stays in view while the figures scroll sideways on a phone. */
    .nova-report-table th:first-child,
    .nova-report-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        background: var(--color-surface);
        max-width: 160px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .nova-report-table th:first-child {
        z-index: 3;
    }

    .agent-chat-message-assistant .nova-report-table .num,
    .nova-report .nova-report-table .num {
        text-align: right;
    }

.nova-report-section td {
    font-weight: 700;
    background: var(--color-bg) !important;
}

    .nova-report-section td span {
        font-weight: 400;
        color: var(--color-text-secondary);
    }

.nova-report-subtotal td {
    font-style: italic;
    color: var(--color-text-secondary);
}

.nova-report-total td {
    font-weight: 700;
    border-top: 2px solid var(--color-border);
}

.agent-chat-message-assistant .nova-report-table td.nova-report-bad,
.nova-report .nova-report-table td.nova-report-bad {
    background: var(--color-danger-light);
    color: var(--color-danger-text);
}

.agent-chat-message-assistant .nova-report-table td.nova-report-warn,
.nova-report .nova-report-table td.nova-report-warn {
    background: var(--color-warning-light);
    color: var(--color-warning-text);
}

.agent-chat-message-assistant .nova-report-table td.nova-report-good,
.nova-report .nova-report-table td.nova-report-good {
    background: var(--color-success-light);
    color: var(--color-success-text);
}

.agent-chat-message-assistant .nova-report-table td.nova-report-muted,
.nova-report .nova-report-table td.nova-report-muted {
    color: var(--color-text-muted);
}

.nova-report-more {
    display: block;
    width: 100%;
    padding: var(--space-2);
    border: none;
    border-top: 1px solid var(--color-border-light);
    background: none;
    color: var(--color-primary);
    font-weight: 600;
    cursor: pointer;
}

.nova-report-rules {
    padding: var(--space-2) var(--space-3);
    border-top: 1px solid var(--color-border-light);
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
}

    .nova-report-rules summary {
        cursor: pointer;
        font-weight: 600;
    }

    .agent-chat-message-assistant .nova-report-rules ul,
    .nova-report .nova-report-rules ul {
        margin: var(--space-2) 0 0;
        padding-left: var(--space-4);
    }

.agent-chat-message-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
}

/* The longer wait, under the dots. Borrows .nova-rail and .nova-row-text from
   the dashboard summary so a slow answer looks the same in both places —
   narrower here, since it sits in a drawer rather than a card, and shown only
   once a turn has run past the point where three dots stop reassuring anyone.
   The dots stay: they are the "a reply is coming" signal, and this is the
   "it is taking a while" one. */
.agent-chat-waiting {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-width: 260px;
    /* Top padding matches what the dots carried, since this replaces them
       rather than sitting under them — without it the panel jumps up against
       the last message at the moment of handover. */
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

    .agent-chat-waiting .nova-rail {
        margin-bottom: 0;
    }

.agent-chat-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-full);
    background: var(--color-text-muted);
    animation: agent-chat-typing-bounce 1.2s infinite ease-in-out both;
}

.agent-chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.agent-chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.agent-chat-typing-dot:nth-child(3) { animation-delay: 0s; }

@keyframes agent-chat-typing-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.agent-chat-input-row {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--color-border-light);
    flex-shrink: 0;
    /* flex-end, so the attach and Send buttons stay pinned to the bottom edge
       as the message box grows instead of stretching to match its height. */
    align-items: flex-end;
}

    .agent-chat-input-row .form-control {
        flex: 1;
    }

/* The message box is a textarea now, sized from JS (balanceBlitz.growChatInput).
   resize:none because the browser's drag handle fights the auto-sizing. */
.agent-chat-textarea {
    resize: none;
    overflow-y: hidden;
    min-height: 40px;
    max-height: 160px;
    line-height: 1.45;
    font-family: inherit;
}

.agent-chat-attachments {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5) 0;
    flex-shrink: 0;
}

.agent-chat-attachment-thumb {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--color-border);
    flex-shrink: 0;
}

    .agent-chat-attachment-thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

.agent-chat-attachment-file {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: var(--color-bg);
    color: var(--color-text-muted);
    padding: 2px;
}

.agent-chat-attachment-name {
    font-size: 8px;
    line-height: 1;
    max-width: 44px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.agent-chat-attachment-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

/* A file still on its way up: a spinner over a bar that fills from the
   bottom as the bytes arrive. */
.agent-chat-attachment-thumb.is-uploading {
    background: var(--color-bg);
}
.agent-chat-attachment-progress {
    position: absolute;
    inset: auto 0 0 0;
    height: var(--upload-pct, 0%);
    background: color-mix(in srgb, var(--color-primary) 18%, transparent);
    transition: height 0.12s linear;
}
.agent-chat-attachment-uploading {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--color-primary);
}

.agent-chat-attachment-error {
    padding: var(--space-2) var(--space-5) 0;
    font-size: var(--font-size-xs);
    color: var(--color-danger);
    flex-shrink: 0;
}

.notif-view-all {
    font-size: var(--font-size-sm);
    color: var(--color-primary);
    font-weight: var(--font-weight-medium);
}

/* ── Content ── */
.app-content {
    padding: var(--space-8);
    flex: 1;
}

.click-outside {
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-dropdown) - 1);
}

/* On mobile the sidebar is z-index:50. The click-outside overlay
   must sit BELOW it so taps on the sidebar reach the nav links
   rather than being intercepted by the overlay. */
@media (max-width: 1024px) {
    .click-outside {
        z-index: 49;
    }
}

/* ── User Dropdown Menu ── */
.dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 200px;
    z-index: var(--z-dropdown);
    padding: var(--space-2);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    /* REQUIRED, because this project has no global box-sizing reset (see the
       note in pos.css). Without it, width:100% is the CONTENT width and the
       padding is added on top, so every item sat 6px wider than the menu
       holding it. Two visible symptoms, one cause: the hover highlight ran
       past the menu's rounded edge, and the business switcher — which sets
       overflow-y:auto, and so gets overflow-x:auto forced on it by the spec —
       grew a horizontal scrollbar with nothing to scroll to.
       A <button> picked up border-box from the button reset and an <a> did
       not, which is why only some rows overflowed. */
    box-sizing: border-box;
    padding: var(--space-3) var(--space-3);
    font-size: var(--font-size-md);
    color: var(--color-text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    text-decoration: none;
    transition: all var(--transition-fast);
}

    .dropdown-item:hover {
        background: var(--color-primary-light);
        color: var(--color-primary);
        text-decoration: none;
    }

.dropdown-item-danger:hover {
    background: var(--color-danger-light);
    color: var(--color-danger);
}

.dropdown-divider {
    border: none;
    border-top: 1px solid var(--color-border-light);
    margin: var(--space-2) 0;
}

/* ── Mobile menu toggle — hidden on desktop, shown when sidebar
   becomes a drawer (matches the tablet/mobile breakpoints below) ── */
.mobile-menu-btn {
    display: none;
}

@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: flex;
    }
}

/* ── Responsive — matches the mockup's 3-tier breakpoint system ──
   Desktop (>1024): persistent sidebar
   Tablet  (768-1024): slide-in drawer sidebar
   Mobile  (<768): bottom nav implied, sidebar becomes drawer too,
                   tables collapse to stacked cards, 44px touch targets */

@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-normal);
        box-shadow: var(--shadow-xl);
        /* dvh, not the 100vh the base rule sets. On a phone 100vh is the
           viewport with the browser chrome RETRACTED, so the panel is taller
           than what you can actually see and its last nav items sit behind the
           address bar -- which is what makes you keep scrolling at the bottom
           in the first place. dvh follows the chrome, so the end of the list is
           the end of the panel. */
        height: 100dvh;
    }

        /* Over the page, not just over the page's background. The sidebar is
           z-index 50 and every picker dropdown is at --z-modal (200) to clear
           the drawer, so sliding the nav out over an invoice with a catalogue
           list open put the list on top of the nav. Measured, same as the
           notification panel and the Nova panel above.

           Only while open, so the sidebar keeps its ordinary 50 on desktop
           where it is always there. Its click-outside sits one below, keeping
           the pairing the .click-outside rules below describe. */
        .app-sidebar.open {
            transform: translateX(0);
            z-index: calc(var(--z-modal) + 5);
        }

            .app-sidebar.open ~ .click-outside {
                z-index: calc(var(--z-modal) + 4);
            }

    .app-main {
        margin-left: 0;
    }

    .topbar-search {
        display: none;
    }
}

@media (max-width: 768px) {
    .app-content {
        padding: var(--space-4);
    }

    .app-topbar {
        padding: 0 var(--space-4);
    }

    .topbar-title {
        font-size: var(--font-size-lg);
    }

    .notif-panel {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: none;
        border-radius: 0;
        border: none;
    }

    .agent-chat-fab-wrap {
        bottom: var(--space-4);
        right: var(--space-4);
    }

    .agent-chat-panel {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        /* Nova's message box is the last thing in this panel, so this is what
           decides whether you can see what you are typing to it. 0 on Chrome,
           the keyboard's height on iOS. See app.js. */
        bottom: var(--viewport-bottom-inset, 0px);
        width: 100%;
        height: auto;
        border-radius: 0;
        border: none;
    }

    /* Touch targets grow to 44px minimum on mobile, per the
       mockup's stated responsive rules */
    .sidebar-nav-item,
    .topbar-icon-btn,
    .btn {
        min-height: 44px;
    }
}

/* Shift+Enter hint under Nova's input. Sits inside the input row's container
   so it lines up with the textarea, not the paperclip button. */
.agent-chat-hint {
    font-size: 11px;
    color: var(--color-text-muted);
    padding: 4px var(--space-4) 0 44px;
    line-height: 1.3;
}

/* The "Nova can be wrong" notice, dismissed with Got it.
   Sits between the token bar and the message list, so it is the first thing
   read on a fresh drawer and then never seen again. Not position:fixed and not
   an overlay: it pushes the messages down rather than covering them, because
   an overlay over the transcript is something to escape rather than read. */
.agent-chat-notice {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin: var(--space-3) var(--space-4) 0;
    padding: 10px 12px;
    background: var(--color-surface-alt, #f6f7fb);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 8px);
}

.agent-chat-notice-text {
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

/* Looks like a button rather than a link, because "Got it" has to read as the
   thing that closes this — a text link beside body copy gets skimmed past. */
.agent-chat-notice-ack {
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 6px);
    padding: 4px 10px;
    font-size: 12px;
    font-weight: var(--font-weight-medium);
    color: var(--color-text-primary);
    cursor: pointer;
    line-height: 1.3;
}

.agent-chat-notice-ack:hover {
    background: var(--color-surface);
    border-color: var(--color-text-muted);
}


/* Small print under a form control.
   The class was already used in Business Settings and had never been defined
   anywhere, so every one of those hints rendered as full-size black body copy
   sitting under its field. Defining it fixes those too, not just the new ones. */
.form-hint {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    line-height: 1.4;
    margin-top: var(--space-2);
}

/* Same size and weight, only the colour changes. A caution the owner should
   read before saving, not a banner. */
.form-hint-warn {
    color: var(--color-warning);
}
