:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f9fafc;
  --text: #172033;
  --muted: #697386;
  --line: #dce2ea;
  --brand: #0b3b75;
  --brand-2: #135da8;
  --accent: #e31e2f;
  --success: #0f9f6e;
  --warning: #d08a00;
  --danger: #cc2936;
  --radius: 16px;
  --shadow: 0 14px 30px rgba(17, 24, 39, .08);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button, input, select, textarea {
  font: inherit;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #08264e 0%, #0b3b75 100%);
  color: white;
  padding: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #fff;
  color: var(--brand);
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: -1px;
}

.brand span {
  display: block;
  color: rgba(255,255,255,.72);
  margin-top: 2px;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: rgba(255,255,255,.82);
  text-align: left;
  padding: 12px 14px;
  cursor: pointer;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255,255,255,.13);
  color: white;
}

.sidebar-note {
  margin-top: 32px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255,255,255,.08);
}

.sidebar-note p {
  margin: 6px 0 0;
  color: rgba(255,255,255,.75);
  font-size: 13px;
  line-height: 1.45;
}

.main {
  padding: 28px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.03em;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.card h2,
.card h3 {
  margin: 0 0 14px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.stat {
  display: grid;
  gap: 8px;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  font-size: 32px;
  letter-spacing: -0.05em;
}

.form {
  display: grid;
  gap: 18px;
}

.form-section {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 18px;
}

.form-section h3 {
  margin: 0 0 14px;
}

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

.field {
  display: grid;
  gap: 6px;
  grid-column: span 4;
}

.field.span-2 { grid-column: span 2; }
.field.span-3 { grid-column: span 3; }
.field.span-4 { grid-column: span 4; }
.field.span-5 { grid-column: span 5; }
.field.span-6 { grid-column: span 6; }
.field.span-8 { grid-column: span 8; }
.field.span-9 { grid-column: span 9; }
.field.span-12 { grid-column: span 12; }

label {
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--text);
  padding: 11px 12px;
  outline: 0;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(19,93,168,.12);
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
}

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

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

.btn-outline {
  background: white;
  border-color: var(--line);
  color: var(--text);
}

.btn-outline:hover {
  border-color: var(--brand-2);
  color: var(--brand-2);
}

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

.btn-soft {
  background: #eef4fb;
  color: var(--brand);
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

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

th {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--panel-2);
}

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

.ticket-folio {
  font-family: var(--mono);
  font-weight: 900;
  color: var(--brand);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  border: 1px solid transparent;
}

.badge-blue {
  color: #0b3b75;
  background: #e8f1fb;
  border-color: #c7ddf4;
}

.badge-green {
  color: #087553;
  background: #e8faf3;
  border-color: #c0efdc;
}

.badge-yellow {
  color: #8a5a00;
  background: #fff6df;
  border-color: #f4df9d;
}

.badge-red {
  color: #a11625;
  background: #fff0f1;
  border-color: #f5c7cb;
}

.badge-gray {
  color: #4b5563;
  background: #f3f4f6;
  border-color: #e5e7eb;
}

.alert {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: #e8f1fb;
  color: #0b3b75;
  border: 1px solid #c7ddf4;
}

.alert.success {
  background: #e8faf3;
  color: #087553;
  border-color: #c0efdc;
}

.alert.error {
  background: #fff0f1;
  color: #a11625;
  border-color: #f5c7cb;
}

.hidden {
  display: none !important;
}

.filters {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr) auto;
  gap: 10px;
  margin-bottom: 14px;
  align-items: end;
}

.detail-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 18px;
  align-items: start;
}

.detail-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
}

.timeline-dot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  margin-top: 3px;
  background: #e5e7eb;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
}

.timeline-item.completed .timeline-dot {
  background: var(--success);
}

.timeline-item.in_progress .timeline-dot {
  background: var(--warning);
}

.timeline-item.blocked .timeline-dot {
  background: var(--danger);
}

.timeline-title {
  font-weight: 800;
}

.timeline-date {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.update-list {
  display: grid;
  gap: 10px;
}

.update-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--panel-2);
}

.update-item h4 {
  margin: 0 0 4px;
}

.update-item p {
  margin: 0;
  white-space: pre-wrap;
}

.update-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
}

