/* Labor Workscope Copilot — Dark Theme */

:root {
    --bg: #030816;
    --bg2: #0a1628;
    --bg3: #111d35;
    --border: rgba(93, 224, 255, 0.12);
    --border-hover: rgba(93, 224, 255, 0.3);
    --text: rgba(244, 248, 255, 0.94);
    --text-dim: rgba(244, 248, 255, 0.55);
    --accent: #5de0ff;
    --accent-dim: rgba(93, 224, 255, 0.15);
    --green: #34d399;
    --green-dim: rgba(52, 211, 153, 0.15);
    --yellow: #fbbf24;
    --yellow-dim: rgba(251, 191, 36, 0.15);
    --red: #f87171;
    --red-dim: rgba(248, 113, 113, 0.15);
    --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Code", monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius: 8px;
    --radius-sm: 4px;
}

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

html {
    font-size: 15px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
header {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
}

.logo svg {
    width: 32px;
    height: 32px;
    color: var(--accent);
}

.logo h1 {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.logo .subtitle {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 400;
}

.site-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    flex-wrap: wrap;
}

nav a {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

nav a:hover {
    color: var(--accent);
    background: var(--accent-dim);
}

/* Main content */
main {
    padding: 32px 0;
}

h2 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 12px;
}

/* Cards */
.card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    transition: border-color 0.15s;
}

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

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn[disabled]:hover {
    border-color: var(--border);
    color: var(--text);
}

.btn-primary {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
    font-weight: 600;
}

.btn-primary:hover {
    background: #7de8ff;
    border-color: #7de8ff;
    color: var(--bg);
}

.btn-accept {
    border-color: var(--green);
    color: var(--green);
}

.btn-accept:hover {
    background: var(--green-dim);
}

.btn-edit {
    border-color: var(--yellow);
    color: var(--yellow);
}

.btn-edit:hover {
    background: var(--yellow-dim);
}

.btn-reject {
    border-color: var(--red);
    color: var(--red);
}

.btn-reject:hover {
    background: var(--red-dim);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.btn-group {
    display: flex;
    gap: 6px;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-dim);
}

select.form-control {
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%235de0ff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Line items table */
.line-items {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.line-items th {
    background: var(--bg3);
    padding: 10px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.line-items th:first-child {
    border-radius: var(--radius-sm) 0 0 0;
}

.line-items th:last-child {
    border-radius: 0 var(--radius-sm) 0 0;
}

.line-items td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: top;
}

.line-items tr:hover td {
    background: rgba(93, 224, 255, 0.03);
}

.line-items .task-code {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--accent);
    white-space: nowrap;
}

.line-items .hours,
.line-items .rate,
.line-items .total {
    font-family: var(--font-mono);
    font-size: 0.88rem;
    text-align: right;
    white-space: nowrap;
}

.line-items .total {
    font-weight: 600;
}

.line-items tfoot td {
    font-weight: 700;
    background: var(--bg3);
    border-top: 2px solid var(--accent);
}

/* Status badges */
.status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-pending {
    background: var(--accent-dim);
    color: var(--accent);
}

.status-draft {
    background: rgba(148, 163, 184, 0.16);
    color: var(--text-dim);
}

.status-sent {
    background: var(--accent-dim);
    color: var(--accent);
}

.status-accepted {
    background: var(--green-dim);
    color: var(--green);
}

.status-edited {
    background: var(--yellow-dim);
    color: var(--yellow);
}

.status-rejected {
    background: var(--red-dim);
    color: var(--red);
}

.status-declined {
    background: var(--red-dim);
    color: var(--red);
}

/* Citation chips */
.citations {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.citation-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--accent-dim);
    border: 1px solid rgba(93, 224, 255, 0.2);
    border-radius: 12px;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    color: var(--accent);
    cursor: pointer;
    transition: all 0.15s;
    position: relative;
}

.citation-chip:hover {
    background: rgba(93, 224, 255, 0.25);
    border-color: var(--accent);
}

.citation-chip .icon {
    font-size: 0.65rem;
}

.historical-chip {
    background: var(--green-dim);
    border-color: rgba(52, 211, 153, 0.2);
    color: var(--green);
}

.historical-chip:hover {
    background: rgba(52, 211, 153, 0.25);
    border-color: var(--green);
}

.prior-calibration {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    margin-top: 8px;
    font-size: 0.76rem;
}

.prior-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 8px;
}

.prior-dot-in-band {
    background: var(--green);
    box-shadow: 0 0 0 3px var(--green-dim);
}

.prior-dot-low-band {
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.prior-dot-high-band {
    background: var(--yellow);
    box-shadow: 0 0 0 3px var(--yellow-dim);
}

.prior-badge {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px 9px;
}

.prior-link {
    border: 0;
    background: transparent;
    color: var(--text-dim);
    font: inherit;
    cursor: pointer;
    padding: 2px 0;
}

.prior-link:hover {
    color: var(--accent);
}

/* Citation tooltip */
.citation-tooltip {
    display: none;
    position: absolute;
    background: var(--bg2);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 16px;
    max-width: 400px;
    font-size: 0.82rem;
    line-height: 1.5;
    z-index: 200;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.citation-chip:hover .citation-tooltip {
    display: block;
}

/* Quote summary */
.quote-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-stat {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}

.summary-stat .value {
    font-family: var(--font-mono);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
}

.summary-stat .label {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 4px;
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg3);
    border-radius: 2px;
    overflow: hidden;
    margin: 16px 0;
}

.progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Draft list */
.draft-list {
    display: grid;
    gap: 12px;
}

.draft-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto auto;
    align-items: center;
    gap: 16px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s;
}

