/* Fila do Reparo — Claro Operacional Design System
 * Zero external CDNs. Font >= 12px. Inputs >= 16px. Tap targets >= 44x44px.
 */

:root {
  /* Core Surfaces & Neutrals */
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-alt: #E9EEF5;
  --border: #D6DFEB;
  --border-strong: #B8C5D6;

  /* Ink */
  --text: #0F172A;
  --text-muted: #475569;
  --text-subtle: #64748B;

  /* White-Label Brand Tokens */
  --primary: #0B4F6C;
  --primary-hover: #083B52;
  --primary-soft: #E6F2F7;
  --primary-ink: #FFFFFF;

  --accent: #EA580C;
  --accent-hover: #C2410C;
  --accent-soft: #FFF1E6;
  --accent-ink: #9A3412;

  /* Feedback Tokens */
  --danger: #DC2626;
  --danger-hover: #B91C1C;
  --danger-soft: #FEF2F2;
  --danger-bd: #FCA5A5;

  --success: #15803D;
  --success-hover: #166534;
  --success-soft: #DCFCE7;
  --success-bd: #86EFAC;

  --warning: #B45309;
  --warning-soft: #FEF3C7;
  --warning-bd: #FCD34D;

  /* Semantic Status Palette */
  --st-em_analise: #0284C7;
  --st-em_analise-bg: #E0F2FE;
  --st-em_analise-bd: #7DD3FC;

  --st-orcamento: #D97706;
  --st-orcamento-bg: #FEF3C7;
  --st-orcamento-bd: #FCD34D;

  --st-aprovado: #2563EB;
  --st-aprovado-bg: #DBEAFE;
  --st-aprovado-bd: #93C5FD;

  --st-em_bancada: #7C3AED;
  --st-em_bancada-bg: #F3E8FF;
  --st-em_bancada-bd: #C4B5FD;

  --st-pronto: #15803D;
  --st-pronto-bg: #DCFCE7;
  --st-pronto-bd: #86EFAC;

  --st-entregue: #0F766E;
  --st-entregue-bg: #CCFBF1;
  --st-entregue-bd: #5EEAD4;

  --st-cancelada: #64748B;
  --st-cancelada-bg: #F1F5F9;
  --st-cancelada-bd: #CBD5E1;

  /* Geometry & Elevation */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, 0.22);

  /* Safe Areas & Header */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --topbar-h: 64px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  overflow-x: clip;
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  padding-bottom: var(--safe-bottom);
}

body.fr-modal-open {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

img,
svg {
  max-width: 100%;
}

.fr-icon {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
}

.fr-qr-svg {
  display: block;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #FFFFFF;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  color: var(--text);
  line-height: 1.25;
  letter-spacing: -0.012em;
}

h1 {
  font-size: 1.5rem;
  font-weight: 800;
}

h2 {
  font-size: 1.25rem;
  font-weight: 750;
}

h3 {
  font-size: 1.0625rem;
  font-weight: 700;
}

h4 {
  font-size: 0.9375rem;
  font-weight: 700;
}

p {
  margin: 0;
}

a {
  color: var(--primary);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}

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

:focus-visible {
  outline: 3px solid var(--st-aprovado);
  outline-offset: 2px;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

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

.text-sm {
  font-size: 0.875rem;
}

.text-xs {
  font-size: 0.75rem;
}

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

/* Hard Mobile/iOS Invariants: Inputs >= 16px, Tap Targets >= 44x44px */
input,
select,
textarea {
  font-family: inherit;
  font-size: 16px;
  line-height: 1.35;
  min-height: 44px;
  color: var(--text);
}

button,
a.btn,
.btn,
.tab-btn,
.tap-target {
  min-height: 44px;
  min-width: 44px;
  font-family: inherit;
  touch-action: manipulation;
}

/* ==========================================================================
   Safe Auto-Update Banner (#app-update)
   ========================================================================== */
.update-banner,
#app-update {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px calc(16px + var(--safe-right)) 10px calc(16px + var(--safe-left));
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-bottom: 2px solid var(--accent);
  font-size: 0.9375rem;
  font-weight: 600;
}

.update-banner-msg {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.update-banner-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================================
   Topbar (Sticky Claro Operacional Header)
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-height: var(--topbar-h);
  padding: calc(8px + var(--safe-top)) calc(16px + var(--safe-right)) 8px calc(16px + var(--safe-left));
  background: var(--surface);
  border-top: 4px solid var(--primary);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

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

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: 38px;
  height: 38px;
  max-width: 120px;
  max-height: 38px;
  object-fit: contain;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-size: 1.0625rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-pill > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Containers, Layout Utilities & Cards
   ========================================================================== */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px calc(16px + var(--safe-right)) calc(36px + var(--safe-bottom)) calc(16px + var(--safe-left));
}

.container-narrow {
  max-width: 820px;
}

.container-sm {
  max-width: 560px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.divider {
  height: 1px;
  background: var(--border);
  border: 0;
  margin: 14px 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.card-body {
  padding: 18px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ==========================================================================
   KPI Grid & Cards
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.kpi-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.kpi-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 1.625rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-subtle);
}

/* ==========================================================================
   Tabs
   ========================================================================== */
.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
}

.tab-btn.is-active,
.tab-btn[aria-selected="true"] {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease, color 0.14s ease, transform 0.08s ease;
}

.btn:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--text-subtle);
  color: var(--text);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  color: var(--primary-ink);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #FFFFFF;
}

