/* ==========================================================================
   DCS Field & Scope Studio — Complete Design System (styles.css)
   - Sovereign Dark Mode (#051424 Deep Navy + #F59E0B Warm Amber)
   - 1-Click Outdoor Daylight Mode (data-theme="daylight")
   - Mobile iPhone Field Wizard Mode (body.field-copilot-mode)
   - Full-Screen DCS Authentication Gate Modal
   ========================================================================== */

:root {
  --bg-canvas: #051424;
  --bg-surface-lowest: #020c17;
  --bg-surface-low: #0a1828;
  --bg-surface: #102033;
  --bg-surface-high: #182b42;
  --bg-surface-highest: #223852;

  --text-main: #e6f0fc;
  --text-muted: #94abc7;
  --text-dim: #647c99;

  --primary: #f59e0b;
  --primary-soft: #ffc174;
  --secondary: #7bd0ff;
  --tertiary: #4edea3;
  --danger: #f87171;

  --border-ghost: rgba(190, 216, 248, 0.12);
  --border-strong: rgba(245, 158, 11, 0.45);
  --shadow-card: 0 14px 34px -10px rgba(1, 8, 18, 0.65);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

html[data-theme="daylight"] {
  --bg-canvas: #f1f5f9;
  --bg-surface-lowest: #ffffff;
  --bg-surface-low: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-high: #e2e8f0;
  --bg-surface-highest: #cbd5e1;

  --text-main: #0f172a;
  --text-muted: #334155;
  --text-dim: #64748b;

  --primary: #d97706;
  --primary-soft: #b45309;
  --secondary: #0284c7;
  --tertiary: #059669;
  --danger: #dc2626;

  --border-ghost: rgba(15, 23, 42, 0.14);
  --border-strong: rgba(217, 119, 6, 0.5);
  --shadow-card: 0 10px 26px -8px rgba(15, 23, 42, 0.12);
}

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

body {
  background: var(--bg-canvas);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   AUTHENTICATION MODAL
   ========================================================================== */
.auth-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(2, 10, 20, 0.88);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
}

/* ==========================================================================
   TOP COMMAND HEADER & PRIMARY NAVIGATION TABS
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--bg-surface-low);
  border-bottom: 1px solid var(--border-ghost);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  max-width: 1640px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #051424;
  font-weight: 800;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-pill {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: rgba(245, 158, 11, 0.18);
  color: var(--primary-soft);
  border: 1px solid var(--border-strong);
  padding: 2px 7px;
  border-radius: 999px;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.claim-switcher-select {
  background: rgba(123, 208, 255, 0.12);
  color: var(--secondary);
  border: 1px solid rgba(123, 208, 255, 0.3);
  border-radius: 6px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mode-switch {
  display: inline-flex;
  background: var(--bg-surface-lowest);
  border: 1px solid var(--border-ghost);
  border-radius: 8px;
  padding: 3px;
}

.mode-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-btn.active {
  background: var(--primary);
  color: #051424;
}

.theme-toggle-btn {
  border: 1px solid var(--border-ghost);
  background: var(--bg-surface);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
}

.lan-pill {
  background: rgba(78, 222, 163, 0.1);
  border: 1px solid rgba(78, 222, 163, 0.28);
  color: var(--tertiary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 8px;
}

.nav-tabs {
  max-width: 1640px;
  margin: 0 auto;
  padding: 0 20px 10px 20px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.nav-tab {
  border: 1px solid var(--border-ghost);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 8px 13px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s ease;
}

.nav-tab:hover {
  background: var(--bg-surface-high);
  color: var(--text-main);
}

.nav-tab.active {
  background: rgba(245, 158, 11, 0.16);
  color: var(--primary-soft);
  border-color: var(--border-strong);
}

.tab-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 6px;
  border-radius: 999px;
}

/* ==========================================================================
   MAIN WORKSPACE & KPI STRIP
   ========================================================================== */
.workspace {
  max-width: 1640px;
  margin: 0 auto;
  padding: 18px 20px 48px 20px;
}

.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-ghost);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow-card);
}

