:root {
  --navy: #1e1c33;
  --navy-2: #292640;
  --cyan: #12e3eb;
  --cyan-deep: #00a8b2;
  --magenta: #d11579;
  --ivory: #f4f1e9;
  --paper: #fffefa;
  --ink: #232035;
  --muted: #716d7e;
  --line: #ded9d0;
  --success: #1a9c78;
  --warning: #e39916;
  --danger: #ce445c;
  --shadow: 0 18px 50px rgba(30, 28, 51, .12);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--ivory);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(330px, .9fr) minmax(460px, 1.1fr);
  background: var(--navy);
}
.login-brand {
  padding: clamp(34px, 7vw, 94px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: white;
  background:
    radial-gradient(circle at 20% 80%, rgba(18, 227, 235, .2), transparent 32%),
    radial-gradient(circle at 80% 15%, rgba(209, 21, 121, .16), transparent 28%);
}
.login-logo { width: min(320px, 70%); height: auto; }
.login-brand h1 { font-size: clamp(34px, 4vw, 60px); line-height: 1; margin: 24px 0 14px; letter-spacing: -.04em; }
.login-brand p { color: #c8c5d4; max-width: 480px; font-size: 18px; line-height: 1.6; }
.login-accent { display: flex; align-items: center; gap: 10px; color: var(--cyan); font-weight: 800; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; }
.login-accent::before { content: ""; width: 40px; height: 4px; border-radius: 5px; background: var(--magenta); }
.login-panel { background: var(--paper); display: grid; place-items: center; padding: 30px; border-radius: 38px 0 0 38px; }
.login-box { width: min(430px, 100%); }
.login-box h2 { margin: 0 0 8px; font-size: 30px; }
.login-box > p { margin: 0 0 30px; color: var(--muted); }
.demo-access { margin-top: 26px; padding: 16px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.demo-access strong { color: var(--ink); }
.environment-notice { margin-top: 22px; padding: 14px 16px; border: 1px solid #f0c36a; border-radius: 12px; color: #704800; background: #fff5d8; line-height: 1.45; font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 28px 18px;
  color: white; background: var(--navy); display: flex; flex-direction: column;
}
.sidebar-logo { width: 150px; margin: 0 12px 36px; }
.nav { display: grid; gap: 7px; }
.nav-button {
  width: 100%; border: 0; border-radius: 13px; padding: 13px 14px; color: #c8c5d4;
  background: transparent; text-align: left; display: flex; align-items: center; gap: 12px; font-weight: 700;
}
.nav-button:hover { background: rgba(255,255,255,.07); color: white; }
.nav-button.active { background: var(--cyan); color: var(--navy); }
.nav-icon { width: 24px; text-align: center; font-size: 18px; }
.badge { margin-left: auto; min-width: 23px; height: 23px; padding: 0 7px; border-radius: 20px; display: grid; place-items: center; background: var(--magenta); color: white; font-size: 12px; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 18px; }
.user-card { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--magenta); display: grid; place-items: center; font-weight: 900; }
.user-name { font-weight: 800; font-size: 14px; }
.user-role { color: #aaa6b9; text-transform: capitalize; font-size: 12px; }
.logout { border: 0; color: #aaa6b9; background: none; font-size: 18px; }

.workspace { min-width: 0; }
.topbar { min-height: 82px; display: flex; align-items: center; gap: 14px; padding: 15px clamp(20px, 4vw, 56px); border-bottom: 1px solid var(--line); background: rgba(244,241,233,.92); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.topbar h1 { margin: 0; font-size: clamp(22px, 3vw, 31px); letter-spacing: -.025em; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { margin-left: auto; display: flex; gap: 10px; }
.environment-banner { display: flex; justify-content: center; gap: 10px; padding: 8px 16px; color: #704800; background: #fff0bd; border-bottom: 1px solid #e7c55f; font-size: 12px; }
.environment-banner b { letter-spacing: .06em; }
.content { width: 100%; min-width: 0; padding: 32px clamp(20px, 4vw, 56px) 60px; max-width: 1450px; margin: 0 auto; }
#page-content, .settings-card, .checklist-editor { min-width: 0; }

.button { border: 0; border-radius: 12px; padding: 11px 17px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.button.primary { color: var(--navy); background: var(--cyan); }
.button.primary:hover { background: #37eef3; }
.button.secondary { color: var(--ink); background: white; border: 1px solid var(--line); }
.button.magenta { color: white; background: var(--magenta); }
.button.danger { color: var(--danger); background: #fff0f2; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.icon-button { border: 1px solid var(--line); background: white; border-radius: 11px; width: 40px; height: 40px; }

.page-heading { display: flex; gap: 20px; justify-content: space-between; align-items: flex-end; margin-bottom: 25px; }
.page-heading h2 { margin: 0 0 6px; font-size: 25px; }
.page-heading p { margin: 0; color: var(--muted); }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.kicker { color: var(--magenta); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; margin-bottom: 8px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 8px 22px rgba(30,28,51,.04); }
.stat-value { font-size: 35px; font-weight: 900; letter-spacing: -.05em; }
.stat-label { color: var(--muted); margin-top: 4px; }
.stat.cyan { border-top: 5px solid var(--cyan); }
.stat.magenta { border-top: 5px solid var(--magenta); }
.stat.warning { border-top: 5px solid var(--warning); }
.stat.success { border-top: 5px solid var(--success); }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: 0 9px 26px rgba(30,28,51,.045); }
.card + .card { margin-top: 18px; }
.card-title { margin: 0 0 18px; font-size: 18px; }
.empty { min-height: 190px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 35px; }
.empty-icon { font-size: 42px; opacity: .55; margin-bottom: 8px; }

.form-section { padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid var(--line); }
.form-section:last-child { border: 0; padding-bottom: 0; margin-bottom: 0; }
.section-title { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.section-number { width: 30px; height: 30px; border-radius: 50%; color: var(--navy); background: var(--cyan); display: grid; place-items: center; font-weight: 900; }
.section-title h3 { margin: 0; font-size: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.field { grid-column: span 4; display: grid; gap: 7px; align-content: start; }
.field.span-6 { grid-column: span 6; }
.field.span-8 { grid-column: span 8; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 800; }
.required::after { content: " *"; color: var(--magenta); }
input, select, textarea { width: 100%; color: var(--ink); background: white; border: 1px solid #ccc6bd; border-radius: 11px; padding: 11px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--cyan-deep); box-shadow: 0 0 0 3px rgba(18,227,235,.15); }
textarea { min-height: 105px; resize: vertical; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.45; }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; }
.inline-check { display: flex; align-items: center; gap: 8px; margin-top: 29px; }
.inline-check input { width: auto; }
.feedback { padding: 12px 14px; border-radius: 11px; margin-bottom: 16px; }
.feedback.error { background: #fff0f2; color: #9b2641; border: 1px solid #f3b9c4; }
.feedback.success { background: #ebfff8; color: #106e56; border: 1px solid #a6e6d3; }

.pattern-wrap { display: grid; grid-template-columns: 200px 1fr; gap: 22px; align-items: center; }
.pattern-board { position: relative; width: 190px; aspect-ratio: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px; padding: 21px; touch-action: none; user-select: none; }
.pattern-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.pattern-lines polyline { fill: none; stroke: var(--magenta); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.pattern-dot { z-index: 1; width: 32px; height: 32px; align-self: center; justify-self: center; padding: 0; border: 4px solid var(--navy); border-radius: 50%; background: white; color: var(--navy); font-size: 12px; font-weight: 900; }
.pattern-dot.selected { border-color: var(--magenta); background: var(--cyan); transform: scale(1.1); }
.pattern-result { font-weight: 900; font-variant-numeric: tabular-nums; color: var(--magenta); }
.screen-pattern { display: block; width: min(190px, 100%); margin: 10px auto 4px; }
.screen-pattern .path { fill: none; stroke: var(--magenta); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.screen-pattern .dot { fill: white; stroke: var(--navy); stroke-width: 3; }
.screen-pattern .start { fill: var(--navy); }
.screen-pattern .end { fill: none; stroke: var(--magenta); stroke-width: 2; }
.pattern-legend { text-align: center; color: var(--muted); font-size: 11px; font-weight: 800; }

.order-search-card { padding: 15px 18px; margin-bottom: 18px; }
.order-search { display: grid; grid-template-columns: minmax(260px, 1fr) auto auto; gap: 10px; align-items: end; }
.order-search .field { grid-column: auto; }
.order-search-card .hint { margin: 8px 0 0; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 15px; background: white; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 14px 16px; border-bottom: 1px solid #eeeae3; text-align: left; font-size: 14px; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: 11px; background: #faf8f3; }
tbody tr:hover { background: #fbfaf7; }
.order-number { color: var(--navy); font-weight: 900; }
.pill { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 20px; background: #efedf3; color: #524e61; font-size: 11px; font-weight: 900; text-transform: uppercase; }
.pill.urgente { color: #9b1658; background: #ffe3f1; }
.pill.arriba { color: #006d74; background: #d9fbfc; }
.pill.abajo { color: #7a4e00; background: #fff0ce; }
.pill.active { color: #0d755b; background: #dff9f0; }

.chat-layout { display: grid; grid-template-columns: 270px minmax(0, 1fr) 290px; gap: 18px; min-height: calc(100vh - 185px); }
.conversation-panel { min-width: 0; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-rows: auto auto minmax(260px, 1fr); }
.conversation-head { padding: 17px; border-bottom: 1px solid var(--line); }
.conversation-head h3 { margin: 3px 0 0; font-size: 16px; }
.conversation-search { position: relative; padding: 13px; border-bottom: 1px solid var(--line); }
.conversation-search label { display: block; margin-bottom: 6px; font-size: 11px; font-weight: 900; text-transform: uppercase; color: var(--muted); }
.conversation-results { position: absolute; z-index: 15; left: 13px; right: 13px; top: 76px; max-height: 280px; overflow: auto; border-radius: 11px; background: white; box-shadow: var(--shadow); }
.conversation-results:empty { display: none; }
.conversation-results button { width: 100%; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: white; text-align: left; display: grid; gap: 2px; }
.conversation-results button:hover { background: #edfdfe; }
.conversation-results span { color: var(--muted); font-size: 11px; }
.conversation-list { overflow-y: auto; padding: 8px; }
.conversation-item { width: 100%; padding: 11px; border: 0; border-radius: 11px; background: transparent; text-align: left; display: grid; gap: 4px; }
.conversation-item:hover { background: #f7f4ed; }
.conversation-item.active { color: white; background: var(--navy); }
.conversation-name { display: flex; justify-content: space-between; gap: 7px; font-weight: 900; }
.conversation-preview { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.conversation-item.active .conversation-preview, .conversation-item.active small { color: #cac6d5; }
.conversation-item small { color: var(--muted); }
.conversation-unread { min-width: 21px; height: 21px; padding: 0 6px; border-radius: 20px; color: var(--navy); background: var(--cyan); display: inline-grid; place-items: center; font-size: 11px; }
.chat-panel { background: white; border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-rows: auto minmax(360px, 1fr) auto; overflow: hidden; }
.chat-header { padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.sector-mark { width: 40px; height: 40px; border-radius: 13px; background: var(--navy); color: var(--cyan); display: grid; place-items: center; font-weight: 900; }
.chat-header h3 { margin: 0; font-size: 16px; }
.chat-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.messages { padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; background: #f8f6f0; }
.message { max-width: min(72%, 620px); padding: 11px 13px; border-radius: 5px 16px 16px 16px; background: white; box-shadow: 0 3px 12px rgba(30,28,51,.07); align-self: flex-start; }
.message.mine { align-self: flex-end; border-radius: 16px 5px 16px 16px; background: var(--navy); color: white; }
.message-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; font-size: 11px; color: var(--muted); }
.message.mine .message-meta { color: #bbb7c8; }
.message-author { font-weight: 900; color: var(--magenta); }
.message.mine .message-author { color: var(--cyan); }
.message-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; }
.message-ot { margin-top: 7px; font-size: 11px; font-weight: 900; color: var(--cyan-deep); }
.composer { padding: 15px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 190px minmax(0,1fr) auto; gap: 12px; align-items: end; }
.composer-options { display: grid; grid-template-columns: auto 1fr; gap: 5px 8px; align-items: center; }
.composer-options label { color: var(--muted); font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.composer-options select { padding: 7px 8px; font-size: 12px; }
.composer textarea { min-height: 46px; max-height: 130px; }
.chat-info { display: grid; align-content: start; gap: 16px; }
.notification-status { display: flex; align-items: flex-start; gap: 11px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.live-dot { width: 10px; height: 10px; margin-top: 4px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(26,156,120,.15); flex: 0 0 auto; }

.toast-region { position: fixed; z-index: 100; right: 22px; top: 22px; width: min(390px, calc(100vw - 32px)); display: grid; gap: 12px; pointer-events: none; }
.toast { pointer-events: auto; color: white; background: var(--navy); border: 1px solid rgba(18,227,235,.45); border-left: 6px solid var(--cyan); border-radius: 15px; padding: 16px; box-shadow: 0 18px 50px rgba(15,14,25,.28); animation: toast-in .25s ease-out; }
.toast-title { display: flex; align-items: center; gap: 8px; font-weight: 900; margin-bottom: 6px; }
.toast-title span { color: var(--cyan); }
.toast p { margin: 0; color: #d8d5e1; line-height: 1.4; }
.toast-actions { margin-top: 11px; display: flex; justify-content: flex-end; }
.toast-actions button { border: 0; background: var(--cyan); color: var(--navy); border-radius: 8px; padding: 7px 10px; font-weight: 900; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } }

.dialog-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(20,18,34,.55); display: grid; place-items: center; padding: 22px; }
.dialog { width: min(720px, 100%); max-height: calc(100vh - 44px); overflow: auto; background: var(--paper); border-radius: 20px; box-shadow: var(--shadow); padding: 25px; }
.dialog-head { display: flex; justify-content: space-between; gap: 15px; align-items: start; margin-bottom: 20px; }
.dialog-head h2 { margin: 0; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 15px; }
.detail { padding: 12px; background: white; border: 1px solid var(--line); border-radius: 11px; }
.detail.full { grid-column: 1 / -1; }
.detail-label { color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 800; letter-spacing: .05em; }
.detail-value { margin-top: 5px; font-weight: 700; white-space: pre-wrap; }

.client-search-wrap { position: relative; }
.client-suggestions { position: absolute; z-index: 12; left: 0; right: 0; top: 72px; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.client-suggestions button { width: 100%; border: 0; border-bottom: 1px solid #eeeae3; padding: 11px 13px; background: white; text-align: left; display: grid; gap: 3px; }
.client-suggestions button:hover { background: #edfdfe; }
.client-suggestions button span, .suggestion-empty { color: var(--muted); font-size: 12px; }
.suggestion-empty { padding: 14px; }

.order-module { margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.order-module h3 { margin: 0 0 5px; }
.order-module p { color: var(--muted); line-height: 1.45; }
.order-module textarea { margin: 12px 0; min-height: 95px; }
.edit-order-module { border-left: 5px solid var(--cyan-deep); }
.internal-note-module { border-left: 5px solid var(--magenta); }
.whatsapp-module { border-left: 5px solid #20b968; }
.button.whatsapp { color: white; background: #159f58; }
.note-list { display: grid; gap: 9px; margin-top: 12px; }
.note-list article { padding: 12px; border-radius: 10px; background: #f7f4ed; }
.note-list time { margin-left: 8px; color: var(--muted); font-size: 11px; }
.note-list p { margin: 6px 0 0; color: var(--ink); white-space: pre-wrap; }

.import-requirements { padding: 15px; border-radius: 12px; background: #f7f4ed; }
.import-requirements code { display: block; margin: 9px 0; padding: 10px; border-radius: 8px; color: var(--navy); background: white; overflow-wrap: anywhere; }
.import-requirements p { margin: 7px 0 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.row-actions .button { padding: 8px 10px; font-size: 12px; }
.work-types-table { min-width: 980px; }
.work-types-table input { min-width: 140px; padding: 8px 9px; }
.catalog-hint { margin: 14px 2px 0; }
.budget-items { display: grid; gap: 10px; margin: 14px 0; }
.budget-empty { padding: 18px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); background: #faf8f3; text-align: center; }
.budget-item { display: grid; grid-template-columns: minmax(0, 1fr) 170px auto; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #faf8f3; }
.budget-item .field { grid-column: auto; }
.budget-item input[readonly] { color: var(--muted); background: #f1eee7; }
.budget-remove { margin-bottom: 1px; }
.budget-total { display: flex; justify-content: flex-end; align-items: baseline; gap: 12px; padding: 8px 4px; }
.budget-total span { color: var(--muted); font-size: 12px; }
.budget-total b { font-size: 20px; }
.budget-picker { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-top: 14px; }
.budget-module { border-left: 5px solid var(--cyan-deep); }

.workflow-backdrop { align-items: start; overflow-y: auto; }
.workflow-dialog { width: min(1040px, 100%); margin: 18px auto; overflow: visible; }
.workflow-head p { margin: 6px 0 0; color: var(--muted); }
.workflow-progress { display: grid; gap: 9px; margin: 0 0 14px; padding: 18px; border-radius: 15px; color: white; background: var(--navy); }
.workflow-progress-bar { height: 9px; overflow: hidden; border-radius: 9px; background: rgba(255,255,255,.15); }
.workflow-progress-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--magenta)); transition: width .25s ease; }
.workflow-progress > div:last-child { display: flex; justify-content: space-between; gap: 14px; font-size: 13px; }
.workflow-progress span { color: #c8c5d4; }
.workflow-role-note { margin-bottom: 17px; padding: 11px 14px; border: 1px solid #bcebed; border-radius: 11px; color: #155d62; background: #eafbfc; font-size: 13px; }
.workflow-stage { margin-bottom: 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 15px; background: white; }
.workflow-stage[open] { box-shadow: 0 8px 22px rgba(30,28,51,.04); }
.workflow-stage.complete { border-left: 5px solid var(--success); }
.workflow-stage summary { min-height: 64px; padding: 13px 17px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px; list-style: none; cursor: pointer; background: #faf8f3; }
.workflow-stage summary::-webkit-details-marker { display: none; }
.workflow-stage summary > span:nth-child(2) { display: grid; gap: 3px; }
.workflow-stage summary b { font-size: 16px; }
.workflow-stage summary small { color: var(--muted); }
.stage-number { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 50%; color: var(--navy); background: var(--cyan); font-weight: 900; }
.workflow-stage.complete .stage-number { color: white; background: var(--success); }
.stage-state { padding: 5px 9px; border-radius: 20px; color: #7a4e00; background: #fff0ce; font-size: 11px; font-weight: 900; text-transform: uppercase; }
.workflow-stage.complete .stage-state { color: #0d755b; background: #dff9f0; }
.stage-body { padding: 20px; }
.checklist-table { margin-bottom: 18px; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; background: white; }
.checklist-row { min-width: 760px; display: grid; grid-template-columns: minmax(155px, 1.1fr) 82px 82px 105px minmax(210px, 1.5fr); align-items: center; border-bottom: 1px solid #ece8e0; }
.checklist-row:last-child { border-bottom: 0; }
.checklist-row > * { min-height: 55px; display: flex; align-items: center; padding: 9px 12px; border-right: 1px solid #ece8e0; }
.checklist-row > *:last-child { border-right: 0; }
.checklist-head { color: white; background: var(--navy); font-size: 11px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.checklist-head > * { min-height: 42px; border-color: rgba(255,255,255,.14); justify-content: center; }
.checklist-head > *:first-child, .checklist-head > *:last-child { justify-content: flex-start; }
.checklist-row > b { font-size: 13px; }
.matrix-option { justify-content: center; cursor: pointer; position: relative; }
.matrix-option input { position: absolute; opacity: 0; pointer-events: none; }
.matrix-option span { width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border: 2px solid #c9c4ba; border-radius: 50%; color: transparent; background: white; font-size: 15px; font-weight: 900; }
.matrix-option em { display: none; }
.matrix-option:hover span { border-color: var(--cyan-deep); }
.matrix-option:has(input:checked) span { border-color: var(--cyan-deep); color: var(--navy); background: var(--cyan); box-shadow: 0 0 0 3px rgba(18,227,235,.16); }
.matrix-option:has(input[value="no_anda"]:checked) span { border-color: var(--magenta); color: white; background: var(--magenta); box-shadow: 0 0 0 3px rgba(209,21,121,.14); }
.matrix-option:has(input[value="no_revisado"]:checked) span { border-color: #aaa4b0; color: white; background: #aaa4b0; box-shadow: none; }
.matrix-option:has(input:disabled) { cursor: not-allowed; }
.check-observation { width: calc(100% - 18px); min-height: 37px; margin: 9px; padding: 8px 10px; }
.workflow-inline { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.photo-pending { color: var(--muted); font-size: 12px; }
.stage-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 9px; margin-top: 17px; }
.transfer-card { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.transfer-card p { margin: 10px 0 0; color: var(--muted); }
.parts-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 17px; }
.parts-head h4 { margin: 0; }
.parts-list { display: grid; gap: 9px; margin-top: 10px; }
.parts-empty { padding: 15px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; }
.part-row { display: grid; grid-template-columns: minmax(180px, 1fr) 110px 140px auto; gap: 8px; }
.delivery-confirm { padding: 13px; border-radius: 11px; background: #eefcfc; }
.workflow-history { margin: 20px 0; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: #faf8f3; }
.timeline { display: grid; gap: 0; }
.timeline article { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 10px; min-height: 72px; }
.timeline article > span { width: 11px; height: 11px; margin-top: 4px; border-radius: 50%; background: var(--magenta); box-shadow: 0 0 0 4px #f7dce9; }
.timeline article:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 18px; bottom: 0; width: 1px; background: #d8cbd2; }
.timeline p { margin: 4px 0; color: var(--muted); }
.timeline small { color: var(--muted); }
.workflow-feedback { position: sticky; bottom: 0; z-index: 2; }
select:disabled, input:disabled, textarea:disabled { color: #5c5866; background: #f1eee7; opacity: 1; cursor: not-allowed; }
.settings-card > .hint { display: block; margin: -8px 0 18px; }
.settings-title { display: flex; align-items: start; justify-content: space-between; gap: 15px; }
.settings-title .card-title { margin-bottom: 5px; }
.settings-table { min-width: 680px; }
.settings-table td:not(:first-child), .settings-table th:not(:first-child) { width: 120px; text-align: center; }
.settings-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.settings-toggle input { width: 18px; height: 18px; }
.settings-toggle span { min-width: 20px; font-size: 12px; font-weight: 800; }
.settings-list { display: grid; gap: 10px; margin-top: 18px; }
.settings-empty { padding: 22px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.custom-field-row { display: grid; grid-template-columns: minmax(150px, 1fr) 140px minmax(180px, 1fr) repeat(4, auto) auto; align-items: center; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: #faf8f3; }
.custom-field-row label { display: flex; align-items: center; gap: 5px; white-space: nowrap; font-size: 12px; font-weight: 700; }
.custom-field-row label input { width: auto; }
.settings-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.checklist-editor { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: #faf8f3; }
.checklist-editor h4 { margin: 8px 0; }
.checklist-settings-list { display: grid; gap: 8px; margin-top: 13px; }
.checklist-setting-row { display: grid; grid-template-columns: auto minmax(110px, 1fr) auto auto auto; gap: 7px; align-items: center; }
.drag-mark { color: var(--muted); font-weight: 900; }
.checklist-setting-row .icon-button { width: 34px; height: 34px; }
.checklist-setting-row .button { padding: 8px; }
.template-variables { color: var(--muted); line-height: 2; }
.template-variables code { padding: 4px 6px; border-radius: 6px; color: var(--navy); background: #e9fdfe; white-space: nowrap; }
.template-editor { min-height: 270px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; line-height: 1.5; }
.settings-save { position: sticky; z-index: 5; bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 20px; padding: 15px 18px; border: 1px solid rgba(18,227,235,.55); border-radius: 14px; color: white; background: rgba(30,28,51,.96); box-shadow: var(--shadow); }
.settings-save span { color: #d0cdda; font-size: 12px; }

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { min-height: 300px; }
  .login-panel { border-radius: 30px 30px 0 0; }
  .app-shell { grid-template-columns: 82px minmax(0, 1fr); }
  .sidebar { padding: 22px 12px; }
  .sidebar-logo { width: 54px; margin: 0 auto 32px; object-fit: cover; object-position: left; }
  .nav-button { justify-content: center; padding: 13px 8px; }
  .nav-label, .user-card > div:nth-child(2), .logout { display: none; }
  .user-card { grid-template-columns: 1fr; justify-items: center; }
  .badge { position: absolute; transform: translate(18px, -14px); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .chat-layout { grid-template-columns: 1fr; }
  .conversation-panel { max-height: 520px; }
  .chat-info { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1150px) {
  .settings-columns { grid-template-columns: 1fr; }
  .custom-field-row { grid-template-columns: minmax(160px, 1fr) 140px minmax(180px, 1fr); }
  .custom-field-row label, .custom-field-row .button { justify-self: start; }
}

@media (max-width: 620px) {
  .app-shell { display: block; padding-bottom: 72px; }
  .sidebar { position: fixed; z-index: 30; inset: auto 0 0; width: 100%; height: auto; padding: 8px 10px; }
  .sidebar-logo, .sidebar-bottom { display: none; }
  .nav { display: flex; justify-content: space-around; overflow-x: auto; }
  .nav-button { min-width: 62px; width: auto; display: grid; gap: 2px; justify-items: center; font-size: 10px; }
  .nav-label { display: block; }
  .topbar { min-height: 68px; }
  .topbar p { display: none; }
  .content { padding-top: 22px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 16px; }
  .field, .field.span-6, .field.span-8 { grid-column: 1 / -1; }
  .order-search { grid-template-columns: 1fr 1fr; }
  .order-search .field { grid-column: 1 / -1; }
  .pattern-wrap { grid-template-columns: 1fr; }
  .composer { grid-template-columns: 1fr auto; }
  .composer-options { grid-column: 1 / -1; }
  .chat-info { grid-template-columns: 1fr; }
  .message { max-width: 88%; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail.full { grid-column: auto; }
  .budget-item { grid-template-columns: 1fr; }
  .budget-picker { grid-template-columns: 1fr; }
  .budget-remove { justify-self: start; }
  .workflow-dialog { margin: 0; border-radius: 0; }
  .workflow-backdrop { padding: 0; }
  .checklist-table { margin-left: -8px; margin-right: -8px; }
  .part-row { grid-template-columns: 1fr 1fr; }
  .part-row [data-part-name] { grid-column: 1 / -1; }
  .transfer-card { align-items: flex-start; flex-direction: column; }
  .workflow-progress > div:last-child { align-items: flex-start; flex-direction: column; }
  .settings-columns { grid-template-columns: 1fr; }
  .custom-field-row { grid-template-columns: 1fr 1fr; }
  .custom-field-row > :first-child, .custom-field-row > :nth-child(3) { grid-column: 1 / -1; }
  .settings-save { align-items: stretch; flex-direction: column; }
}
