/**
 * MasonryBid Application Stylesheet
 * Native CSS with @layer structure
 * Dark mode first (respects prefers-color-scheme)
 * Mobile-first responsive design
 */

@layer reset, base, components, modules, utilities;

/* ============================================================
   RESET LAYER
   Normalize browser defaults
   ============================================================ */

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

  html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  body {
    margin: 0;
    padding: 0;
  }

  button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
  }

  input, textarea, select {
    font: inherit;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}

/* ============================================================
   COLOR SYSTEM
   OKLCH for perceptually uniform colors
   Separate light & dark mode palettes
   ============================================================ */

:root {
  /* Light mode defaults */
  --bg: oklch(98% 0 0);                   /* off-white background */
  --surface: oklch(95% 0 0);              /* light gray surface */
  --text: oklch(20% 0 0);                 /* near-black text */
  --text-secondary: oklch(50% 0 0);       /* medium gray secondary text */
  --border: oklch(90% 0 0);               /* light gray border */
  
  /* Accent colors */
  --accent: oklch(60% 0.15 250);          /* blue */
  --accent-hover: oklch(55% 0.15 250);    /* blue hover */
  --accent-dark: oklch(50% 0.15 250);     /* blue active/pressed */
  
  /* Status colors */
  --success: oklch(65% 0.2 145);          /* green */
  --warning: oklch(75% 0.15 85);          /* orange */
  --danger: oklch(55% 0.2 25);            /* red */
  
  /* Semantic */
  --focus: var(--accent);                 /* focus outline */
  
  /* Typography */
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Courier New", monospace;
  
  /* Spacing (8px base unit) */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  
  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  /* Transitions */
  --transition: 150ms ease-in-out;
}

/* Dark mode (respects OS preference) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(15% 0 0);                 /* near-black background */
    --surface: oklch(25% 0 0);            /* dark gray surface */
    --text: oklch(90% 0 0);               /* near-white text */
    --text-secondary: oklch(70% 0 0);     /* light gray secondary text */
    --border: oklch(35% 0 0);             /* dark gray border */
    
    --accent: oklch(70% 0.15 250);        /* lighter blue */
    --accent-hover: oklch(75% 0.15 250);  /* lighter blue hover */
    --accent-dark: oklch(65% 0.15 250);   /* lighter blue active */
  }
}

/* ============================================================
   BASE LAYER
   Typography, form defaults, structural elements
   ============================================================ */

@layer base {
  body {
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background-color: var(--bg);
    transition: background-color var(--transition), color var(--transition);
  }

  /* Headings */
  h1 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: var(--space-lg);
  }

  h2 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: var(--space-md);
  }

  h3 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: var(--space-md);
  }

  h4, h5, h6 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
  }

  /* Paragraphs */
  p {
    margin-bottom: var(--space-md);
  }

  /* Links */
  a {
    color: var(--accent);
    text-decoration: underline;
    transition: color var(--transition);
  }

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

  /* Form elements */
  label {
    display: block;
    margin-bottom: var(--space-xs);
    font-weight: 500;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  textarea,
  select {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
  }

  input:focus,
  textarea:focus,
  select:focus {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--focus) 20%, transparent);
  }

  textarea {
    resize: vertical;
    min-height: 120px;
    font-family: var(--font-family);
  }

  /* Form groups */
  .form-group {
    margin-bottom: var(--space-lg);
  }

  .form-group:last-child {
    margin-bottom: 0;
  }

  /* Error messages */
  .error-message {
    color: var(--danger);
    font-size: 14px;
    margin-top: var(--space-xs);
  }

  .field_with_errors input,
  .field_with_errors textarea,
  .field_with_errors select {
    border-color: var(--danger);
  }

  /* Lists */
  ul, ol {
    margin-bottom: var(--space-md);
    margin-left: var(--space-lg);
  }

  li {
    margin-bottom: var(--space-xs);
  }

  /* Code */
  code {
    font-family: var(--font-mono);
    background-color: var(--surface);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 14px;
  }

  /* HR */
  hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: var(--space-lg) 0;
  }
}