.kpi-card.highlight { border-left-color: var(--primary); }
.kpi-card.sky { border-left-color: var(--secondary); }
.kpi-card.emerald { border-left-color: var(--tertiary); }

.kpi-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.kpi-val {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 2px;
}

.kpi-sub {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ==========================================================================
   TAB PANELS, CARDS & GRIDS
   ========================================================================== */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-ghost);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-card);
}

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

.card-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
}

.card-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

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

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

/* ==========================================================================
   STEP-BY-STEP FIELD WIZARD (TAB 0 & MOBILE FIELD CO-PILOT)
   ========================================================================== */
.wizard-stepper {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.wizard-step-btn {
  border: 1px solid var(--border-ghost);
  background: var(--bg-surface-low);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.wizard-step-btn:hover {
  background: var(--bg-surface-high);
  color: var(--text-main);
}

.wizard-step-btn.active {
  background: var(--primary);
  color: #051424;
  border-color: var(--primary);
}

.calc-pill-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 14px 0;
}

.calc-pill {
  background: var(--bg-surface-lowest);
  border: 1px solid rgba(123, 208, 255, 0.3);
  border-radius: 8px;
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.calc-pill strong {
  color: var(--primary-soft);
}

.calc-pill span {
  color: var(--secondary);
  font-weight: 700;
}

.trade-section-card {
  background: var(--bg-surface-low);
  border: 1px solid var(--border-ghost);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.trade-section-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--primary-soft);
  text-decoration: underline;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dr-checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 8px;
}

.dr-check-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-ghost);
  border-radius: 8px;
  padding: 9px 11px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s ease;
}

.dr-check-item:hover {
  border-color: var(--secondary);
}

.dr-check-item input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.continuity-banner {
  background: rgba(78, 222, 163, 0.09);
  border: 1px solid rgba(78, 222, 163, 0.32);
  border-left: 4px solid var(--tertiary);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.82rem;
}

/* ==========================================================================
   BUTTONS, INPUTS, PILLS & BADGES
   ========================================================================== */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--primary);
  color: #051424;
}

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

.btn-secondary {
  background: var(--bg-surface-high);
  color: var(--text-main);
  border-color: var(--border-ghost);
}

.btn-secondary.active,
.btn-secondary:hover {
  border-color: var(--secondary);
  color: var(--secondary);
}

.btn-emerald {
  background: rgba(78, 222, 163, 0.16);
  color: var(--tertiary);
  border-color: rgba(78, 222, 163, 0.38);
}

.btn-emerald:hover {
  background: rgba(78, 222, 163, 0.26);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-ghost);
}

.btn-ghost:hover {
  color: var(--text-main);
  background: var(--bg-surface-high);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}

.field-label {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.input-field,
.select-field,
.textarea-field {
  width: 100%;
  background: var(--bg-surface-lowest);
  border: 1px solid var(--border-ghost);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  padding: 8px 12px;
  border-radius: 8px;
}

.input-field:focus,
.select-field:focus,
.textarea-field:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  border: 1px solid var(--border-ghost);
  background: var(--bg-surface-low);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill:hover {
  color: var(--text-main);
  border-color: var(--secondary);
}

.pill.active {
  background: var(--primary);
  color: #051424;
  border-color: var(--primary);
  font-weight: 700;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
}

.badge-amber {
  background: rgba(245, 158, 11, 0.16);
  color: var(--primary-soft);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-sky {
  background: rgba(123, 208, 255, 0.14);
  color: var(--secondary);
  border: 1px solid rgba(123, 208, 255, 0.3);
}

.badge-emerald {
  background: rgba(78, 222, 163, 0.14);
  color: var(--tertiary);
  border: 1px solid rgba(78, 222, 163, 0.3);
}

.badge-rose {
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  border: 1px solid rgba(248, 113, 113, 0.3);
}

/* ==========================================================================
   SCOPE LINE ITEM TABLES & VERBATIM BOXES
   ========================================================================== */
.scope-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-ghost);
  border-radius: 10px;
}

