:root {
  --bg: #0d1410;
  --surface: #131c17;
  --surface-alt: #19251e;
  --border: #25372c;
  --green: #15532d;
  --green-bright: #1f7a40;
  --teal: #2dd4bf;
  --amber: #f2b134;
  --text: #e7efe9;
  --text-dim: #9fb3a6;
  --danger: #e0584f;
  --blue: #4a9eff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--teal);
  text-decoration: none;
}

/* ---------- Auth pages ---------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #16251c, var(--bg));
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--text);
}

.auth-card .subtitle {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 24px;
}

.brand {
  color: var(--teal);
  font-weight: 700;
}

.field {
  margin-bottom: 16px;
}

.footprint-fields {
  display: flex;
  gap: 16px;
  max-width: 360px;
}

.footprint-fields .field {
  flex: 1;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

.field input:focus {
  outline: none;
  border-color: var(--teal);
}

.field textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.field textarea:focus {
  outline: none;
  border-color: var(--teal);
}

.field-errors {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
}

.input-icon-group {
  position: relative;
}

.input-icon-group input {
  padding-left: 38px;
}

.input-icon-group.has-toggle input {
  padding-right: 38px;
}

.input-icon-left {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

.input-icon-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  display: flex;
}

.input-icon-toggle:hover {
  color: var(--teal);
}

.password-match-hint {
  font-size: 12px;
  margin-top: 4px;
  min-height: 14px;
}

.password-match-hint.match {
  color: #4ade80;
}

.password-match-hint.mismatch {
  color: var(--danger);
}

.btn-primary {
  width: 100%;
  padding: 11px;
  background: var(--green-bright);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

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

.auth-footer {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
}

.alert {
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error {
  background: rgba(224, 88, 79, 0.15);
  border: 1px solid var(--danger);
  color: #ffb3ad;
}

/* ---------- App shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 230px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
}

.sidebar .brand-block {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}

.sidebar .brand-block .brand {
  font-size: 18px;
}

.sidebar nav {
  flex: 1;
}

.sidebar nav a {
  display: block;
  padding: 11px 20px;
  color: var(--text-dim);
  font-size: 14px;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.sidebar nav a.active {
  background: var(--surface-alt);
  color: var(--teal);
  border-left-color: var(--teal);
}

.sidebar .user-block {
  padding: 16px 20px 0;
  border-top: 1px solid var(--border);
}

.sidebar .user-block .user-name {
  font-size: 14px;
  color: var(--text);
}

.sidebar .user-block .user-role {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar .user-block form {
  margin-top: 10px;
}

.sidebar .user-block button {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}

.sidebar .user-block button:hover {
  color: var(--danger);
}

.main-content {
  flex: 1;
  padding: 32px 40px;
}

.amber {
  color: var(--amber);
}

/* ---------- Dashboard / project pages ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  margin: 0;
}

.btn-inline {
  width: auto;
  display: inline-block;
  padding: 9px 18px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.firm-profile-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #1f7a40;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: 14px;
}

.firm-profile-banner-dismiss {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-alt);
}

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

.empty-state {
  color: var(--text-dim);
  font-size: 14px;
}

.card-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px;
  max-width: 480px;
}

.card-form select {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}

.status-badge {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--teal);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 5px 12px;
  border-radius: 20px;
}

.confidence-badge {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-block;
}

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

.confidence-medium {
  color: var(--amber);
}

.confidence-low {
  color: var(--danger);
}

.confidence-manual {
  color: var(--blue);
}

/* ---------- Workflow stepper ---------- */
.workflow-stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 24px;
}

.workflow-stepper a {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
}

.workflow-stepper .step-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border);
  font-size: 11px;
}

.workflow-stepper a.completed {
  color: var(--green-bright);
  border-color: var(--green-bright);
}

.workflow-stepper a.completed .step-index {
  background: var(--green-bright);
  border-color: var(--green-bright);
  color: #06140c;
}

.workflow-stepper a.current {
  color: var(--teal);
  border-color: var(--teal);
  background: var(--surface-alt);
}

.workflow-stepper a.current .step-index {
  border-color: var(--teal);
  color: var(--teal);
}

/* ---------- Project tabs ---------- */
.project-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.project-tabs a,
.project-tabs .locked {
  display: inline-block;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-dim);
  border-bottom: 2px solid transparent;
}

.project-tabs a:hover {
  color: var(--text);
}

.project-tabs a.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
}

.project-tabs .locked {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- Drawing register ---------- */
.discipline-section {
  margin-bottom: 28px;
}

.discipline-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.discipline-header h3 {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 14px;
}

.discipline-header .discipline-count {
  color: var(--text-dim);
  font-size: 13px;
}

.drawing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.drawing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.drawing-card-thumb {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-alt);
  margin-bottom: 10px;
}

.drawing-card-thumb-placeholder {
  width: 100%;
  height: 120px;
  border-radius: 6px;
  background: var(--surface-alt);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  margin-bottom: 10px;
}

