/* ==========================================
   PRIMEFORGE — BUSINESS ADMIN CONSOLE
   Consumes theme.css / globals.css / sidebar.css.
   Does not redefine core color/border/radius tokens
   or the fixed-sidebar layout system.
========================================== */

.business-page {
    max-width: 1080px;
}

.biz-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.biz-header h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.your-role {
    font-size: 12px;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 4px 8px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

/* ---- Loading / empty / error states ---- */

.biz-state {
    display: none;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    padding: 32px;
}

#pageLoading {
    display: flex;
}

/* ---- Overview grid ---- */

.biz-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.biz-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px;
}

.biz-card h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 8px;
}

.biz-card p {
    font-size: 20px;
    font-weight: 700;
}

/* ---- Sections ---- */

.biz-section {
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    margin-bottom: 24px;
    overflow: hidden;
}

.biz-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.biz-section-header h2 {
    font-size: 14px;
    font-weight: 700;
}

/* ---- Tables ---- */

.biz-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.biz-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

.biz-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.biz-table tr:last-child td {
    border-bottom: none;
}

.muted-row,
.error-row {
    color: var(--muted);
    text-align: center;
    padding: 20px !important;
}

.error-row {
    color: var(--danger);
}

/* ---- Badges ---- */

.role-badge,
.status-badge,
.owner-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 7px;
    border: 1px solid var(--border-strong);
    border-radius: 3px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.role-admin {
    color: var(--text);
    border-color: var(--text);
}

.status-active {
    color: var(--text);
}

.owner-tag {
    color: var(--text);
    border-color: var(--text);
}

/* ---- Form controls ---- */

.biz-select,
.biz-input {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 3px;
    color: var(--text);
    padding: 8px 10px;
    font-size: 13px;
}

.role-select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 3px;
    color: var(--text);
    padding: 4px 6px;
    font-size: 12px;
}

/* ---- Buttons ---- */

.btn-primary,
.btn-remove,
.btn-revoke {
    border-radius: 3px;
    border: 1px solid var(--border-strong);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px 14px;
    transition:
        background-color .15s ease,
        color .15s ease,
        border-color .15s ease;
}

.btn-primary {
    background: var(--button-bg);
    color: var(--button-text);
    border-color: var(--button-bg);
}

.btn-primary:hover {
    background: var(--button-hover);
}

.btn-primary:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.btn-remove,
.btn-revoke {
    background: transparent;
    color: var(--muted);
}

.btn-remove:hover,
.btn-revoke:hover {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-remove:disabled,
.btn-revoke:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ---- Invite form ---- */

.invite-form {
    display: flex;
    gap: 8px;
    padding: 16px;
    flex-wrap: wrap;
}

.invite-form input {
    flex: 1;
    min-width: 200px;
}

/* ---- Audit log ---- */

.audit-list {
    padding: 4px 16px;
    max-height: 320px;
    overflow-y: auto;
}

.audit-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.audit-row:last-child {
    border-bottom: none;
}

.audit-action {
    color: var(--text);
    font-weight: 600;
}

.audit-meta,
.audit-time {
    color: var(--muted);
}

.recent-activity-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
}

.recent-activity-row:last-child {
    border-bottom: none;
}

.actions-cell {
    text-align: right;
    white-space: nowrap;
}

/* ---- Mobile ---- */

@media (max-width: 900px) {

    .biz-table {
        font-size: 12px;
    }

    .biz-table th,
    .biz-table td {
        padding: 8px 10px;
    }

    .invite-form {
        flex-direction: column;
        align-items: stretch;
    }

}

/* ==========================================
   PHASE 3 ADDITIONS — PROJECTS
   Reuses the classes above (.biz-card, .biz-section, .biz-table,
   .btn-primary, .role-badge, .status-badge, .biz-input, .biz-select)
   wherever they already fit. Only new, project-specific pieces are
   added below - nothing above this comment was changed.
========================================== */

.header-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 4px 8px;
    transition: color .15s ease, border-color .15s ease;
}

.header-link:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

/* Status badge modifiers beyond the .status-active one already
   defined above (draft/archived weren't needed until Projects). */
.status-draft {
    color: var(--muted);
}

