/* Layout: carril fijo + lista densa + detalle. Marca: colores de softextarraco.com (marino, azul claro, azul vivo).
   Los estados siguen siendo señales de seguridad ISO 7010: su color indica significado, no marca. */
:root {
  --ground: #EAEEF2;
  --panel: #FFFFFF;
  --panel-2: #F3F6F9;
  --line: #D2DAE2;
  --ink: #1A1F25;
  --ink-2: #4F5965;
  --ink-3: #6E7883;
  --rail: #283645;
  --rail-2: #35475A;
  --rail-ink: #EEF3F8;
  --rail-ink-2: #AFC1D3;
  --rail-line: #4A5E73;
  --brand: #283645;      /* marino de la web: barra superior y botón activo */
  --brand-hover: #1D2836;
  --brand-sky: #8FBEE8;  /* azul claro de la web: menú y logo */
  --brand-blue: #1490D7; /* azul vivo de la web: enlaces y acentos */
  --sig-red: #B11F2D;
  --sig-yellow: #F2B200;
  --sig-blue: #1B58A3;
  --sig-green: #1D7649;
  --sig-grey: #78818B;
  --sig-black: #15181B;
  --red-wash: #FBEDEE;
  --yellow-wash: #FFF6D9;
  --blue-wash: #EAF1FA;
  --green-wash: #E7F3EC;
  --focus: #1490D7;
  --font-ui: "Barlow", "Segoe UI", system-ui, sans-serif;
  --font-sign: "Barlow Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  --font-code: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 6px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #14181C; --panel: #1C2126; --panel-2: #222830; --line: #313942;
    --ink: #E5E8EB; --ink-2: #A9B2BC; --ink-3: #8A949F;
    --rail: #17202A; --rail-2: #243241; --rail-ink: #E5ECF3; --rail-ink-2: #93A7BB; --rail-line: #33475B; --brand: #8FBEE8; --brand-hover: #B3D4F1;
    --sig-red: #E04556; --sig-blue: #4C8BDB; --sig-green: #3BA571; --sig-grey: #8A939C;
    --red-wash: #3A1D22; --yellow-wash: #3A3018; --blue-wash: #1A2A3F; --green-wash: #183024;
    --focus: #8FBEE8; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #14181C; --panel: #1C2126; --panel-2: #222830; --line: #313942;
  --ink: #E5E8EB; --ink-2: #A9B2BC; --ink-3: #8A949F;
  --rail: #17202A; --rail-2: #243241; --rail-ink: #E5ECF3; --rail-ink-2: #93A7BB; --rail-line: #33475B; --brand: #8FBEE8; --brand-hover: #B3D4F1;
  --sig-red: #E04556; --sig-blue: #4C8BDB; --sig-green: #3BA571; --sig-grey: #8A939C;
  --red-wash: #3A1D22; --yellow-wash: #3A3018; --blue-wash: #1A2A3F; --green-wash: #183024;
  --focus: #8FBEE8; color-scheme: dark;
}

html, body { height: 100%; }
body { background: var(--ground); color: var(--ink); font-family: var(--font-ui); font-size: 15px; line-height: 1.45; }
::selection { background: var(--brand-sky); color: #172230; }
* { box-sizing: border-box; scrollbar-color: var(--line) transparent; scrollbar-width: thin; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); height: 100%; }