.drawing-card-title {
  font-size: 14px;
  margin-bottom: 4px;
}

.drawing-card-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.drawing-card-actions {
  display: flex;
  gap: 10px;
  font-size: 12px;
  margin-top: 8px;
}

.status-chip {
  display: inline-block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
}

.status-chip-uploaded {
  color: var(--text-dim);
}

.status-chip-processing {
  color: var(--amber);
}

.status-chip-extracted {
  color: var(--blue);
}

.status-chip-confirmed {
  color: var(--green-bright);
}

.status-chip-failed {
  color: var(--danger);
}

.empty-slot {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
  color: var(--text-dim);
  font-size: 13px;
}

.pipeline-steps {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  font-size: 12px;
  color: var(--text-dim);
}

.pipeline-steps li {
  padding: 2px 0;
}

.pipeline-steps li.done {
  color: var(--green-bright);
}

.data-table input,
.data-table select {
  width: 100%;
  padding: 6px 8px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
}

.room-row-removed {
  opacity: 0.4;
  text-decoration: line-through;
}

.boq-element-edit .data-table td {
  vertical-align: top;
}

.delete-cell {
  white-space: nowrap;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.upload-form {
  margin-bottom: 16px;
}

.wizard-steps-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.step-pill {
  padding: 7px 14px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
}

.step-pill.active {
  background: var(--green-bright);
  border-color: var(--green-bright);
  color: #fff;
}

.spec-form {
  max-width: 560px;
}

.wizard-step {
  display: none;
}

.wizard-step.active {
  display: block;
}

.wizard-step h2 {
  margin-top: 0;
  font-size: 17px;
  color: var(--teal);
}

.wizard-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.checkbox-grid ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}

.checkbox-grid input {
  width: auto;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 24px;
}

.city-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.city-tabs a {
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}

.city-tabs a.active {
  background: var(--teal);
  color: #04201c;
  border-color: var(--teal);
}

.price-up {
  color: var(--danger);
}

.price-down {
  color: #4ade80;
}

.price-flat {
  color: var(--text-dim);
}

/* The BOQ document itself is always plain black-on-white/serif, regardless
   of the app's dark theme — it's a formal client-facing QS document. */
.boq-document {
  background: #fff;
  color: #111;
  font-family: 'Times New Roman', Times, serif;
  padding: 40px;
  border-radius: 10px;
  margin-bottom: 32px;
}

.boq-document h1,
.boq-document h2 {
  color: #111;
  font-family: 'Times New Roman', Times, serif;
}

.boq-letterhead {
  border-top: 6px solid #1f7a40;
  padding-top: 12px;
  margin-bottom: 24px;
  text-align: center;
}

.boq-letterhead-logo {
  max-height: 60px;
  margin: 0 auto 8px;
  display: block;
}

.boq-letterhead h2 {
  margin: 0 0 4px;
  font-size: 22px;
}

.boq-letterhead p {
  margin: 2px 0;
  font-size: 13px;
}

.boq-title {
  text-align: center;
  margin-bottom: 32px;
}

.boq-element {
  margin-bottom: 32px;
}

.boq-table {
  background: #fff;
  border: 1px solid #999;
  border-radius: 0;
  margin-bottom: 4px;
}

.boq-table th,
.boq-table td {
  color: #111;
  border-bottom: 1px solid #ccc;
  font-size: 13px;
}

.boq-table th {
  background: #f0f0f0;
  color: #111;
}

.boq-table .section-header {
  font-style: italic;
  font-weight: 600;
}

.boq-table .num {
  text-align: right;
}

.boq-table .row-carried td,
.boq-table .row-total td {
  font-weight: 600;
  border-top: 2px solid #111;
}

.boq-footer {
  margin-top: 32px;
  font-size: 13px;
}

.struxy-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  font-family: inherit;
}

.struxy-toggle {
  background: var(--teal);
  color: #04201c;
  border: none;
  border-radius: 999px;
  padding: 14px 22px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.struxy-toggle:hover {
  filter: brightness(1.05);
}

.struxy-panel {
  display: none;
  position: absolute;
  bottom: 64px;
  right: 0;
  width: 340px;
  height: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  flex-direction: column;
  overflow: hidden;
}

.struxy-panel.is-open {
  display: flex;
}

.struxy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.struxy-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
}

.struxy-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.struxy-bubble {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.struxy-user {
  align-self: flex-end;
  background: var(--teal);
  color: #04201c;
}

.struxy-assistant {
  align-self: flex-start;
  background: var(--surface-alt);
  color: var(--text);
  border: 1px solid var(--border);
}

.struxy-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.struxy-form input {
  flex: 1;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
}

.struxy-form input:focus {
  outline: none;
  border-color: var(--teal);
}

@media print {
  .sidebar,
  .no-print {
    display: none;
  }
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
}

.btn-danger:hover {
  background: #c2453d;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.is-open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

.modal-box h3 {
  margin: 0 0 10px;
}

.modal-box p {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-actions button {
  width: auto;
  padding: 9px 18px;
}