.btn-secondary {
  background: var(--surface-alt);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: #DCE4EF;
  color: var(--text);
}

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

.btn-ghost:hover:not(:disabled) {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary-hover);
}

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

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
  color: #FFFFFF;
}

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: #FFFFFF;
}

.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
  border-color: var(--success-hover);
  color: #FFFFFF;
}

.btn-sm {
  min-height: 44px;
  min-width: 44px;
  padding: 6px 12px;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

/* ==========================================================================
   Badges & Status Pills
   ========================================================================== */
.badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.status-pill::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.status-em_analise {
  background: var(--st-em_analise-bg);
  border-color: var(--st-em_analise-bd);
  color: #0369A1;
}

.status-orcamento {
  background: var(--st-orcamento-bg);
  border-color: var(--st-orcamento-bd);
  color: #92400E;
}

.status-aprovado {
  background: var(--st-aprovado-bg);
  border-color: var(--st-aprovado-bd);
  color: #1D4ED8;
}

.status-em_bancada {
  background: var(--st-em_bancada-bg);
  border-color: var(--st-em_bancada-bd);
  color: #6D28D9;
}

.status-pronto {
  background: var(--st-pronto-bg);
  border-color: var(--st-pronto-bd);
  color: #15803D;
}

.status-entregue {
  background: var(--st-entregue-bg);
  border-color: var(--st-entregue-bd);
  color: #0F766E;
}

.status-cancelada {
  background: var(--st-cancelada-bg);
  border-color: var(--st-cancelada-bd);
  color: #475569;
}

.badge-priority {
  background: var(--accent-soft);
  border-color: #FDBA74;
  color: var(--accent-ink);
}

.badge-warranty {
  background: #EDE9FE;
  border-color: #C4B5FD;
  color: #5B21B6;
}

.badge-success {
  background: var(--success-soft);
  border-color: var(--success-bd);
  color: #166534;
}

.badge-warning {
  background: var(--warning-soft);
  border-color: var(--warning-bd);
  color: #92400E;
}

.badge-danger {
  background: var(--danger-soft);
  border-color: var(--danger-bd);
  color: #B91C1C;
}

.badge-info {
  background: var(--primary-soft);
  border-color: #BAE6FD;
  color: var(--primary);
}

/* ==========================================================================
   Forms & Fields
   ========================================================================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label,
.field > label {
  font-size: 0.875rem;
  font-weight: 650;
  color: var(--text);
}

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

.field-error {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--danger);
}

.input,
.select,
.textarea,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  min-height: 44px;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.field textarea,
.textarea {
  min-height: 88px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(11, 79, 108, 0.16);
  outline: none;
}

.field input[type="color"] {
  width: 56px;
  height: 44px;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
}

.checkbox-row input[type="checkbox"],
.checkbox-row input[type="radio"] {
  width: 20px;
  height: 20px;
  min-height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  padding-right: 52px;
}

.password-toggle {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.password-toggle:hover {
  color: var(--text);
  background: var(--surface-alt);
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

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

.table th {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg);
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: #F8FAFC;
}

/* ==========================================================================
   Modals (Accessible Dialogs)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  background: rgba(15, 23, 42, 0.54);
  backdrop-filter: blur(2px);
}

.modal-dialog {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: calc(100dvh - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-sm {
  max-width: 440px;
}

.modal-md {
  max-width: 640px;
}

.modal-lg {
  max-width: 900px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 750;
  color: var(--text);
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1 1 auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ==========================================================================
   Toast Region
   ========================================================================== */
.toast-region {
  position: fixed;
  right: calc(16px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-md);
  font-size: 0.9375rem;
  font-weight: 600;
  pointer-events: auto;
}

.toast-body {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.toast-info {
  border-left: 4px solid var(--primary);
}

.toast-success {
  border-left: 4px solid var(--success);
  background: #F0FDF4;
  color: #14532D;
}

.toast-warning {
  border-left: 4px solid var(--accent);
  background: #FFF7ED;
  color: #7C2D12;
}

.toast-error {
  border-left: 4px solid var(--danger);
  background: #FEF2F2;
  color: #7F1D1D;
}

.toast-close {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Login Shell
   ========================================================================== */
.login-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(20px + var(--safe-top)) calc(16px + var(--safe-right)) calc(24px + var(--safe-bottom)) calc(16px + var(--safe-left));
  background: linear-gradient(180deg, var(--primary-soft) 0%, var(--bg) 42%);
}

.login-card {
  width: 100%;
  max-width: 430px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-back-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.login-brand .brand-logo {
  width: 48px;
  height: 48px;
  max-height: 48px;
}

.login-error {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--danger-bd);
  background: var(--danger-soft);
  color: #991B1B;
  font-size: 0.875rem;
  font-weight: 600;
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 36px 20px;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--primary);
}

/* ==========================================================================
   3x3 Visual Unlock Pattern Widget
   ========================================================================== */
.pattern-widget {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pattern-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  place-items: center;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 8px;
  user-select: none;
  touch-action: none;
}

.pattern-grid.is-readonly {
  touch-action: auto;
  background: var(--surface-alt);
}

.pattern-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.pattern-dot {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-subtle);
  font-size: 0.875rem;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, transform 0.1s ease;
}