/* Carril */
.rail { background: var(--rail); color: var(--rail-ink); display: flex; flex-direction: column; gap: 22px;
  padding-block: 20px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: 16px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.brand b { font-family: var(--font-sign); font-weight: 700; font-size: 21px; letter-spacing: .02em; line-height: 1; display: block; }
.brand span { font-size: 12px; color: var(--rail-ink-2); letter-spacing: .04em; }
.rail h2 { font-family: var(--font-sign); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--rail-ink-2); margin: 0 0 8px; }
.roles { display: grid; gap: 4px; }
.role { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; border-radius: var(--r); padding: 7px 9px; cursor: pointer; color: var(--rail-ink-2); }
.role:hover { background: var(--rail-2); color: var(--rail-ink); }
.role[aria-checked="true"] { background: var(--rail-2); color: var(--rail-ink); border-color: var(--rail-line); }
.role small { display: block; font-size: 12px; color: var(--rail-ink-2); line-height: 1.2; }
.role-dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--rail-ink-2); flex: none; }
.role[aria-checked="true"] .role-dot { background: var(--brand-sky); border-color: var(--brand-sky); }
.nav { display: grid; gap: 2px; }
.nav button { display: flex; justify-content: space-between; align-items: center; width: 100%; background: none; border: 0; border-radius: var(--r); padding: 8px 9px; color: var(--rail-ink-2); cursor: pointer; font-weight: 500; text-align: left; }
.nav button:hover { color: var(--rail-ink); background: var(--rail-2); }
.nav button[aria-current="page"] { color: var(--rail-ink); background: var(--rail-2); box-shadow: inset 3px 0 0 var(--brand-sky); }
.nav .count { font-size: 12px; color: var(--rail-ink-2); }
.menu-btn { display: none; }
.rail-menu { display: contents; }
.me { margin-top: auto; border-top: 1px solid var(--rail-2); padding-top: 14px; font-size: 13px; }
.me b { display: block; font-weight: 600; }
.me > span { display: block; color: var(--rail-ink-2); }
.demo-note { font-size: 12px; color: var(--rail-ink-2); line-height: 1.4; }
.demo-note b { color: var(--brand-sky); font-weight: 600; }