/* ============================================================
   COMPONENTS LAYER
   Reusable UI components (buttons, alerts, badges, etc.)
   ============================================================ */

@layer components {
  /* Buttons */
  .btn {
    display: inline-block;
    padding: var(--space-sm) var(--space-md);
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
  }

  .btn:hover {
    transform: translateY(-1px);
  }

  .btn:active {
    transform: translateY(0);
  }

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

  .btn-primary {
    background-color: var(--accent);
    color: white;
  }

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

  .btn-primary:active {
    background-color: var(--accent-dark);
  }

  .btn-secondary {
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
  }

  .btn-secondary:hover {
    background-color: oklch(from var(--surface) calc(l + 5%) c h);
  }

  .btn-danger {
    background-color: var(--danger);
    color: white;
  }

  .btn-danger:hover {
    background-color: oklch(from var(--danger) calc(l - 5%) c h);
  }

  .btn-success {
    background-color: var(--success);
    color: white;
  }

  .btn-success:hover {
    background-color: oklch(from var(--success) calc(l - 5%) c h);
  }

  .btn-sm {
    padding: var(--space-xs) var(--space-sm);
    font-size: 13px;
  }

  .btn-lg {
    padding: var(--space-md) var(--space-lg);
    font-size: 16px;
  }

  .btn-block {
    display: block;
    width: 100%;
  }

  /* Alerts */
  .alert {
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 200ms ease-out;
  }

  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .alert-success {
    background-color: color-mix(in srgb, var(--success) 15%, var(--surface));
    color: var(--text);
    border-left: 4px solid var(--success);
  }

  .alert-danger {
    background-color: color-mix(in srgb, var(--danger) 15%, var(--surface));
    color: var(--text);
    border-left: 4px solid var(--danger);
  }

  .alert-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .alert-close::before {
    content: "×";
    font-size: 24px;
  }

  /* Badges */
  .badge {
    display: inline-block;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .badge-primary {
    background-color: color-mix(in srgb, var(--accent) 20%, var(--surface));
    color: var(--accent);
  }

  .badge-success {
    background-color: color-mix(in srgb, var(--success) 20%, var(--surface));
    color: var(--success);
  }

  .badge-warning {
    background-color: color-mix(in srgb, var(--warning) 20%, var(--surface));
    color: var(--warning);
  }

  .badge-danger {
    background-color: color-mix(in srgb, var(--danger) 20%, var(--surface));
    color: var(--danger);
  }

  /* Cards */
  .card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
  }

  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
  }

  .card-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
  }

  .card-body {
    margin-bottom: var(--space-lg);
  }

  .card-footer {
    display: flex;
    gap: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border);
  }

  /* Forms */
  .form {
    max-width: 500px;
  }

  .form-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-xl);
  }

  /* File Upload */
  .file-upload {
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
  }

  .file-upload input[type="file"] {
    display: none;
  }

  .file-upload:hover {
    border-color: var(--accent);
    background-color: color-mix(in srgb, var(--accent) 5%, var(--surface));
  }

  .file-upload.drag-active {
    border-color: var(--accent);
    background-color: color-mix(in srgb, var(--accent) 10%, var(--surface));
  }

  .file-upload-area {
    pointer-events: none;
  }

  .file-upload-label {
    margin-bottom: var(--space-sm);
  }

  .file-upload-preview {
    color: var(--text-secondary);
  }

  /* Estimate Summary */
  .estimate-summary {
    font-size: 14px;
  }

  .summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
  }

  .summary-row strong {
    font-weight: 600;
  }

  /* Tables */
  table {
    width: 100%;
    border-collapse: collapse;
  }

  th {
    background-color: var(--surface);
    color: var(--text);
    padding: var(--space-md);
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
  }

  td {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
  }

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

  /* Spinner/Loading */
  .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }

  @keyframes spin {
    to { transform: rotate(360deg); }
  }
}