.status-archived {
    color: var(--subtle);
    text-decoration: line-through;
    text-decoration-color: var(--border-strong);
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.project-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.project-card:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

.project-card.selected {
    border-color: var(--text);
}

.project-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.project-card-name {
    font-size: 14px;
    font-weight: 700;
    word-break: break-word;
}

.project-card-desc {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 10px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.project-card-meta {
    font-size: 11px;
    color: var(--subtle);
}

.project-detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.project-detail-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.project-detail-row label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    min-width: 90px;
}

.project-detail-row textarea,
.project-detail-row input {
    flex: 1;
    min-width: 200px;
}

textarea.biz-input {
    resize: vertical;
    min-height: 64px;
    font-family: inherit;
}

.project-detail-actions {
    display: flex;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid var(--border);
    justify-content: space-between;
}

.add-member-row {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.add-member-row select {
    flex: 1;
    min-width: 160px;
}

.close-detail {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 10px;
    cursor: pointer;
}

.close-detail:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

/* ==========================================
   PHASE 4 ADDITIONS — APPROVAL WORKFLOW
   Reuses .biz-section-header, .status-badge, .btn-primary,
   .btn-remove, .muted-row, .error-row, .biz-input from above.
   Only new, workflow-specific pieces are added below.
========================================== */

.workflow-header {
    border-top: 1px solid var(--border);
}

.workflow-body {
    padding: 16px;
}

.workflow-meta {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 4px;
}

.workflow-comment {
    font-size: 12px;
    color: var(--text);
    font-style: italic;
    border-left: 2px solid var(--border-strong);
    padding-left: 8px;
    margin: 8px 0;
}

textarea#workflowComment {
    width: 100%;
    margin-top: 8px;
}

/* Status badge modifiers for workflow states beyond .status-active/
   .status-draft/.status-archived already defined above. */
.status-submitted {
    color: var(--text);
}

.status-in_review {
    color: var(--muted);
    border-style: dashed;
}

.status-approved {
    color: var(--text);
    border-color: var(--text);
}

.status-rejected {
    color: var(--danger);
    border-color: var(--danger);
}

/* ==========================================
   PHASE 6 ADDITIONS — ANALYTICS
   Reuses .biz-grid, .biz-card, .biz-section, .biz-table,
   .muted-row, .error-row, .role-badge from above. Only new,
   analytics-specific pieces (range selector, bar chart, cost
   display) are added below.
========================================== */

.range-selector {
    display: inline-flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 16px;
}

.range-btn {
    appearance: none;
    -webkit-appearance: none;
    display: inline-block;
    margin: 0;
    background: var(--card-bg);
    border: none;
    border-right: 1px solid var(--border);
    border-radius: 0;
    color: var(--muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    padding: 8px 14px;
    cursor: pointer;
    outline: none;
    transition: color .15s ease, background-color .15s ease;
}

.range-selector .range-btn:last-child {
    border-right: none;
}

.range-btn:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.range-btn.active {
    background: var(--button-bg);
    color: var(--button-text);
}

.range-btn.active:hover {
    background: var(--button-hover);
    color: var(--button-text);
}

.stat-subtext {
    font-size: 11px;
    color: var(--muted);
    margin-top: 6px;
}

/* ---- Estimated cost ---- */

.cost-body {
    padding: 16px;
}

.cost-figure {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.cost-disclaimer {
    font-size: 11px;
    color: var(--muted);
    font-style: italic;
    margin-bottom: 8px;
}

/* ---- Lightweight, dependency-free bar chart ----
   Bar heights are set as explicit PIXEL values by businessAnalytics.js
   (not CSS percentages) - percentage heights chained through nested
   flex containers are unreliable across browsers and were the reason
   bars weren't rendering. .activity-bar-col no longer needs an
   explicit height at all: align-items:flex-end on the .activity-bars
   parent baseline-aligns every column at the bottom, so each column
   just sizes to its own content (bar + label). */

.activity-chart {
    padding: 16px;
}

.activity-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 140px;
    border-bottom: 1px solid var(--border);
}

.activity-bar-col {
    flex: 1 1 0;
    min-width: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.activity-bar {
    width: 100%;
    background: var(--text);
    border-radius: 2px 2px 0 0;
    min-height: 2px;
}

.activity-bar-label {
    display: block;
    min-height: 12px;
    margin-top: 4px;
    font-size: 9px;
    color: var(--subtle);
    white-space: nowrap;
}

.activity-legend {
    margin-top: 10px;
    font-size: 11px;
    color: var(--muted);
}

/* ==========================================
   PHASE 7 ADDITIONS — CLIENT PORTALS (admin page)
   Reuses .biz-section, .biz-table, .project-detail-row/grid/actions,
   .biz-input/.biz-select, .btn-primary/.btn-remove, .close-detail,
   .status-badge, .add-member-row, .cost-body/.cost-disclaimer from
   above. Only one new container needs a rule.
========================================== */

.resource-list {
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 8px 12px;
    background: var(--input-bg);
}

/* ==========================================
   PHASE 8 ADDITIONS — API ACCESS
   Reuses .biz-section, .biz-table, .project-detail-row/grid/actions,
   .biz-input, .btn-primary/.btn-remove, .close-detail, .status-badge,
   .role-badge, .cost-body/.cost-disclaimer, .workflow-meta,
   .muted-row/.error-row from above. Only the code block needs a
   new rule.
========================================== */

.code-block {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 14px 16px;
    overflow-x: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text);
}

.code-block code {
    white-space: pre;
}

/* ==========================================
   PHASE 9 ADDITIONS — BILLING
   Reuses .biz-grid, .biz-card, .biz-section, .biz-table, .cost-body/
   .cost-disclaimer/.cost-figure, .status-badge, .stat-subtext,
   .btn-primary/.btn-remove, .muted-row/.error-row from above. Only
   a few new status-badge modifiers are needed for billing-specific
   statuses not seen in prior phases.
========================================== */

.status-trialing {
    color: var(--muted);
    border-style: dashed;
}

.status-past_due {
    color: var(--danger);
    border-color: var(--danger);
}

.status-cancelled {
    color: var(--subtle);
    text-decoration: line-through;
    text-decoration-color: var(--border-strong);
}

.status-expired {
    color: var(--subtle);
}