/* Principal */
.main { display: flex; flex-direction: column; min-width: 0; height: 100%; overflow: hidden; }
.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-block: 16px 12px; padding-left: 24px; padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.top h1 { font-family: var(--font-sign); font-weight: 700; font-size: 30px; letter-spacing: .005em; line-height: 1; margin: 0; text-wrap: balance; }
.top .sub { color: var(--ink-3); font-size: 13px; }
.top-titles { display: grid; gap: 4px; margin-right: auto; min-width: 0; }
.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.search input { width: 240px; max-width: 100%; height: 36px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 0 10px 0 32px; }
.search input::placeholder { color: var(--ink-3); }
.btn { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; white-space: nowrap; transition: background-color .15s ease, border-color .15s ease, transform .1s ease; }
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
:root[data-theme="dark"] .btn-primary { color: #172230; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #172230; } }
.btn-danger { color: var(--sig-red); }
.btn-danger-solid { background: var(--sig-red); border-color: var(--sig-red); color: #fff; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Tira de señales */
.signs { display: flex; gap: 8px; flex-wrap: wrap; padding-left: 24px; padding-right: max(24px, env(safe-area-inset-right, 0px)); padding-bottom: 14px; }
.sign-filter { display: inline-flex; align-items: center; gap: 9px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 6px 12px 6px 8px; cursor: pointer; transition: border-color .15s ease, background-color .15s ease; }
.sign-filter:hover { border-color: var(--ink-3); }
.sign-filter[aria-pressed="true"] { border-color: var(--ink); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--ink); }
.sign-filter b { font-family: var(--font-sign); font-size: 22px; font-weight: 700; line-height: 1; }
.sign-filter span { font-size: 13px; color: var(--ink-2); line-height: 1.15; }
.client-filter { height: 38px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 0 8px; max-width: 100%; }

/* Área de trabajo */
.work { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 410px) minmax(0, 1fr); border-top: 1px solid var(--line); }
.list { overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel); }
.row { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; width: 100%; text-align: left; padding: 12px 16px 12px 16px; background: none; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; transition: background-color .12s ease; }
.row:hover { background: var(--panel-2); }
.row[aria-selected="true"] { background: var(--blue-wash); }
.row-sign { padding-top: 2px; }
.row-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.row-id { font-size: 12px; color: var(--ink-3); font-weight: 600; flex: none; }
.row-time { margin-left: auto; font-size: 12px; color: var(--ink-3); flex: none; }
.row-title { display: flex; align-items: center; gap: 6px; font-weight: 600; line-height: 1.3; margin-top: 2px; }
.row-title span { min-width: 0; overflow-wrap: anywhere; }
.row-meta { font-size: 13px; color: var(--ink-2); margin-top: 3px; overflow-wrap: anywhere; }
.row-state { font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.st-nuevo, .st-curso { color: var(--sig-blue); }
.st-esperando { color: var(--ink); background: var(--yellow-wash); padding: 0 4px; border-radius: 3px; }
.st-resuelto { color: var(--sig-green); }
.st-cerrado { color: var(--sig-grey); }
.empty { padding: 40px 24px; color: var(--ink-2); display: grid; gap: 10px; justify-items: start; }
.empty h3 { font-family: var(--font-sign); font-size: 20px; margin: 0; color: var(--ink); }

.detail { overflow-y: auto; min-width: 0; }
.detail-inner { max-width: 860px; padding-block: 22px 40px; padding-left: 28px; padding-right: max(28px, env(safe-area-inset-right, 0px)); display: grid; gap: 22px; }
.back { display: none; }
.hazard { display: flex; align-items: center; gap: 12px; border-radius: var(--r); overflow: hidden; background: repeating-linear-gradient(-45deg, var(--sig-yellow) 0 14px, var(--sig-black) 14px 28px); padding: 7px; }
.hazard span { background: var(--sig-black); color: #fff; font-family: var(--font-sign); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 14px; padding: 4px 10px; border-radius: 3px; }
.d-head { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; align-items: start; }
.d-state { font-family: var(--font-sign); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: 13px; }
.d-title { font-family: var(--font-sign); font-weight: 700; font-size: 30px; line-height: 1.08; margin: 2px 0 6px; text-wrap: balance; overflow-wrap: anywhere; }
.d-meta { color: var(--ink-2); font-size: 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin: 0; }
.facts div { background: var(--panel); padding: 9px 12px; min-width: 0; box-shadow: inset -1px -1px 0 var(--line); }
.facts dt { font-family: var(--font-sign); font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
code, .code { font-family: var(--font-code); font-size: 13.5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px; }
.known { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; background: var(--yellow-wash); border: 1px solid var(--sig-yellow); border-radius: var(--r); padding: 12px 14px; }
.known b { display: block; }
.known p { margin: 3px 0 0; color: var(--ink-2); font-size: 14px; }
.desc { margin: 0; max-width: 68ch; white-space: pre-wrap; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.actions label { font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.actions select { height: 30px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); padding: 0 6px; }
.actions .spacer { flex: 1; }
.confirm { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--red-wash); border: 1px solid var(--sig-red); border-radius: var(--r); padding: 10px 12px; }
.confirm p { margin: 0 auto 0 0; }

.section-h { font-family: var(--font-sign); font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 10px; }
.thread { display: grid; gap: 12px; }
.msg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; max-width: 72ch; }
.msg.mine { margin-left: auto; background: var(--panel-2); }
.msg-h { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 13px; color: var(--ink-3); margin-bottom: 4px; }
.msg-h b { color: var(--ink); font-weight: 600; }
.msg p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.internal { background: transparent; border-style: dashed; border-color: var(--ink-3); }
.msg.ask { background: var(--yellow-wash); border-color: var(--sig-yellow); }
.tag { font-family: var(--font-sign); font-weight: 700; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 1px 6px; border-radius: 3px; }
.tag-int { background: var(--rail); color: #fff; }
.tag-ask { background: var(--sig-yellow); color: var(--sig-black); }
.event { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); padding-left: 2px; }
.event time { color: var(--ink-3); }

.composer { display: grid; gap: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: none; padding: 6px 12px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.seg button[data-mode="ask"][aria-pressed="true"] { background: var(--sig-yellow); color: var(--sig-black); }
textarea, .field input, .field select { width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 8px 10px; }
textarea { min-height: 84px; resize: vertical; }
textarea::placeholder, .field input::placeholder { color: var(--ink-3); }
.composer-foot { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.composer-foot .hint { font-size: 13px; color: var(--ink-3); margin-right: auto; }

/* Formulario */
.form { display: grid; gap: 16px; }
.form h2 { font-family: var(--font-sign); font-size: 30px; font-weight: 700; margin: 0; line-height: 1.05; }
.form .lead { margin: 4px 0 0; color: var(--ink-2); max-width: 64ch; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.field { display: grid; gap: 5px; min-width: 0; align-content: start; }
.field > span { font-weight: 600; font-size: 14px; }
.field small { color: var(--ink-3); font-size: 12.5px; }
.field input, .field select { height: 38px; }
.field.err input, .field.err textarea { border-color: var(--sig-red); }
.field .errmsg { color: var(--sig-red); font-size: 13px; font-weight: 500; }
.field label .opt { font-weight: 400; color: var(--ink-3); margin-left: 6px; font-size: 13px; }
.field-tel { max-width: 320px; }
.d-meta .tel { display: inline-flex; align-items: center; gap: 4px; color: var(--ink); font-weight: 600; text-decoration: none; white-space: nowrap; }
.d-meta .tel:hover { text-decoration: underline; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; min-width: 0; }
legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.impact { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.impact label { display: grid; grid-template-columns: auto 22px minmax(0, 1fr); gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: var(--r); padding: 10px; cursor: pointer; background: var(--panel); }
.impact label:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.impact input { accent-color: var(--brand); margin: 0; }
.impact b { display: block; font-size: 14px; }
.impact small { color: var(--ink-3); font-size: 12.5px; }
.files { font-size: 13px; }
.form-foot { display: flex; gap: 10px; flex-wrap: wrap; }

/* Tablas */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 14px; }
th { text-align: left; font-family: var(--font-sign); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--panel-2); }
.inline { display: inline-flex; align-items: center; gap: 6px; }
.countdown { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.countdown > b { font-family: var(--font-sign); font-size: 34px; line-height: 1; }
.countdown p { margin: 0; color: var(--ink-2); max-width: 60ch; }
.kb { display: grid; gap: 10px; }
.kb-item { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kb-item h3 { margin: 0; font-size: 16px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.kb-item p { margin: 0; color: var(--ink-2); max-width: 75ch; }
.kb-item .area { font-size: 12px; color: var(--ink-3); }

.toast { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); background: var(--rail); color: #fff; padding: 10px 14px; border-radius: var(--r); box-shadow: 0 6px 20px rgba(0,0,0,.25); display: flex; gap: 8px; align-items: center; opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s cubic-bezier(.2,.8,.2,1); pointer-events: none; z-index: 20; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1060px) {
  .work { grid-template-columns: minmax(0, 1fr); }
  .work.has-detail .list { display: none; }
  .work:not(.has-detail) .detail { display: none; }
  .list { border-right: 0; }
  .back { display: inline-flex; justify-self: start; }
}
@media (max-width: 760px) {
  html, body { height: auto; }
  .app { grid-template-columns: minmax(0, 1fr); height: auto; }
  .rail { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); gap: 14px; display: grid; grid-template-columns: minmax(0, 1fr); }
  .roles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .role { flex-direction: column; align-items: flex-start; gap: 4px; padding: 7px; }
  .role small { display: none; }
  .nav { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
  .nav button { justify-content: center; gap: 6px; padding: 8px 4px; }
  .nav button[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--brand-sky); }
  .me { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 0; padding-top: 10px; }
  .me b { display: inline; }
  .me .theme-seg { margin: 0; flex: none; }
  .me .logout { margin-top: 0; }
  .main { height: auto; overflow: visible; }
  .top, .signs { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .search { flex: 1 1 100%; order: 3; }
  .search input { width: 100%; }
  .list, .detail { overflow: visible; }
  .detail-inner { padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .d-title { font-size: 25px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Añadidos de la app ---------- */
body { margin: 0; }
.boot { display: grid; place-items: center; height: 100%; color: var(--ink-3); }

.login-wrap { min-height: 100%; display: grid; place-items: center; gap: 18px; align-content: center;
  padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.login { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: grid; gap: 16px; box-shadow: 0 10px 30px rgba(20, 24, 28, .08); }
.login .brand b { color: var(--ink); }
.login .brand span { color: var(--ink-3); }
.login h1 { font-family: var(--font-sign); font-size: 28px; margin: 0; line-height: 1.05; }
.login p { margin: 0; color: var(--ink-2); }
.login .btn { justify-content: center; height: 40px; }
.form-error { color: var(--sig-red); font-weight: 500; font-size: 14px; margin: 0; }
.demo-accounts { width: 100%; max-width: 380px; display: grid; gap: 6px; font-size: 13px; color: var(--ink-2); }
.demo-accounts b { color: var(--ink); font-family: var(--font-sign); letter-spacing: .08em; text-transform: uppercase; font-size: 12px; }
.demo-accounts button { display: flex; justify-content: space-between; gap: 10px; width: 100%; text-align: left; background: var(--panel); border: 1px dashed var(--line); border-radius: var(--r); padding: 7px 10px; cursor: pointer; }
.demo-accounts button:hover { border-color: var(--ink-3); }
.demo-accounts span { color: var(--ink-3); }

.logout { margin-top: 10px; background: none; border: 1px solid var(--rail-line); color: var(--rail-ink-2); border-radius: var(--r); padding: 5px 10px; cursor: pointer; font-size: 13px; }
.logout:hover { color: var(--rail-ink); border-color: var(--rail-ink-2); }
.tag-sin { background: var(--panel-2); color: var(--ink-2); border: 1px dashed var(--ink-3); }
.skel { height: 64px; border-bottom: 1px solid var(--line); background: linear-gradient(90deg, var(--panel) 0%, var(--panel-2) 50%, var(--panel) 100%); background-size: 200% 100%; animation: skel 1.2s ease-in-out infinite; }
@keyframes skel { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.new-simple textarea { min-height: 180px; }
#root { height: 100%; }
@media (max-width: 760px) { #root { height: auto; } }
.demo-note code { background: var(--rail-2); color: var(--rail-ink); border-color: var(--rail-line); }

/* Usuarios */
.user-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; }
.user-form h2 { font-size: 24px; }
.user-form .hint { margin: 0; color: var(--ink-3); font-size: 13px; }
.user-form .hint:empty { display: none; }
.user-form .spacer { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
[hidden] { display: none !important; }
tr.off td { color: var(--ink-3); }
.muted { color: var(--ink-3); font-weight: 400; }

/* Tiempo trabajado */
.time-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: grid; gap: 10px; }
.time-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.time-head .section-h { margin: 0; }
.time-head b { font-family: var(--font-sign); font-size: 22px; line-height: 1; }
.time-list { list-style: none; margin: 0; padding: 0; display: grid; }
.time-list li { display: grid; grid-template-columns: 92px 92px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.time-list li > span:first-child { color: var(--ink-3); }
.time-form { display: grid; grid-template-columns: 170px 150px minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.time-form .btn { height: 38px; }
@media (max-width: 700px) { .time-form { grid-template-columns: 1fr 1fr; } .time-form .t-nota { grid-column: 1 / -1; } .time-list li { grid-template-columns: 84px 1fr auto; } .time-list li > span:nth-child(3) { grid-column: 1 / -1; grid-row: 2; color: var(--ink-2); } }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-3); }
.btn-ghost:hover { color: var(--sig-red); border-color: transparent; }
.countdown p b { white-space: nowrap; }
/* Informe de horas */
.range-bar { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; padding: 0 24px 14px; border-bottom: 1px solid var(--line); }
.range-bar .field { width: 160px; }
.range-bar label { white-space: nowrap; }
.range-quick { display: flex; gap: 6px; }
.range-quick .btn { height: 38px; }
.range-quick .btn[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
@media (max-width: 700px) { .range-bar { padding-inline: 16px; } .range-bar .field { width: calc(50% - 6px); } }
.tarifa-box { display: flex; align-items: end; gap: 18px; margin-left: auto; flex-wrap: wrap; }
.tarifa-box .field { width: 150px; }
.tarifa-box > div:not(.field) { display: grid; gap: 2px; min-height: 38px; align-content: end; }
.tarifa-box .k { font-family: var(--font-sign); font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.tarifa-box b { font-size: 16px; }
.tarifa-box small { color: var(--ink-3); font-size: 12px; }
.tarifa-box .cambio { font-size: 14px; color: var(--ink-2); }
.linkbtn { border: 0; background: none; padding: 0; color: var(--ink); text-decoration: underline; cursor: pointer; font: inherit; }
.nowrap { white-space: nowrap; }
@media (max-width: 700px) { .tarifa-box { margin-left: 0; } }
.tarifa-box > a.cambio-link { display: grid; gap: 2px; min-height: 38px; align-content: end; color: inherit; text-decoration: none; border-radius: 4px; }
.cambio-link .k { display: inline-flex; align-items: center; gap: 4px; }
.cambio-link:hover .cambio, .cambio-link:focus-visible .cambio { text-decoration: underline; color: var(--ink); }
.cambio-link:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

/* Adjuntos: selector, pendientes y archivos guardados como fichas compactas */
.attach { display: grid; gap: 8px; }
.attach-btn { justify-self: start; position: relative; }
.attach-btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.attach-hint { font-size: 13px; color: var(--ink-3); }
.chips { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.attach .chips { margin: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 30px; padding: 0 4px 0 9px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel-2); font-size: 13px; color: var(--ink-2); }
.chip-open { display: inline-flex; align-items: center; gap: 6px; min-width: 0; border: 0; background: none; padding: 0; color: var(--ink); cursor: pointer; font: inherit; }
.chip-open:hover .chip-name { text-decoration: underline; }
.chip-name { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34ch; }
.chip-size { color: var(--ink-3); }
.chip-x { width: 24px; height: 24px; border: 0; border-radius: 4px; background: none; color: var(--ink-3); cursor: pointer; font-size: 17px; line-height: 1; }
.chip-x:hover { background: var(--red-wash); color: var(--sig-red); }
.msg .chips { margin-top: 10px; }
.d-meta .wa { color: var(--sig-green); }

/* Selector de apariencia en el carril: Automático / Claro / Oscuro, solo iconos, en la fila de "Cerrar sesión" */
.theme-seg { display: inline-flex; vertical-align: middle; margin: 10px 8px 0 0; border: 1px solid var(--rail-line); border-radius: var(--r); overflow: hidden; }
.theme-seg button { display: grid; place-items: center; width: 32px; height: 28px; padding: 0; border: 0; background: none; color: var(--rail-ink-2); cursor: pointer; }
.theme-seg button + button { border-left: 1px solid var(--rail-line); }
.theme-seg button:hover { color: var(--rail-ink); background: var(--rail-2); }
.theme-seg button[aria-pressed="true"] { background: var(--rail-2); color: var(--brand-sky); box-shadow: inset 0 -2px 0 var(--brand-sky); }
.me .logout { height: 30px; vertical-align: middle; }

/* ---------- Móvil ---------- */
/* Al abrir un ticket o el formulario, la cabecera y los filtros de la lista sobran: se ve solo el detalle */
@media (max-width: 1060px) {
  #main:has(.work.has-detail) > .top,
  #main:has(.work.has-detail) > .signs { display: none; }
  #main:has(.work.has-detail) .detail-inner { padding-top: 14px; }
}
@media (max-width: 760px) {
  /* Carril = barra fija con la marca y el botón ☰; el menú se despliega debajo, sobre el contenido */
  .rail { position: sticky; top: 0; z-index: 30; display: flex; flex-direction: row; align-items: center; justify-content: space-between;
    gap: 12px; padding-block: 8px; padding-top: max(8px, env(safe-area-inset-top, 0px)); overflow: visible; }
  .brand-mark { width: 26px; height: 26px; }
  .brand b { font-size: 18px; }
  .brand span { font-size: 11px; }
  .menu-btn { display: grid; place-items: center; width: 44px; height: 44px; margin-right: -8px; border: 0; border-radius: var(--r); background: none; color: var(--rail-ink); cursor: pointer; }
  .menu-btn:hover, .rail.open .menu-btn { background: var(--rail-2); }
  .menu-btn path { stroke: currentColor; stroke-width: 2; stroke-linecap: round; transform-origin: 11px 11px; transition: transform .2s ease, opacity .15s ease; }
  .rail.open .menu-btn .l1 { transform: translateY(5px) rotate(45deg); }
  .rail.open .menu-btn .l2 { opacity: 0; }
  .rail.open .menu-btn .l3 { transform: translateY(-5px) rotate(-45deg); }

  .rail-menu { display: none; position: absolute; top: 100%; left: 0; right: 0; max-height: calc(100dvh - 100%); overflow-y: auto;
    background: var(--rail); border-top: 1px solid var(--rail-line); box-shadow: 0 18px 32px -12px rgb(0 0 0 / .45);
    padding: 8px max(16px, env(safe-area-inset-right, 0px)) 16px max(16px, env(safe-area-inset-left, 0px)); }
  /* La sombra enorme oscurece la página bajo el menú; el recorte evita que tape la barra */
  .rail.open .rail-menu { display: grid; gap: 14px; animation: menu-in .18s ease-out;
    box-shadow: 0 0 0 100vmax rgb(10 16 24 / .45); clip-path: inset(0 0 -100vmax 0); }
  @keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } }
  .rail h2, .demo-note { display: none; }
  .nav { display: grid; grid-auto-flow: row; gap: 2px; }
  .nav button { justify-content: space-between; min-height: 48px; padding: 0 12px; font-size: 16px; }
  .nav button[aria-current="page"] { box-shadow: inset 3px 0 0 var(--brand-sky); }
  .nav .count { font-size: 13px; }
  .me { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; border-top: 1px solid var(--rail-2); margin: 0; padding-top: 14px; }
  .me > b, .me > span { display: block; flex: 1 0 100%; }
  .me > span { margin-top: -10px; }
  .me .theme-seg { flex: none; margin: 0; }
  .theme-seg button { width: 44px; height: 40px; }
  .me .logout { height: 40px; margin: 0 0 0 auto; padding: 0 14px; white-space: nowrap; }

  /* Filtros de estado en una sola fila deslizable */
  .signs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 12px; }
  .signs::-webkit-scrollbar { display: none; }
  .signs > * { flex: none; }
  .top { padding-block: 14px 10px; }

  /* Tablas como fichas: cada fila es una tarjeta con la etiqueta de cada dato */
  .table-wrap { overflow: visible; background: none; border: 0; border-radius: 0; }
  .table-wrap table { min-width: 0; }
  .table-wrap thead { display: none; }
  .table-wrap tbody { display: grid; gap: 8px; }
  .table-wrap tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
  .table-wrap td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
  .table-wrap td:first-child { grid-column: 1 / -1; font-size: 16px; }
  .table-wrap td[data-label]:not(:first-child)::before { content: attr(data-label); display: block; margin-bottom: 1px; font-family: var(--font-sign); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
  .table-wrap td.ancho { grid-column: 1 / -1; }

  /* Composer: los tres tipos de mensaje ocupan el ancho por igual */
  .seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); width: 100%; }
  .seg button { padding: 8px 6px; line-height: 1.2; }

  /* iOS amplía la página al enfocar un campo con letra menor de 16 px */
  input, select, textarea { font-size: 16px; }
}
/* Pantallas táctiles: botones pequeños más fáciles de acertar; la pista de Ctrl+V no aplica */
@media (pointer: coarse) {
  .chip-x { width: 34px; height: 34px; }
  .chip { min-height: 38px; }
  .solo-teclado { display: none; }
}