.scope-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-surface-lowest);
}

.scope-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-surface-low);
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-ghost);
}

.scope-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border-ghost);
  vertical-align: top;
  font-size: 0.83rem;
}

.line-code {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--secondary);
  white-space: nowrap;
}

.line-qty {
  font-family: var(--font-mono);
  white-space: nowrap;
}

.line-price {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--tertiary);
  text-align: right;
  white-space: nowrap;
}

.line-note-box {
  padding: 8px 11px;
  border-left: 3px solid var(--primary);
  background: rgba(245, 158, 11, 0.06);
  border-radius: 0 6px 6px 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--text-main);
}

/* ==========================================================================
   ROOM CARDS & METRICS GRID
   ========================================================================== */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 12px;
}

.room-card {
  background: var(--bg-surface-low);
  border: 1px solid var(--border-ghost);
  border-radius: 10px;
  padding: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.room-card:hover {
  border-color: var(--primary);
  background: var(--bg-surface-high);
}

.room-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.room-name {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--text-main);
}

.room-floor-tag {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.room-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 10px;
}

.metric-box {
  background: var(--bg-surface-lowest);
  border: 1px solid var(--border-ghost);
  border-radius: 6px;
  padding: 5px 8px;
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
}

.metric-box .m-label {
  color: var(--text-muted);
}

.metric-box .m-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--secondary);
}

/* ==========================================================================
   VOICE CO-PILOT BAR, PHOTO STUDIO & DROPZONE
   ========================================================================== */
.voice-bar {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.14) 0%, rgba(123, 208, 255, 0.1) 100%);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.mic-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: #051424;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mic-btn.recording {
  background: var(--danger);
  color: #fff;
  animation: pulseMic 1.2s infinite;
}

@keyframes pulseMic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.65); }
  50% { box-shadow: 0 0 0 12px rgba(248, 113, 113, 0); }
}

.voice-status h4 {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--primary-soft);
}

.voice-status p {
  font-size: 0.8rem;
  color: var(--text-main);
  margin-top: 2px;
}

.photo-studio-layout {
  display: grid;
  grid-template-columns: 310px 1fr 360px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1280px) {
  .photo-studio-layout {
    grid-template-columns: 1fr;
  }
}

.photo-thumb-list {
  max-height: 740px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.photo-thumb-item {
  display: flex;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: var(--bg-surface-low);
  border: 1px solid var(--border-ghost);
  cursor: pointer;
}

.photo-thumb-item.active {
  border-color: var(--primary);
  background: var(--bg-surface-high);
}

.photo-thumb-item img {
  width: 78px;
  height: 58px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

.photo-thumb-meta h5 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-main);
}

.photo-thumb-meta p {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.canvas-stage {
  background: var(--bg-surface);
  border: 1px solid var(--border-ghost);
  border-radius: 12px;
  padding: 14px;
}

.canvas-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.canvas-wrap {
  background: var(--bg-surface-lowest);
  border: 1px solid var(--border-ghost);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
  margin-bottom: 10px;
}

#photoAnnotatorCanvas {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  cursor: crosshair;
}

.dropzone {
  border: 2px dashed rgba(123, 208, 255, 0.38);
  background: rgba(123, 208, 255, 0.05);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dropzone:hover {
  border-color: var(--primary);
  background: rgba(245, 158, 11, 0.08);
}

.dropzone h4 {
  font-size: 0.96rem;
  color: var(--text-main);
  margin-bottom: 4px;
}

.dropzone p {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================================
   TOAST NOTIFICATIONS & MOBILE FIELD WIZARD OVERRIDES
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-surface-high);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.3s ease;
}

body.field-copilot-mode .workspace {
  max-width: 760px;
}

body.field-copilot-mode .btn,
body.field-copilot-mode .wizard-step-btn,
body.field-copilot-mode .dr-check-item {
  padding: 12px 15px;
  font-size: 0.9rem;
}