.draft-item:hover {
    border-color: var(--border-hover);
    background: var(--bg3);
}

.draft-item .customer {
    font-weight: 600;
}

.draft-item .meta {
    font-size: 0.82rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.draft-item .amount {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--green);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--accent);
    opacity: 0.3;
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 20px;
}

/* Edit modal */
.modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(3, 8, 22, 0.85);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.modal-backdrop.active {
    display: flex;
}

.modal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
}

.modal h3 {
    margin-bottom: 16px;
}

.modal .btn-group {
    justify-content: flex-end;
    margin-top: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .draft-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .line-items {
        display: block;
        overflow-x: auto;
    }

    .quote-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .btn-group {
        flex-wrap: wrap;
    }

    #mro-feedback-fab {
        display: none !important;
    }

    header .container {
        flex-direction: column;
        gap: 8px;
    }

    .site-nav {
        justify-content: center;
        width: 100%;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .quote-summary {
        grid-template-columns: 1fr;
    }

    header {
        padding: 12px 0;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .site-nav a {
        font-size: 0.78rem;
        padding: 5px 8px;
    }

    main {
        padding: 22px 0;
    }
}

/* Speed badge */
.speed-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 14px;
    background: rgba(52, 211, 153, 0.12);
    border: 1px solid rgba(52, 211, 153, 0.25);
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    color: #34d399;
    font-family: var(--font-mono);
    margin-left: 12px;
}

/* Citation popover */
.cite-popover {
    display: none;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 420px;
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg2);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0;
    z-index: 300;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.6;
    text-align: left;
}

.cite-popover.visible {
    display: block;
}

.cite-popover-header {
    padding: 10px 14px;
    background: var(--bg3);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cite-popover-ref {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent);
    font-size: 0.82rem;
}

.cite-popover-source {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.cite-popover-text {
    padding: 12px 14px;
    white-space: pre-wrap;
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text);
}

/* Confidence badges */
.confidence {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-left: 6px;
}

.confidence-high {
    background: var(--green-dim);
    color: var(--green);
}

.confidence-medium {
    background: var(--yellow-dim);
    color: var(--yellow);
}

.confidence-low {
    background: var(--red-dim);
    color: var(--red);
}

/* Category header rows */
.category-header td {
    background: var(--bg3);
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--accent);
    padding: 10px 14px;
    border-left: 3px solid var(--accent);
    border-bottom: 1px solid var(--border);
    letter-spacing: 0.02em;
}

/* Historical comparison mini-table */
.historical-section {
    margin-top: 8px;
}

.historical-section .historical-table-wrap {
    display: none;
    margin-top: 6px;
}

.historical-section.expanded .historical-table-wrap {
    display: block;
}

.historical-section.expanded .toggle-arrow {
    transform: rotate(90deg);
}

.historical-toggle {
    background: var(--green-dim);
    border: 1px solid rgba(52, 211, 153, 0.2);
    border-radius: 6px;
    padding: 4px 12px;
    color: var(--green);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.historical-toggle:hover {
    background: rgba(52, 211, 153, 0.25);
    border-color: var(--green);
}

.toggle-arrow {
    font-size: 0.7rem;
    transition: transform 0.15s;
    display: inline-block;
}

.historical-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    margin-top: 4px;
}

.historical-table th {
    background: var(--bg3);
    padding: 4px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.historical-table td {
    padding: 4px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    color: var(--text-dim);
}

.historical-summary {
    padding: 6px 10px;
    font-size: 0.78rem;
    color: var(--text-dim);
    background: var(--bg3);
    border-radius: 0 0 4px 4px;
    margin-top: 2px;
}

/* Utility */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-mono { font-family: var(--font-mono); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

@media print {
    header,
    .site-nav,
    footer,
    #mro-feedback-fab,
    #mro-feedback-modal,
    .modal-backdrop,
    .screen-actions,
    .screen-spacer,
    .btn,
    .btn-group,
    form[action$="/accept-all"],
    form[action$="/duplicate"] {
        display: none !important;
    }

    html,
    body,
    main,
    .container,
    .card,
    .summary-stat,
    .line-items th,
    .line-items td,
    .line-items tfoot td,
    .category-header td {
        background: #fff !important;
        color: #000 !important;
        box-shadow: none !important;
    }

    body {
        font-size: 11pt;
        min-height: auto;
    }

    main {
        padding: 0;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .card,
    .summary-stat,
    .line-items th,
    .line-items td {
        border-color: #999 !important;
    }

    .line-items,
    .historical-table {
        page-break-inside: auto;
    }

    .category-header,
    .category-group,
    .summary-stat,
    .quote-summary,
    .totals,
    .notes {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .text-mono,
    .task-code,
    .hours,
    .rate,
    .total {
        font-family: var(--font-mono);
    }
}