.pattern-dot::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-strong);
}

.pattern-dot.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
  box-shadow: 0 0 0 4px rgba(11, 79, 108, 0.18);
}

.pattern-dot.is-active::after {
  display: none;
}

.pattern-grid.is-readonly .pattern-dot {
  cursor: default;
}

.pattern-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  flex-wrap: wrap;
}

.pattern-code {
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Stepper (Public & Staff Order Progress)
   ========================================================================== */
.stepper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.stepper-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 650;
}

.stepper-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-alt);
  border: 2px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.stepper-item.is-done {
  border-color: var(--st-pronto-bd);
  background: #F0FDF4;
  color: #166534;
}

.stepper-item.is-done .stepper-dot {
  background: var(--success);
  border-color: var(--success);
  color: #FFFFFF;
}

.stepper-item.is-current {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

.stepper-item.is-current .stepper-dot {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-ink);
}

.stepper-item.is-cancelled {
  border-color: var(--st-cancelada-bd);
  background: var(--st-cancelada-bg);
  color: #475569;
}

.stepper-item.is-cancelled .stepper-dot {
  background: var(--st-cancelada);
  border-color: var(--st-cancelada);
  color: #FFFFFF;
}

/* ==========================================================================
   Timeline (Order Events)
   ========================================================================== */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.timeline-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--primary-soft);
}

.timeline-content {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
}

.timeline-title {
  font-size: 0.9375rem;
  font-weight: 650;
  color: var(--text);
}

.timeline-detail {
  margin-top: 4px;
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.timeline-meta {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--text-subtle);
}

/* ==========================================================================
   Photo Grid (Up to 4 Entry Photos <= 24 KB)
   ========================================================================== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.photo-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.photo-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--surface-alt);
  display: block;
  cursor: pointer;
}

.photo-meta {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.photo-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(15, 23, 42, 0.72);
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.photo-remove:hover {
  background: var(--danger);
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 768px) {
  .topbar {
    padding: calc(8px + var(--safe-top)) 12px 8px 12px;
  }

  .container {
    padding: 14px 12px calc(28px + var(--safe-bottom)) 12px;
  }

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

  .card-header,
  .card-body {
    padding: 14px;
  }

  .user-pill {
    max-width: 190px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.3125rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .modal-dialog {
    border-radius: var(--radius-md);
  }
}

/* ==========================================================================
   Print Helpers
   ========================================================================== */
@media print {
  html,
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    overflow: visible !important;
  }

  .no-print,
  .topbar,
  .update-banner,
  #app-update,
  .toast-region,
  .modal-backdrop {
    display: none !important;
  }

  .card {
    box-shadow: none !important;
    border-color: #CBD5E1 !important;
  }
}