.kv {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.kv:last-child {
  border-bottom: 0;
}

.kv span:first-child {
  color: var(--muted);
  font-weight: 800;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 32px;
}

.small {
  font-size: 13px;
  color: var(--muted);
}

.danger-zone {
  border-color: #f5c7cb;
  background: #fff8f8;
}

.print-area {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

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

  .topbar,
  .detail-header {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .field,
  .field.span-2,
  .field.span-3,
  .field.span-4,
  .field.span-5,
  .field.span-6,
  .field.span-8,
  .field.span-9,
  .field.span-12 {
    grid-column: span 12;
  }
}

@media print {
  body {
    background: white;
  }

  .app-shell {
    display: none !important;
  }

  .print-area {
    display: block;
  }

  .receipt {
    width: 72mm;
    padding: 4mm;
    font-family: Arial, sans-serif;
    color: #000;
    font-size: 11px;
  }

  .receipt h1 {
    font-size: 18px;
    margin: 0;
    text-align: center;
  }

  .receipt h2 {
    font-size: 13px;
    margin: 4px 0 8px;
    text-align: center;
  }

  .receipt .center {
    text-align: center;
  }

  .receipt .line {
    border-top: 1px dashed #000;
    margin: 8px 0;
  }

  .receipt .row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 4px 0;
  }

  .receipt .label {
    font-weight: 700;
  }

  .receipt p {
    margin: 4px 0;
  }

  .receipt .qr {
    width: 95px;
    height: 95px;
    border: 1px solid #000;
    display: grid;
    place-items: center;
    margin: 8px auto;
    font-size: 10px;
    text-align: center;
  }
}


/* MVP v0.2 enhancements */
.folio-preview-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.folio-preview-card span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.folio-preview-card p {
  margin: 4px 0 0;
  color: var(--muted);
}

.folio-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  border: 2px solid #111827;
  border-radius: 14px;
  color: #000;
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 950;
  letter-spacing: .02em;
  box-shadow: 4px 4px 0 rgba(0,0,0,.18);
}