/* ============================================================
   MODULES LAYER
   Page-specific layouts and sections
   ============================================================ */

@layer modules {
  /* Navigation */
  .navbar {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: var(--space-md) 0;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
  }

  .navbar-menu {
    display: flex;
    gap: var(--space-md);
    align-items: center;
  }

  .navbar-user {
    font-size: 14px;
    color: var(--text-secondary);
  }

  .navbar-role {
    display: inline-block;
    margin-left: var(--space-sm);
    padding: var(--space-xs) var(--space-sm);
    background-color: var(--accent);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
  }

  /* Page layout */
  .page-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
    min-height: calc(100vh - 200px);
  }

  .page-header {
    margin-bottom: var(--space-xl);
  }

  .page-header-title {
    margin: 0 0 var(--space-sm) 0;
  }

  .page-header-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
  }

  .page-footer {
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    padding: var(--space-lg) var(--space-md);
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: var(--space-3xl);
  }

  /* Auth pages */
  .auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--space-md);
  }

  .auth-card {
    width: 100%;
    max-width: 400px;
  }

  .auth-heading {
    text-align: center;
    margin-bottom: var(--space-xl);
  }

  .auth-link {
    text-align: center;
    margin-top: var(--space-lg);
    font-size: 14px;
  }

  .auth-link a {
    color: var(--accent);
    text-decoration: underline;
  }

  /* Grid */
  .grid {
    display: grid;
    gap: var(--space-lg);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  @media (min-width: 768px) {
    .grid-2 {
      grid-template-columns: 1fr 1fr;
    }
  }

  .grid-3 {
    grid-template-columns: 1fr;
  }

  @media (min-width: 768px) {
    .grid-3 {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  @media (min-width: 1024px) {
    .grid-3 {
      grid-template-columns: repeat(3, 1fr);
    }
  }

  /* Flex */
  .flex {
    display: flex;
    gap: var(--space-md);
  }

  .flex-center {
    align-items: center;
    justify-content: center;
  }

  .flex-between {
    justify-content: space-between;
  }

  .flex-end {
    justify-content: flex-end;
  }

  .flex-col {
    flex-direction: column;
  }

  /* Responsive adjustments */
  @media (min-width: 768px) {
    .page-content {
      padding: var(--space-xl) var(--space-lg);
    }

    .navbar-container {
      padding: 0 var(--space-lg);
    }
  }

  @media (min-width: 1024px) {
    .page-content {
      padding: var(--space-2xl) var(--space-xl);
    }
  }
}

/* ============================================================
   UTILITIES LAYER
   Single-purpose helper classes
   ============================================================ */

@layer utilities {
  .hidden {
    display: none !important;
  }

  .sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
  }

  .mt-xs { margin-top: var(--space-xs); }
  .mt-sm { margin-top: var(--space-sm); }
  .mt-md { margin-top: var(--space-md); }
  .mt-lg { margin-top: var(--space-lg); }
  .mt-xl { margin-top: var(--space-xl); }

  .mb-xs { margin-bottom: var(--space-xs); }
  .mb-sm { margin-bottom: var(--space-sm); }
  .mb-md { margin-bottom: var(--space-md); }
  .mb-lg { margin-bottom: var(--space-lg); }
  .mb-xl { margin-bottom: var(--space-xl); }

  .pt-md { padding-top: var(--space-md); }
  .pb-md { padding-bottom: var(--space-md); }
  .px-md { padding-left: var(--space-md); padding-right: var(--space-md); }
  .py-md { padding-top: var(--space-md); padding-bottom: var(--space-md); }

  .text-center { text-align: center; }
  .text-right { text-align: right; }
  .text-secondary { color: var(--text-secondary); }
  .text-sm { font-size: 14px; }
  .text-xs { font-size: 12px; }

  .w-full { width: 100%; }
  .max-w-sm { max-width: 400px; }
  .max-w-md { max-width: 600px; }
  .max-w-lg { max-width: 800px; }

  .cursor-pointer { cursor: pointer; }
  .opacity-50 { opacity: 0.5; }
}

/* ============================================================
   EXTRACTION REVIEW
   ============================================================ */

@layer components {

  /* Header */
  .review-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
  }

  .review-title h1 { margin: 0; }
  .review-title .subtitle { color: var(--text-muted); margin-top: 0.25rem; }

  .review-stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
  }

  .stat {
    text-align: center;
    min-width: 5rem;
  }

  .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
  }

  .stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  /* Material summary */
  .material-summary {
    margin-bottom: 2rem;
  }

  .material-summary h2 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-muted);
  }

  .summary-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .summary-item {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.375rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-size: 0.875rem;
  }

  .summary-item .code {
    font-weight: 700;
    font-family: var(--font-mono, monospace);
  }

  .summary-item .sf {
    color: var(--text-muted);
  }

  .summary-item.deduction {
    border-color: oklch(0.65 0.15 25);
    color: oklch(0.65 0.15 25);
  }

  /* Wall group */
  .wall-group {
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
  }

  .wall-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .wall-header h2 {
    font-size: 1rem;
    margin: 0;
  }

  .wall-count {
    color: var(--text-muted);
    font-size: 0.875rem;
  }

  /* Takeoff table */
  .takeoff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
  }

  .takeoff-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
  }

  .takeoff-table td {
    padding: 0.375rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
  }

  .takeoff-table tbody tr:hover {
    background: var(--surface);
  }

  /* Row states */
  .deduction-row { color: oklch(0.65 0.15 25); }
  .deduction-row .col-code strong { color: oklch(0.65 0.15 25); }

  .unreviewed { background: oklch(0.97 0.02 85); }

  .modified td:first-child {
    border-left: 3px solid var(--accent);
  }

  /* Status dots */
  .status-dot {
    font-size: 0.75rem;
  }
  .status-dot.reviewed { color: oklch(0.7 0.15 145); }
  .status-dot.unreviewed { color: oklch(0.7 0.1 50); }

  /* Line type badges */
  .line-type {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
  }

  .line-type.wall_layer { background: oklch(0.85 0.08 220); }
  .line-type.accent_band { background: oklch(0.85 0.1 145); }
  .line-type.material_swap { background: oklch(0.85 0.1 25); }
  .line-type.opening_deduct { background: oklch(0.85 0.1 50); }
  .line-type.head_detail { background: oklch(0.85 0.08 280); }
  .line-type.jamb_detail { background: oklch(0.85 0.08 280); }
  .line-type.sill_detail { background: oklch(0.85 0.08 280); }
  .line-type.lintel { background: oklch(0.85 0.08 0); }
  .line-type.corner { background: oklch(0.85 0.08 180); }
  .line-type.custom { background: oklch(0.85 0.1 310); }

  /* Confidence badges */
  .confidence-badge {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
  }

  .confidence-high { background: oklch(0.85 0.12 145); }
  .confidence-medium { background: oklch(0.85 0.1 85); }
  .confidence-low { background: oklch(0.85 0.12 25); }

  .negative { color: oklch(0.65 0.15 25); }

  .opening-ref {
    color: var(--text-muted);
    font-style: italic;
  }

  /* Subtotals */
  .wall-subtotal {
    background: var(--surface);
    font-size: 0.875rem;
  }

  /* Notes row */
  .notes-row .item-notes {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    padding-top: 0;
    padding-bottom: 0.5rem;
  }

  /* Column widths */
  .col-status { width: 2rem; text-align: center; }
  .col-type { width: 5rem; }
  .col-code { width: 8rem; }
  .col-qty { width: 4rem; text-align: right; }
  .col-length { width: 5rem; text-align: right; }
  .col-height { width: 5rem; text-align: right; }
  .col-sf { width: 6rem; text-align: right; }
  .col-conf { width: 4rem; text-align: center; }
  .col-actions { width: 10rem; text-align: right; }

  /* Action buttons */
  .btn-sm {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
  }

  .btn-sm:hover { background: var(--border); }
  .btn-sm.btn-danger { color: oklch(0.65 0.15 25); border-color: oklch(0.65 0.15 25); }
  .btn-sm.btn-danger:hover { background: oklch(0.65 0.15 25); color: white; }

  /* Review actions */
  .review-actions {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    text-align: center;
  }

  .action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 0.75rem;
  }

  .btn-confirm {
    background: oklch(0.55 0.15 145);
    color: white;
    border: none;
    padding: 0.625rem 1.5rem;
    border-radius: 0.375rem;
    font-weight: 600;
    cursor: pointer;
  }

  .btn-confirm:hover { background: oklch(0.5 0.15 145); }

  .btn-reject {
    background: transparent;
    color: oklch(0.65 0.15 25);
    border: 1px solid oklch(0.65 0.15 25);
    padding: 0.625rem 1.5rem;
    border-radius: 0.375rem;
    font-weight: 600;
    cursor: pointer;
  }

  .btn-reject:hover { background: oklch(0.65 0.15 25); color: white; }

  .action-hint {
    color: var(--text-muted);
    font-size: 0.875rem;
  }

  .confirmed-badge {
    color: oklch(0.55 0.15 145);
    font-weight: 600;
    font-size: 1.125rem;
  }

  /* Form */
  .line-item-form .form-grid {
    display: grid;
    gap: 1rem;
  }

  .form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }

  .line-item-form .form-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.75rem;
  }

  .source-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
  }

  .source-badge.ai { background: oklch(0.85 0.1 220); }
  .source-badge.manual { background: oklch(0.85 0.1 145); }

  .ai-note {
    color: var(--text-muted);
    font-size: 0.875rem;
  }

  .ai-note code {
    background: var(--surface);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.8rem;
  }

  /* Summary page */
  .summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
  }

  .summary-table th,
  .summary-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
  }

  .summary-table thead th {
    background: var(--surface);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
  }

  .summary-table tfoot td {
    background: var(--surface);
    font-weight: 700;
  }

  .general-notes ul {
    padding-left: 1.25rem;
  }

  .general-notes li {
    margin-bottom: 0.375rem;
    color: var(--text-muted);
  }

  .review-nav {
    display: flex;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
  }

  /* Add item section */
  .add-item {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
  }

  .add-item h2 {
    margin-top: 0;
    font-size: 1rem;
  }

  /* Responsive */
  @media (max-width: 768px) {
    .review-header { flex-direction: column; }
    .review-stats { width: 100%; justify-content: space-between; }
    .form-row-3 { grid-template-columns: 1fr; }
    .action-buttons { flex-direction: column; }

    .takeoff-table {
      font-size: 0.75rem;
    }

    .col-conf, .col-actions { display: none; }
  }
}

/* ============================================================
   BLUEPRINT PAGES GRID
   ============================================================ */

@layer components {
  .blueprint-pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
  }

  .blueprint-page-card {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
    background: var(--surface);
    transition: box-shadow 0.15s;
  }

  .blueprint-page-card:hover {
    box-shadow: 0 4px 12px oklch(0 0 0 / 0.15);
  }

  .blueprint-page-card.has-masonry {
    border-color: oklch(0.7 0.15 145);
    box-shadow: 0 0 0 2px oklch(0.7 0.15 145 / 0.25);
  }

  .blueprint-page-thumb {
    width: 100%;
    aspect-ratio: 8.5 / 11;
    overflow: hidden;
    background: oklch(0.95 0 0);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .blueprint-page-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    display: block;
  }

  .page-thumb-placeholder {
    font-size: 2.5rem;
    opacity: 0.4;
  }

  .blueprint-page-info {
    padding: 0.5rem 0.625rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
  }

  .page-badge {
    display: inline-block;
    padding: 0.1rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--border);
    color: var(--text);
  }

  .page-badge.masonry {
    background: oklch(0.85 0.12 145);
    color: oklch(0.3 0.1 145);
  }
}