.folio-ml { background: #ffd43b; }
.folio-piso { background: #21a8ff; }
.folio-interno { background: #42d77d; }
.folio-default { background: #e5e7eb; }

.warning-box {
  border: 1px solid #f4df9d;
  background: #fff8e6;
  color: #604100;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}

.evidence-grid {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
  align-items: start;
}

.evidence-thumb {
  width: 96px;
  height: 96px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f3f4f6;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  padding: 6px;
}

.evidence-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@media (max-width: 700px) {
  .folio-preview-card { display: grid; }
  .folio-badge { width: 100%; }
  .evidence-grid { grid-template-columns: 1fr; }
}


.timeline-item.hidden {
  display: none;
}


.hidden{display:none!important}
.brand-logo-only{align-items:center;gap:12px}
.brand-logo{width:78px;height:auto;border-radius:12px;background:#fff;padding:4px}
.login-screen{min-height:100vh;display:flex;align-items:center;justify-content:center;background:linear-gradient(180deg,#f5f7fb 0%,#e9eef7 100%);padding:20px}
.login-card{width:min(460px,100%);background:#fff;border-radius:20px;padding:28px;box-shadow:0 20px 40px rgba(18,34,74,.12);text-align:center}
.login-logo{width:140px;max-width:80%;margin:0 auto 18px;display:block}
.login-help{margin-top:18px;padding:12px;border-radius:14px;background:#f6f8fc;color:#26324b;font-size:.92rem}
.login-form .btn{width:100%}
.muted{color:#6f7892}
.user-chip{display:flex;align-items:center;gap:10px;padding:8px 12px;border-radius:16px;background:#f6f8fc;min-width:160px}
.user-chip span{display:block;color:#6f7892;font-size:.82rem;margin-top:2px}
.avatar-circle{width:42px;height:42px;border-radius:50%;overflow:hidden;background:#dbe7ff;display:flex;align-items:center;justify-content:center;flex:0 0 auto}
.avatar-circle.large{width:64px;height:64px}
.avatar-img.small,.avatar-fallback.small{width:42px;height:42px;border-radius:50%}
.avatar-img.large,.avatar-fallback.large{width:64px;height:64px;border-radius:50%}
.avatar-img{object-fit:cover;display:block}
.avatar-fallback{display:flex;align-items:center;justify-content:center;background:#165f9d;color:#fff;font-weight:700;text-transform:uppercase}
.toolbar-row{display:flex;gap:12px;align-items:center;justify-content:space-between;flex-wrap:wrap}
.search-input{flex:1;min-width:260px;padding:12px 14px;border:1px solid #d8deea;border-radius:12px;font:inherit}
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:14px}
.stat-card{background:#fff;border:1px solid #e3e8f2;border-radius:18px;padding:20px;display:flex;flex-direction:column;gap:6px;box-shadow:0 6px 20px rgba(16,30,54,.05)}
.stat-card strong{font-size:2rem;color:#111d37}
.item-tools{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
.mini-btn{padding:6px 10px;border:none;border-radius:10px;background:#edf2ff;color:#153265;font-size:.82rem;cursor:pointer}
.mini-btn.danger{background:#ffe5e5;color:#8f1010}
.user-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:14px}
.user-card{border:1px solid #e3e8f2;border-radius:18px;padding:16px;background:#fff}
.user-card-head{display:flex;gap:14px;align-items:flex-start}
.user-card-head h3{margin:0 0 4px}
.user-card-actions{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}
.perm-list{display:flex;gap:6px;flex-wrap:wrap}
.perm-pill{padding:5px 8px;border-radius:999px;background:#f0f4fb;font-size:.75rem;color:#36415e}
.receipt-logo-wrap{text-align:center;margin-bottom:8px}
.receipt-logo{width:190px;height:auto;max-width:90%}
.step-row{display:flex;justify-content:space-between;gap:10px;font-size:.82rem;margin-bottom:6px}
.qr-wrap{text-align:center;margin:12px 0}
.qr-img{width:150px;height:150px;object-fit:contain}
.qr-img-large{width:180px;height:180px;object-fit:contain;display:block;margin:0 auto 12px}
.receipt h2{margin:0 0 8px;text-align:center;font-size:1.1rem}
.receipt .row{display:flex;justify-content:space-between;gap:10px;font-size:.82rem;margin-bottom:4px}
.receipt p{font-size:.82rem;line-height:1.35;margin:8px 0}
.receipt .label{font-weight:700}
.receipt .line{border-top:1px dashed #222;margin:10px 0}
.receipt .center{text-align:center}
.letter-sheet{background:#fff;padding:28px;min-height:100vh;color:#111;font-family:Arial,sans-serif}
.letter-header{display:flex;align-items:center;gap:18px;border-bottom:2px solid #d9e0ea;padding-bottom:14px;margin-bottom:16px}
.letter-logo{width:110px;height:auto;border-radius:10px}
.letter-header h2{margin:0 0 4px;font-size:1.35rem}
.letter-columns{display:grid;grid-template-columns:1fr 1fr;gap:24px}
.letter-col{min-width:0}
.section-block{border:1px solid #e4e7ef;border-radius:14px;padding:12px 14px;margin-bottom:14px;break-inside:avoid}
.section-block h3,.policy-summary h3,.signature-box h3,.qr-card h3{margin:0 0 10px;font-size:1rem;color:#163259}
.policy-summary,.signature-box,.qr-card{border:1px solid #e4e7ef;border-radius:14px;padding:14px 16px;margin-bottom:14px}
.policy-summary ul{padding-left:18px;margin:0}
.policy-summary li{margin-bottom:8px;line-height:1.4}
.qr-card{text-align:center}
.sign-line{border-bottom:1px solid #111;height:44px;margin:28px 0 8px}
.sign-grid{display:flex;justify-content:space-between;font-size:.84rem;color:#333}
.print-area{position:fixed;inset:0;background:#fff;z-index:-1;opacity:0;pointer-events:none}
.print-only{display:none}
@media print{
  body>*:not(#printArea){display:none!important}
  #printArea{position:static!important;opacity:1!important;pointer-events:auto!important;z-index:9999!important}
  #printArea .print-only{display:block}
  @page{size:letter portrait;margin:12mm}
  .letter-sheet{padding:0}
  .receipt{width:80mm;margin:0 auto;padding:0 2mm;font-family:Arial,sans-serif}
}
@media (max-width:980px){
  .topbar-actions{flex-wrap:wrap;justify-content:flex-end}
  .letter-columns{grid-template-columns:1fr}
}
@media (max-width:768px){
  .user-chip{min-width:auto}
  .brand-logo{width:62px}
  .toolbar-row{align-items:stretch}
  .search-input{min-width:100%}
}


.app-footer {
  margin-top: 28px;
  padding: 18px 8px 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.login-help.safe {
  background: #f1f5fb;
  border: 1px solid #dce6f2;
}

.supplier-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: var(--panel-2);
}

.supplier-card h3 {
  margin: 0 0 6px;
}

.supplier-rma-tools {
  align-content: end;
}

.btn-mini {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 10px;
}

.rma-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 12px;
  margin-bottom: 12px;
}

@media (max-width: 760px) {
  .supplier-card,
  .rma-action-row {
    flex-direction: column;
    align-items: stretch;
  }
}


/* MVP v0.4.4 print refinements */
.receipt-logo-wrap{text-align:center;margin-bottom:6px}
.receipt-logo{width:170px;max-width:92%;height:auto}
.receipt-title{font-weight:800;text-align:center;font-size:15px;letter-spacing:.01em;margin-bottom:6px}
.receipt-folio{text-align:center;font-weight:800;font-size:12px;margin-bottom:6px}
.receipt-divider{border-top:1px dashed #111;margin:7px 0}
.receipt-meta,.receipt-block,.receipt-steps{display:grid;gap:4px}
.receipt-field{display:grid;grid-template-columns:78px 1fr;gap:6px;align-items:start;font-size:11px;line-height:1.25}
.receipt-field-label{font-weight:700}
.receipt-field-value{word-break:break-word}
.receipt-block-title{font-weight:800;font-size:11px;text-transform:uppercase;letter-spacing:.03em;margin-bottom:2px}
.receipt-paragraph{font-size:11px;line-height:1.28;word-break:break-word;white-space:normal}
.receipt-step{padding:1px 0}
.receipt-step-title{font-size:11px;font-weight:700;line-height:1.22}
.receipt-step-date{font-size:10px;color:#333;padding-left:14px;line-height:1.2}
.receipt-legal{font-size:10.5px;line-height:1.25;text-align:left}
.receipt-web{text-align:center;font-size:11px;font-weight:700;margin:6px 0 2px}
.qr-wrap{text-align:center;margin:8px 0 6px}
.qr-img{width:108px;height:108px;object-fit:contain}
.receipt-thanks{text-align:center;font-size:11px;font-weight:800;margin-top:4px}

.letter-sheet{background:#fff;color:#111;font-family:Arial,sans-serif}
.letter-page{width:8.5in;height:11in;padding:.34in .34in .30in;overflow:hidden;background:#fff}
.letter-header-fixed{display:flex;justify-content:space-between;align-items:center;gap:.22in;margin-bottom:.14in}
.letter-header-left{display:flex;align-items:center;gap:.18in;min-width:0}
.letter-logo{width:1.18in;height:auto}
.letter-title{font-size:22px;font-weight:900;color:#1a4d92;line-height:1.05;letter-spacing:.01em}
.letter-subtitle{font-size:13px;color:#6b7280;font-weight:700;margin-top:2px}
.letter-folio-box{border:2px solid #b9c7dd;border-radius:8px;padding:8px 12px;display:flex;gap:10px;align-items:center;background:#f7fafe;white-space:nowrap}
.letter-folio-box span{text-transform:uppercase;color:#1a4d92;font-weight:800;font-size:12px}
.letter-folio-box strong{font-size:22px;color:#2f3640;letter-spacing:.02em}
.letter-grid{display:grid;grid-template-columns:1.25fr .95fr;gap:.18in;height:calc(100% - 1.12in)}
.letter-left-col,.letter-right-col{min-width:0}
.letter-section,.policy-summary.compact-print,.qr-card.compact-print,.signature-box.compact-print{border:1px solid #c7d0df;border-radius:10px;background:#fff;page-break-inside:avoid;break-inside:avoid}
.letter-section{padding:8px 10px;margin-bottom:10px}
.letter-section-title{font-size:13px;font-weight:900;color:#1a4d92;margin:0 0 6px;text-transform:uppercase;letter-spacing:.01em}
.letter-table{display:grid;border-top:1px solid #d8dee9}
.letter-tr{display:grid;grid-template-columns:1.35in 1fr;border-bottom:1px solid #d8dee9;min-height:25px}
.letter-th,.letter-td{padding:5px 8px;font-size:10.3px;line-height:1.25}
.letter-th{font-weight:800;color:#2f3640;background:#fafbfd}
.letter-td{word-break:break-word}
.letter-timeline{display:grid;gap:6px;padding-top:2px}
.letter-timeline-item{display:grid;grid-template-columns:16px 1fr;gap:8px;align-items:start}
.letter-timeline-dot{width:12px;height:12px;border-radius:999px;border:2px solid #9ba7b8;background:#fff;margin-top:2px}
.letter-timeline-item.done .letter-timeline-dot{background:#1a4d92;border-color:#1a4d92}
.letter-timeline-title{font-weight:800;font-size:10.2px;line-height:1.2}
.letter-timeline-date{font-size:9.7px;color:#5f6978;line-height:1.2;margin-top:1px}
.policy-summary.compact-print,.qr-card.compact-print,.signature-box.compact-print{padding:10px 12px;margin-bottom:10px}
.policy-summary.compact-print h3,.qr-card.compact-print h3,.signature-box.compact-print h3{margin:0 0 8px;font-size:13px;font-weight:900;color:#1a4d92;text-align:left}
.policy-summary.compact-print ul{padding-left:17px;margin:0}
.policy-summary.compact-print li{font-size:9.3px;line-height:1.24;margin-bottom:5px}
.qr-card.compact-print{text-align:center}
.qr-card.compact-print h3{text-align:center}
.qr-img-large{width:1.55in;height:1.55in;object-fit:contain;display:block;margin:4px auto 2px}
.signature-box.compact-print p{font-size:9.5px;line-height:1.3;margin:0}
.sign-line{border-bottom:1px solid #111;height:38px;margin:18px 0 6px}
.sign-grid{display:flex;justify-content:space-between;font-size:9.2px;color:#333;gap:10px}

@media print{
  @page{size:Letter portrait;margin:0}
  html,body{width:8.5in;height:11in;background:#fff;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  body>*:not(#printArea){display:none!important}
  #printArea{display:block!important;position:static!important;opacity:1!important;pointer-events:auto!important;z-index:9999!important;margin:0!important;padding:0!important;background:#fff!important}
  #printArea .print-only{display:block!important}
  .receipt{width:80mm;min-height:auto;margin:0 auto;padding:3mm 2.2mm 2.5mm;color:#000;font-family:Arial,sans-serif;background:#fff}
  .letter-sheet{width:8.5in;height:11in;margin:0;padding:0}
}


/* MVP v0.4.5 refinements */
.equipment-lines {
  display: grid;
  gap: 2px;
  line-height: 1.22;
}
.equipment-lines strong {
  color: var(--text);
  font-size: 13px;
}
.equipment-lines span {
  color: var(--muted);
  font-size: 12px;
}
.latest-ticket-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--panel-2);
}
.latest-ticket-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.latest-ticket-top span {
  color: var(--muted);
  font-size: 12px;
}
.latest-ticket-client {
  margin-top: 6px;
  font-weight: 800;
}
.latest-ticket-equipment {
  margin-top: 6px;
}
.device-type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.device-type-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 8px 6px 12px;
  background: var(--panel-2);
  font-size: 13px;
  font-weight: 800;
}

@media print {
  body.print-ticket-mode {
    width: 80mm !important;
    min-width: 80mm !important;
    height: auto !important;
  }
  body.print-ticket-mode #printArea {
    width: 80mm !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body.print-ticket-mode .receipt {
    width: 72mm !important;
    margin: 0 auto !important;
    padding: 2mm 0 !important;
    transform: none !important;
  }
  body.print-letter-mode,
  body.print-letter-mode #printArea,
  body.print-letter-mode .letter-sheet {
    width: 8.5in !important;
    height: 11in !important;
  }
  body.print-letter-mode .letter-page {
    width: 8.5in !important;
    height: 11in !important;
  }
}

@media (max-width: 760px) {
  .latest-ticket-card {
    grid-template-columns: 1fr;
  }
}


/* MVP v0.4.6 backup configuration */
.backup-file-list {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 13px;
  word-break: break-word;
}
.backup-file-list code {
  white-space: normal;
  word-break: break-word;
}
label input[type="checkbox"] {
  margin-right: 8px;
}


/* MVP v0.4.7 backup setup refinements */
.backup-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}
.backup-flow-step {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
  padding: 10px;
  display: grid;
  gap: 6px;
}
.backup-flow-step strong {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #e5e7eb;
  color: #111827;
}
.backup-flow-step.active strong {
  background: #fff6df;
  color: #8a5a00;
}
.backup-flow-step.done strong {
  background: #e8faf3;
  color: #087553;
}
.backup-flow-step span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.checkbox-line label {
  display: flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: normal;
  font-size: 14px;
  color: var(--text);
}
.checkbox-line input {
  width: auto;
}
@media (max-width: 780px) {
  .backup-flow {
    grid-template-columns: 1fr;
  }
}


/* MVP v0.4.8 backup diagnostic */
.backup-diagnostic {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--panel-2);
  margin: 12px 0;
}
.backup-diagnostic h3 {
  margin: 0 0 10px;
}
.backup-diagnostic .kv {
  grid-template-columns: 140px 1fr;
  padding: 6px 0;
}


/* MVP v0.4.12 filtros compactos, calendario y solicitud directa */
.ticket-toolbar-v0412 {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  margin: 14px 0;
}
.calendar-filter-wrap,
.header-filter-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.filter-popover {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .14);
  padding: 12px;
}
.calendar-popover {
  width: 470px;
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 12px;
  right: 0;
}
.date-quick-list {
  display: grid;
  gap: 4px;
  border-right: 1px solid var(--line);
  padding-right: 10px;
}
.date-quick-list button {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 700;
}
.date-quick-list button.active,
.date-quick-list button:hover {
  background: #e8f1fb;
  color: var(--brand);
}
.date-custom-panel {
  display: grid;
  gap: 10px;
}
.date-custom-panel label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
}
.date-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}
.header-filter-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  padding: 0;
}
.header-filter-btn.is-active {
  color: var(--brand);
}
.header-filter-popover {
  left: 0;
  right: auto;
  top: calc(100% + 10px);
  min-width: 260px;
  display: grid;
  gap: 8px;
  text-transform: none;
  font-weight: 700;
}
.header-filter-popover label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-size: 13px;
}
.header-filter-popover input {
  width: auto;
}
.mini-actions {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 8px;
}
.btn-success {
  background: #14a765;
  color: #fff;
  border-color: #14a765;
}
.btn-success:hover {
  background: #0f8f56;
  border-color: #0f8f56;
}
.sort-link {
  border: 0;
  border-radius: 8px;
  background: #e8f1fb;
  color: var(--brand);
  font-weight: 900;
  cursor: pointer;
  padding: 2px 7px;
}
.stat-click {
  text-align: left;
  width: 100%;
}
button.stat-card {
  border: 1px solid var(--line);
  cursor: pointer;
  font-family: inherit;
}
button.stat-card:hover {
  border-color: var(--brand-2);
  transform: translateY(-1px);
}
.direct-provider-list {
  display: grid;
  gap: 10px;
}
.direct-provider-row {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-2);
  padding: 14px;
}
.direct-provider-row h3 {
  margin: 0 0 10px;
}
.direct-provider-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.direct-link-btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--brand);
  font-weight: 900;
  padding: 9px 12px;
  cursor: pointer;
}
.direct-link-btn:hover {
  border-color: var(--brand-2);
  background: #f5f8ff;
}
@media (max-width: 980px) {
  .ticket-toolbar-v0412 {
    grid-template-columns: 1fr;
  }
  .calendar-popover {
    width: min(92vw, 470px);
    grid-template-columns: 1fr;
    left: 0;
    right: auto;
  }
  .date-quick-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-bottom: 10px;
  }
}


.table-empty {
  min-height: 540px;
  display: flex;
  align-items: center;
  justify-content: center;
}


.table-wrap.is-empty-table {
  min-height: 620px;
}
.table-wrap.is-empty-table table {
  min-height: 600px;
}
.table-empty {
  min-height: 540px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Estado de la base compartida en el servidor */
.sync-pill{display:inline-flex;align-items:center;gap:6px;padding:8px 12px;border-radius:16px;font-weight:600;font-size:.78rem;letter-spacing:.02em;cursor:default;white-space:nowrap}
.sync-pill::before{content:"";width:8px;height:8px;border-radius:50%;background:currentColor;flex:none}
.sync-pill.ok{background:#e8f5ec;color:#1f7a3f}
.sync-pill.warn{background:#fdf3d8;color:#8a6616}
.sync-pill.danger{background:#fae3e3;color:#9a2b2b}
