:root {
  color-scheme: light dark;
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --surface-strong: #fbfcfd;
  --surface-raised: #ffffff;
  --field: #ffffff;
  --line: #d7dee6;
  --text: #17212b;
  --muted: #617080;
  --blue: #006cae;
  --blue-dark: #034f83;
  --corp: #37308f;
  --corp-soft: #eeedf8;
  --corp-shadow: rgba(55, 48, 143, 0.18);
  --green: #1f8a58;
  --orange: #f58220;
  --yellow: #ffd84d;
  --yellow-text: #4c3b00;
  --red: #d71920;
  --purple: #5544b8;
  --ink: #253546;
  --shadow: 0 18px 42px rgba(28, 45, 61, 0.13);
  --nav-bg: #edf2f6;
  --chip-bg: #eef2f5;
  --reply-bg: #f6f8fa;
  --modal-backdrop: rgba(13, 26, 38, 0.38);
  --badge-default-bg: #eef2f5;
  --badge-default-text: #405263;
  --badge-red-bg: #fee8ea;
  --priority-red-bg: #d71920;
  --badge-orange-bg: #fff0db;
  --priority-orange-bg: #f58220;
  --badge-yellow-bg: #fff6cf;
  --priority-yellow-bg: #ffd84d;
  --badge-blue-bg: #e1f0fa;
  --badge-green-bg: #e5f4ec;
  --priority-green-bg: #2fa66a;
  --badge-purple-bg: #eeeaff;
  --purchase-scale: 1;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101820;
    --surface: #17222c;
    --surface-soft: #1d2a35;
    --surface-strong: #131d26;
    --surface-raised: #1f2e3a;
    --field: #111b24;
    --line: #314251;
    --text: #edf3f8;
    --muted: #a9b6c2;
    --blue: #2f9fe0;
    --blue-dark: #67b7ea;
    --corp: #8d86ff;
    --corp-soft: #28264a;
    --corp-shadow: rgba(141, 134, 255, 0.24);
    --green: #62c58d;
    --orange: #ff9f3f;
    --yellow: #ffe066;
    --yellow-text: #302500;
    --red: #ff5a61;
    --purple: #aa9cff;
    --ink: #e4edf5;
    --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
    --nav-bg: #1b2833;
    --chip-bg: #263543;
    --reply-bg: #20303c;
    --modal-backdrop: rgba(0, 0, 0, 0.62);
    --badge-default-bg: #283746;
    --badge-default-text: #d6e0e8;
    --badge-red-bg: #4a232b;
    --priority-red-bg: #c92831;
    --badge-orange-bg: #49331d;
    --priority-orange-bg: #d96f18;
    --badge-yellow-bg: #4a3d17;
    --priority-yellow-bg: #d6b33a;
    --badge-blue-bg: #20384a;
    --badge-green-bg: #1d3d2e;
    --priority-green-bg: #2e875b;
    --badge-purple-bg: #302852;
  }
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 1180px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 28% 20%, color-mix(in srgb, var(--corp) 14%, transparent), transparent 28%),
    linear-gradient(135deg, var(--surface-strong), var(--bg));
}

.login-card {
  width: min(380px, calc(100vw - 34px));
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-logo {
  width: 58px;
  height: auto;
  object-fit: contain;
}

.login-card h1 {
  margin-bottom: 4px;
  font-weight: 600;
}

.login-card label {
  gap: 6px;
  font-weight: 520;
}

.login-card input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--text);
}

.login-error {
  margin: 0;
  padding: 9px 10px;
  border-radius: 7px;
  background: var(--badge-red-bg);
  color: var(--red);
  font-weight: 560;
}

.login-debug {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.topbar {
  height: 56px;
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto minmax(190px, 1fr);
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand, .user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
}

.user-chip {
  justify-self: end;
}

.logout-btn {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-raised);
  color: var(--muted);
  padding: 0 9px;
  font-weight: 560;
  cursor: pointer;
}

.logout-btn:hover {
  border-color: color-mix(in srgb, var(--corp) 45%, var(--line));
  color: var(--corp);
  background: var(--corp-soft);
}

.brand-logo {
  width: auto;
  height: 32px;
  max-width: 70px;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
}

.brand-title { font-size: 16px; font-weight: 600; }

.brand-subtitle,
.user-chip small,
.eyebrow,
.detail-meta,
.ticket-card small {
  color: var(--muted);
  font-size: 11px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  background: var(--nav-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.nav-item {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 7px 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.nav-item:hover {
  background: color-mix(in srgb, var(--corp) 18%, var(--surface));
  color: var(--corp);
  box-shadow: inset 0 0 0 1px rgba(55, 48, 143, 0.18);
}

.nav-item.active {
  color: #fff;
  background: var(--corp);
  box-shadow: 0 8px 16px var(--corp-shadow);
}

.user-chip { justify-self: end; }

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 560;
}

.workspace-shell { padding: 10px 16px 14px; }

.module-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  margin-bottom: 7px;
}

.eyebrow {
  margin: 0 0 2px;
  text-transform: uppercase;
  font-weight: 560;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 20px; font-weight: 600; }
h2 { margin-bottom: 4px; font-size: 18px; font-weight: 580; }

.title-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

.activity-badge,
.reply-alert {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-weight: 560;
}

.activity-badge {
  min-height: 24px;
  padding: 3px 9px;
  font-size: 11px;
  box-shadow: 0 0 0 2px var(--badge-red-bg);
  border: 0;
  cursor: pointer;
}

.activity-badge.empty {
  background: var(--chip-bg);
  color: var(--muted);
}

.activity-badge:not(.empty):hover,
.activity-badge.active {
  box-shadow: 0 0 0 3px var(--badge-red-bg), 0 8px 18px rgba(181, 29, 42, 0.16);
}

.module-actions,
.reply-actions,
.dialog-actions,
.detail-controls,
.board-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.purchase-scale-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.purchase-scale-control select {
  width: 76px;
  height: 30px;
  padding: 0 8px;
  font-weight: 520;
}

.purchase-search {
  width: min(360px, 32vw);
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--text);
}

.primary-btn,
.ghost-btn,
.small-btn,
.icon-btn {
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  min-height: 30px;
}

.primary-btn {
  background: linear-gradient(135deg, var(--corp), var(--blue));
  color: #fff;
  padding: 0 12px;
  font-weight: 580;
  box-shadow: 0 8px 18px var(--corp-shadow);
}

.ghost-btn,
.small-btn {
  background: var(--surface-raised);
  border-color: #c9d8e5;
  color: var(--blue-dark);
  padding: 0 10px;
}

.small-btn {
  min-height: 28px;
  font-size: 11px;
  background: var(--corp-soft);
  border-color: rgba(55, 48, 143, 0.22);
  color: var(--corp);
  font-weight: 560;
}

.ghost-btn:hover,
.small-btn:hover {
  border-color: var(--corp);
  box-shadow: 0 0 0 3px var(--corp-shadow);
}

.ghost-btn.active {
  border-color: var(--corp);
  background: var(--corp-soft);
  color: var(--corp);
}

.icon-btn {
  width: 32px;
  background: var(--chip-bg);
  color: var(--ink);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-raised);
  color: var(--ink);
}

.summary-groups {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 10px;
  margin-bottom: 10px;
}

.summary-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  padding: 7px;
}

.summary-label {
  display: block;
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 560;
  text-transform: uppercase;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 8px;
}

.summary-strip.priorities {
  grid-template-columns: repeat(4, minmax(90px, 1fr));
}

.metric {
  --metric-color: var(--blue);
  appearance: none;
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 8px 5px 12px;
  box-shadow: 0 8px 20px rgba(28, 45, 61, 0.06);
  color: var(--text);
  cursor: pointer;
  overflow: hidden;
  text-align: left;
}

.metric::before,
.home-stat::before,
.purchase-metric::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--metric-color);
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.metric strong {
  color: color-mix(in srgb, var(--metric-color) 70%, var(--text));
  font-size: 16px;
  font-weight: 600;
}

.metric[data-scope="pending"],
.metric.metric-ticket-pending { --metric-color: var(--blue); }
.metric[data-scope="active"],
.metric.metric-ticket-active { --metric-color: var(--green); }
.metric.closed,
.metric.metric-ticket-closed { --metric-color: #7b8793; }
.metric.urgent { --metric-color: var(--red); }
.metric.high { --metric-color: var(--orange); }
.metric.medium { --metric-color: #c99a00; }
.metric.low { --metric-color: var(--green); }
.metric:hover,
.metric.active,
.metric.priority-active {
  border-color: color-mix(in srgb, var(--metric-color) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--metric-color) 14%, transparent), 0 8px 20px rgba(28, 45, 61, 0.06);
}

.home-module {
  min-height: calc(100vh - 106px);
  display: grid;
  align-content: start;
  gap: 10px;
}

.home-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--corp) 8%, transparent), transparent 42%),
    var(--surface);
  box-shadow: 0 10px 24px rgba(28, 45, 61, 0.08);
}

.home-hero h2 {
  margin: 0 0 3px;
  font-size: 18px;
}

.home-hero p {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}

.home-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--corp-soft);
  color: var(--corp);
  font-weight: 560;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.home-card {
  position: relative;
  min-height: 218px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 12px 12px 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(28, 45, 61, 0.07);
  overflow: hidden;
}

.home-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--blue);
}

.home-card.module-compras::before { background: var(--green); }
.home-card.module-pedidos::before { background: var(--orange); }
.home-card.module-indicadores::before { background: var(--purple); }

.home-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.home-module-name,
.home-status {
  color: var(--muted);
  font-size: 10px;
  font-weight: 540;
  text-transform: uppercase;
}

.home-status {
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--chip-bg);
}

.home-card h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 580;
}

.home-card p {
  min-height: 34px;
  margin: 0;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.32;
}

.home-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 7px;
}

.home-stat-section {
  display: grid;
  gap: 6px;
}

.home-stat-section + .home-stat-section {
  margin-top: 2px;
}

.home-stat-section-label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 560;
  text-transform: uppercase;
}

.home-stat {
  --metric-color: var(--blue);
  position: relative;
  min-height: 46px;
  padding: 8px 8px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  overflow: hidden;
}

.home-stat strong {
  display: block;
  color: color-mix(in srgb, var(--metric-color) 72%, var(--text));
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
}

.home-stat span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 560;
  text-transform: uppercase;
}

.home-stat.tone-red { --metric-color: var(--red); }
.home-stat.tone-corp { --metric-color: var(--corp); }
.home-stat.tone-blue { --metric-color: var(--blue); }
.home-stat.tone-cyan { --metric-color: #006cae; }
.home-stat.tone-green { --metric-color: var(--green); }
.home-stat.tone-gray { --metric-color: #7b8793; }
.home-stat.tone-muted { --metric-color: #7b8793; }
.home-stat.tone-neutral { --metric-color: #607080; }
.home-stat.tone-slate { --metric-color: #607d8b; }
.home-stat.tone-gold { --metric-color: #8a6f2a; }
.home-stat.tone-brown { --metric-color: #8a6f2a; }
.home-stat.tone-orange { --metric-color: var(--orange); }
.home-stat.tone-yellow { --metric-color: #c99a00; }
.home-stat.tone-indigo { --metric-color: #5c6bc0; }
.home-stat.tone-purple { --metric-color: #7b3ff2; }
.home-stat.tone-no-delivery { --metric-color: #546a7b; }
.home-stat.tone-pink { --metric-color: #d0007f; }
.home-stat.tone-magenta { --metric-color: #d0007f; }

.home-open-btn {
  align-self: flex-start;
  margin-top: auto;
}

.home-open-btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.home-empty {
  grid-column: 1 / -1;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 560;
}

.ticket-table-shell {
  height: calc(100vh - 192px);
  min-height: 510px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (max-width: 1380px) {
  .home-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.active-filter {
  min-height: 28px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 540;
  background: var(--surface);
}

.purchase-status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.purchase-status-main {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-status-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 1 auto;
  min-width: 0;
}

.purchase-status-meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  padding: 2px 6px;
  border: 1px solid color-mix(in srgb, var(--line) 78%, var(--corp));
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface-raised) 80%, var(--corp-soft));
  color: var(--muted);
  white-space: nowrap;
}

.purchase-status-meta-item strong {
  color: color-mix(in srgb, var(--text) 74%, var(--corp));
  font-weight: 650;
}

.ticket-table-wrap {
  flex: 1;
  overflow: auto;
  background: var(--surface-raised);
}

.purchase-tracking-shell {
  --purchase-text: color-mix(in srgb, var(--text) 86%, var(--muted));
  --purchase-strong: color-mix(in srgb, var(--text) 78%, var(--corp));
  --purchase-code: color-mix(in srgb, var(--corp) 78%, var(--text));
  --purchase-muted: color-mix(in srgb, var(--muted) 90%, var(--text));
  height: calc(100vh - 118px);
  min-height: 520px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.purchase-summary {
  display: flex;
  align-items: center;
  gap: 14px;
  transition: max-height 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

.purchase-metric-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.purchase-phase-group {
  flex: 1 1 58%;
}

.purchase-time-group {
  flex: 1 1 42%;
}

.purchase-metric-group-label {
  align-self: center;
  flex: 0 0 auto;
  margin-right: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 560;
  text-transform: uppercase;
}

.purchase-metric {
  --metric-color: var(--corp);
  --metric-bg: var(--surface);
  position: relative;
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: space-between;
  min-width: 96px;
  min-height: 34px;
  padding: 5px 8px 5px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  overflow: visible;
}

.purchase-metric.metric-today {
  min-width: calc(108px * var(--purchase-scale, 1));
}

.purchase-metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 520;
}

.purchase-metric strong {
  font-size: 16px;
  font-weight: 600;
  color: color-mix(in srgb, var(--metric-color) 70%, var(--text));
}

.purchase-metric.active {
  border-color: color-mix(in srgb, var(--metric-color) 55%, var(--line));
  background: color-mix(in srgb, var(--metric-color) 15%, var(--surface));
  color: color-mix(in srgb, var(--metric-color) 75%, var(--text));
}

.purchase-tracking-shell.provider-filter-mode .purchase-metric.provider-filter-applies::after {
  content: "";
  position: absolute;
  right: 14px;
  bottom: -5px;
  left: 14px;
  height: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, #d71920 64%, transparent);
}

.purchase-metric.metric-overdue { --metric-color: #d71920; }
.purchase-metric.metric-today { --metric-color: var(--corp); }
.purchase-metric.metric-soon { --metric-color: #2b79c2; }
.purchase-metric.metric-undated { --metric-color: #7b8793; }
.purchase-metric.metric-request { --metric-color: #607d8b; }
.purchase-metric.metric-prep { --metric-color: #8a6f2a; }
.purchase-metric.metric-approve { --metric-color: #cf7a12; }
.purchase-metric.metric-send { --metric-color: #5c6bc0; }
.purchase-metric.metric-receive { --metric-color: #006cae; }
.purchase-metric.metric-withdraw { --metric-color: #7b3ff2; }
.purchase-metric.metric-no-delivery { --metric-color: #546a7b; }
.purchase-metric.metric-rented { --metric-color: #d0007f; }

.purchase-board {
  --purchase-scale: 1;
  --purchase-lane-width: calc(132px * var(--purchase-scale));
  --purchase-day-width: calc(138px * var(--purchase-scale));
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: calc(7px * var(--purchase-scale));
  min-height: 0;
  font-size: calc(13px * var(--purchase-scale));
}

.purchase-main-board {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(calc(208px * var(--purchase-scale)), calc(248px * var(--purchase-scale))) minmax(0, 1fr);
  gap: calc(7px * var(--purchase-scale));
}

body.purchase-compact .module-head,
body.purchase-compact .purchase-summary,
body.purchase-compact #purchaseActiveFilter {
  max-height: 0;
  min-height: 0;
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin: 0;
  border-width: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transform: translateY(-8px);
}

body.purchase-compact .workspace-shell {
  padding-top: 6px;
}

body.purchase-compact .purchase-tracking-shell {
  height: calc(100vh - 64px);
}

.purchase-previous-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 8px;
  min-height: 0;
  flex: 1;
}

.purchase-transit-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.purchase-transit-panel > header {
  min-height: calc(36px * var(--purchase-scale));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(12px * var(--purchase-scale));
  padding: calc(6px * var(--purchase-scale)) calc(9px * var(--purchase-scale));
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.purchase-transit-panel > header strong {
  display: block;
  font-size: calc(13px * var(--purchase-scale));
}

.purchase-transit-panel > header span,
.purchase-transit-panel > header small,
.purchase-timeline-note {
  color: var(--muted);
  font-size: calc(11px * var(--purchase-scale));
  font-weight: 520;
}

.purchase-timeline-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--line) 50%, transparent) 1px, transparent 1px) 0 0 / var(--purchase-day-width) 100%,
    var(--surface-raised);
}

.purchase-timeline-grid {
  display: grid;
  grid-template-rows: calc(30px * var(--purchase-scale)) auto;
  min-height: 100%;
  min-width: max-content;
  position: relative;
}

.purchase-timeline-corner,
.purchase-timeline-date,
.purchase-timeline-lane-label,
.purchase-timeline-cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.purchase-timeline-corner,
.purchase-timeline-date {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(6px * var(--purchase-scale));
  min-height: calc(30px * var(--purchase-scale));
  border: 0;
  background: var(--surface-soft);
  font-weight: 560;
  color: var(--muted);
  box-shadow: inset 0 -1px 0 var(--line);
}

.purchase-timeline-date strong {
  min-width: calc(20px * var(--purchase-scale));
  padding: calc(1px * var(--purchase-scale)) calc(6px * var(--purchase-scale));
  border-radius: 999px;
  background: var(--badge-blue-bg);
  color: var(--blue-dark);
  font-size: calc(11px * var(--purchase-scale));
  font-weight: 560;
}

.purchase-timeline-corner {
  left: 0;
  z-index: 4;
}

.purchase-timeline-date.today {
  color: #ffffff;
  background: var(--corp-soft);
  background: var(--corp);
  box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--red) 72%, #ffffff);
}

.purchase-timeline-date.today span {
  color: #ffffff;
  font-weight: 600;
}

.purchase-timeline-date.today strong {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.purchase-overdue-toggle {
  width: 100%;
  cursor: pointer;
  appearance: none;
  font: inherit;
}

.purchase-overdue-toggle span {
  color: color-mix(in srgb, var(--red) 72%, var(--text));
}

.purchase-overdue-toggle strong {
  background: #ffe3e0;
  color: #a91419;
}

.purchase-timeline-lane-label {
  position: sticky;
  left: 0;
  z-index: 3;
  min-height: calc(330px * var(--purchase-scale));
  padding: calc(8px * var(--purchase-scale));
  background: var(--surface-soft);
}

.purchase-timeline-lane-label strong,
.purchase-timeline-lane-label span {
  display: block;
}

.purchase-timeline-lane-label span {
  width: fit-content;
  margin-top: calc(6px * var(--purchase-scale));
  padding: calc(2px * var(--purchase-scale)) calc(8px * var(--purchase-scale));
  border-radius: 999px;
  background: var(--badge-blue-bg);
  color: var(--blue-dark);
  font-weight: 600;
}

.purchase-timeline-cell {
  min-height: 100%;
  overflow: visible;
  display: grid;
  align-content: start;
  gap: calc(5px * var(--purchase-scale));
  padding: calc(6px * var(--purchase-scale));
}

.purchase-timeline-cell.collapsed-overdue {
  align-content: start;
  justify-content: stretch;
  background: color-mix(in srgb, var(--red) 5%, var(--surface-raised));
}

.purchase-overdue-summary {
  display: grid;
  gap: calc(3px * var(--purchase-scale));
  align-items: center;
  justify-items: center;
  min-height: calc(64px * var(--purchase-scale));
  border: 1px dashed color-mix(in srgb, var(--red) 34%, var(--line));
  border-radius: calc(8px * var(--purchase-scale));
  background: color-mix(in srgb, #ffe3e0 64%, var(--surface));
  color: color-mix(in srgb, var(--red) 70%, var(--text));
  cursor: pointer;
  font: inherit;
}

.purchase-overdue-summary strong {
  font-size: calc(18px * var(--purchase-scale));
  font-weight: 600;
}

.purchase-overdue-summary span {
  font-size: calc(11px * var(--purchase-scale));
  font-weight: 560;
}

.purchase-today-marker {
  grid-row: 1 / -1;
  position: relative;
  z-index: 4;
  pointer-events: none;
}

.purchase-today-marker::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--today-progress, 50%);
  width: 1px;
  background: color-mix(in srgb, var(--red) 56%, transparent);
  box-shadow: 0 0 4px color-mix(in srgb, var(--red) 16%, transparent);
}

.purchase-timeline-block {
  min-width: calc(124px * var(--purchase-scale));
  border: 1px solid var(--line);
  border-left: max(2px, calc(4px * var(--purchase-scale))) solid var(--badge-default-text);
  border-radius: calc(7px * var(--purchase-scale));
  background: #eef8c9;
  color: #17212b;
  padding: calc(5px * var(--purchase-scale)) calc(7px * var(--purchase-scale));
  box-shadow: 0 1px 0 rgba(20, 35, 50, 0.04);
}

.purchase-order-card {
  cursor: pointer;
}

.purchase-timeline-block-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: calc(6px * var(--purchase-scale));
}

.purchase-transit-badge {
  flex: 0 0 auto;
  padding: calc(1px * var(--purchase-scale)) calc(6px * var(--purchase-scale));
  border-radius: 999px;
  font-size: calc(10px * var(--purchase-scale));
  font-style: normal;
  font-weight: 600;
}

.purchase-transit-badge.receive {
  background: #006cae;
  color: #ffffff;
}

.purchase-transit-badge.withdraw {
  background: #7b3ff2;
  color: #ffffff;
}

.purchase-transit-badge.no-delivery {
  background: #546a7b;
  color: #ffffff;
}

.purchase-transit-badge.received {
  background: #d71920;
  color: #ffffff;
}

.purchase-transit-badge.rented {
  background: #d0007f;
  color: #ffffff;
}

.purchase-timeline-block.vencido { border-left-color: var(--red); background: #fff0ee; }
.purchase-timeline-block.hoy { border-left-color: var(--orange); background: #fff5df; }
.purchase-timeline-block.proximo { border-left-color: var(--blue); background: #eef8c9; }
.purchase-timeline-block.sin-fecha { border-left-color: var(--muted); background: var(--surface); }

.purchase-timeline-block.receive {
  border-left-color: #006cae;
  background: #e8f6ff;
  box-shadow: inset 0 0 0 1px rgba(0, 108, 174, 0.12), 0 1px 0 rgba(20, 35, 50, 0.04);
}

.purchase-timeline-block.withdraw {
  border-left-color: #7b3ff2;
  background: #fff1d6;
  box-shadow: inset 0 0 0 1px rgba(123, 63, 242, 0.16), 0 1px 0 rgba(20, 35, 50, 0.04);
}

.purchase-timeline-block.no-delivery {
  border-left-color: #546a7b;
  background: #eef3f6;
  box-shadow: inset 0 0 0 1px rgba(84, 106, 123, 0.16), 0 1px 0 rgba(20, 35, 50, 0.04);
}

.purchase-timeline-block.vencido.receive,
.purchase-timeline-block.vencido.withdraw,
.purchase-timeline-block.vencido.no-delivery {
  border-left-color: #d71920;
  background: #ffe3e0;
  box-shadow: inset 0 0 0 1px rgba(215, 25, 32, 0.18), 0 1px 0 rgba(20, 35, 50, 0.04);
}

.purchase-timeline-block.rented-machine {
  border-left-color: #d0007f;
  background: #ffe1f2;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #d0007f 18%, transparent), 0 1px 0 rgba(20, 35, 50, 0.04);
}

.purchase-timeline-block.vencido.rented-machine {
  border-left-color: #d0007f;
  background: #ffd6eb;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, #d0007f 20%, transparent), 0 1px 0 rgba(20, 35, 50, 0.04);
}

.purchase-timeline-block.received {
  border-left-color: #d71920;
  background: #ffe3e0;
  box-shadow: inset 0 0 0 1px rgba(215, 25, 32, 0.18), 0 0 12px rgba(215, 25, 32, 0.22);
  animation: received-order-pulse 2.4s ease-in-out infinite;
}

.purchase-timeline-block strong,
.purchase-timeline-block span,
.purchase-timeline-block small {
  display: block;
}

.purchase-timeline-block .purchase-badge-row {
  display: flex;
  align-items: center;
  gap: calc(4px * var(--purchase-scale));
  max-width: none;
  margin-top: 0;
  overflow: visible;
  white-space: nowrap;
}

.purchase-timeline-block strong {
  color: #37308f;
  font-size: calc(12px * var(--purchase-scale));
  font-weight: 600;
}

.purchase-timeline-block span {
  margin-top: calc(2px * var(--purchase-scale));
  max-width: calc(220px * var(--purchase-scale));
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  font-weight: 560;
  font-size: calc(12px * var(--purchase-scale));
  line-height: 1.18;
}

.purchase-timeline-block small {
  margin-top: calc(2px * var(--purchase-scale));
  color: #536271;
  font-size: calc(11px * var(--purchase-scale));
  font-weight: 520;
}

.purchase-timeline-empty,
.purchase-timeline-note {
  padding: 0 10px 8px;
}

.purchase-column {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.purchase-column header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(34px * var(--purchase-scale));
  padding: calc(7px * var(--purchase-scale)) calc(9px * var(--purchase-scale));
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
  font-weight: 560;
}

.purchase-column header strong {
  min-width: calc(24px * var(--purchase-scale));
  text-align: center;
  padding: calc(2px * var(--purchase-scale)) calc(6px * var(--purchase-scale));
  border-radius: 999px;
  background: var(--badge-blue-bg);
  color: var(--blue-dark);
}

.purchase-card-list {
  display: grid;
  align-content: start;
  gap: calc(6px * var(--purchase-scale));
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: calc(7px * var(--purchase-scale));
}

.purchase-card {
  border: 1px solid var(--line);
  border-left: max(2px, calc(4px * var(--purchase-scale))) solid var(--badge-default-text);
  border-radius: calc(8px * var(--purchase-scale));
  background: var(--surface-raised);
  padding: calc(7px * var(--purchase-scale));
}

.purchase-request-card {
  padding: calc(6px * var(--purchase-scale)) calc(7px * var(--purchase-scale));
  cursor: pointer;
}

.purchase-card.vencido { border-left-color: var(--red); }
.purchase-card.hoy { border-left-color: var(--orange); }
.purchase-card.proximo { border-left-color: var(--blue); }
.purchase-card.sin-fecha { border-left-color: var(--muted); }
.purchase-card.sin-programacion { border-left-color: #7b8793; }
.purchase-card.solicitudes_pendientes { border-left-color: #607d8b; }
.purchase-card.pedidos_preparacion { border-left-color: #8a6f2a; }
.purchase-card.pendiente_aprobar { border-left-color: #cf7a12; }
.purchase-card.pendiente_enviar { border-left-color: #5c6bc0; }
.purchase-card.pendiente_recibir { border-left-color: #006cae; }
.purchase-card.pendiente_retirar { border-left-color: #7b3ff2; }
.purchase-card.rented-machine {
  border-left-color: #d0007f;
  background: color-mix(in srgb, #d0007f 7%, var(--surface-raised));
}

.purchase-focus-panel .purchase-card.vencido,
.purchase-focus-panel .purchase-card.hoy,
.purchase-focus-panel .purchase-card.proximo,
.purchase-focus-panel .purchase-card.sin-fecha {
  border-left-color: inherit;
}

.purchase-focus-panel .purchase-card.pedidos_preparacion { border-left-color: #8a6f2a; }
.purchase-focus-panel .purchase-card.pendiente_aprobar { border-left-color: #cf7a12; }
.purchase-focus-panel .purchase-card.pendiente_enviar { border-left-color: #5c6bc0; }

.purchase-card-top {
  display: flex;
  justify-content: space-between;
  gap: calc(8px * var(--purchase-scale));
  align-items: center;
}

.purchase-card-top strong {
  font-size: calc(12px * var(--purchase-scale));
  color: var(--corp);
}

.purchase-card-top span {
  padding: calc(2px * var(--purchase-scale)) calc(6px * var(--purchase-scale));
  border-radius: 999px;
  background: var(--badge-default-bg);
  color: var(--badge-default-text);
  font-size: calc(11px * var(--purchase-scale));
  font-weight: 560;
}

.purchase-card-top .purchase-card-badges {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: calc(5px * var(--purchase-scale));
  padding: 0;
  background: transparent;
}

.purchase-card-top .purchase-card-badges > span {
  padding: calc(2px * var(--purchase-scale)) calc(6px * var(--purchase-scale));
  border-radius: 999px;
  background: var(--badge-default-bg);
  color: var(--badge-default-text);
}

.purchase-card-top .request-started-light {
  display: block;
  width: calc(11px * var(--purchase-scale));
  height: calc(11px * var(--purchase-scale));
  min-width: calc(11px * var(--purchase-scale));
  padding: 0;
  border: 1px solid color-mix(in srgb, #8cff00 74%, #ffffff);
  border-radius: 50%;
  background: #2af05a;
  box-shadow: 0 0 0 2px var(--badge-green-bg), 0 0 9px color-mix(in srgb, #48ff00 50%, transparent);
  animation: request-started-pulse 2.2s ease-in-out infinite;
}

.purchase-card-top .request-light-stack {
  display: flex;
  gap: calc(7px * var(--purchase-scale));
  align-items: center;
  justify-content: flex-end;
  padding: 0;
  border-radius: 0;
  background: transparent;
}

.purchase-card-top .request-light-stack .purchase-transit-badge {
  display: inline-flex;
  align-items: center;
  min-height: calc(18px * var(--purchase-scale));
}

.purchase-card-top .request-started-light.partial {
  border-color: color-mix(in srgb, #ffae00 74%, #ffffff);
  background: #ffae00;
  box-shadow: 0 0 0 2px #fff0cf, 0 0 9px color-mix(in srgb, #ffae00 52%, transparent);
  animation-name: request-partial-pulse;
}

.purchase-card-top .request-started-light.received {
  border-color: color-mix(in srgb, #ff3b30 76%, #ffffff);
  background: #ff3b30;
  box-shadow: 0 0 0 2px #ffe3e0, 0 0 9px color-mix(in srgb, #ff3b30 54%, transparent);
  animation-name: request-received-pulse;
}

.purchase-card-top .request-started-light.rented {
  border-color: color-mix(in srgb, #ff2ea6 72%, #ffffff);
  background: #ff2ea6;
  box-shadow: 0 0 0 2px #ffe2f3, 0 0 8px color-mix(in srgb, #ff2ea6 44%, transparent);
  animation-name: request-rented-pulse;
}

@keyframes request-started-pulse {
  0%, 100% {
    opacity: 0.7;
    transform: scale(0.92);
    background: var(--green);
    box-shadow: 0 0 0 2px var(--badge-green-bg), 0 0 5px color-mix(in srgb, var(--green) 38%, transparent);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.08);
    background: #65ee24;
    box-shadow: 0 0 0 3px color-mix(in srgb, #65ee24 16%, transparent), 0 0 12px color-mix(in srgb, #65ee24 58%, transparent);
  }
}

@keyframes request-partial-pulse {
  0%, 100% {
    opacity: 0.7;
    transform: scale(0.92);
    background: #d78000;
    box-shadow: 0 0 0 2px #fff0cf, 0 0 5px color-mix(in srgb, #d78000 36%, transparent);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.08);
    background: #f0b32b;
    box-shadow: 0 0 0 3px color-mix(in srgb, #f0b32b 16%, transparent), 0 0 12px color-mix(in srgb, #f0b32b 58%, transparent);
  }
}

@keyframes request-received-pulse {
  0%, 100% {
    opacity: 0.7;
    transform: scale(0.92);
    background: #d71920;
    box-shadow: 0 0 0 2px #ffe3e0, 0 0 5px rgba(215, 25, 32, 0.36);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.08);
    background: #ef5148;
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.16), 0 0 12px rgba(255, 59, 48, 0.58);
  }
}

@keyframes request-rented-pulse {
  0%, 100% {
    opacity: 0.72;
    transform: scale(0.92);
    background: #d0007f;
    box-shadow: 0 0 0 2px #ffe2f3, 0 0 5px color-mix(in srgb, #d0007f 34%, transparent);
  }
  50% {
    opacity: 0.9;
    transform: scale(1.06);
    background: #ff2ea6;
    box-shadow: 0 0 0 3px color-mix(in srgb, #ff2ea6 14%, transparent), 0 0 11px color-mix(in srgb, #ff2ea6 46%, transparent);
  }
}

@keyframes received-order-pulse {
  0%, 100% {
    box-shadow: inset 0 0 0 1px rgba(215, 25, 32, 0.18), 0 0 6px rgba(215, 25, 32, 0.14);
  }
  50% {
    box-shadow: inset 0 0 0 1px rgba(215, 25, 32, 0.24), 0 0 16px rgba(215, 25, 32, 0.34);
  }
}

.purchase-title {
  margin: calc(5px * var(--purchase-scale)) 0;
  line-height: 1.25;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.purchase-request-card .purchase-title {
  -webkit-line-clamp: 2;
  margin: calc(5px * var(--purchase-scale)) 0 calc(4px * var(--purchase-scale));
  font-size: calc(13px * var(--purchase-scale));
  line-height: 1.18;
}

.purchase-request-serial {
  margin: 0 0 calc(4px * var(--purchase-scale));
  color: var(--muted);
  font-size: calc(11px * var(--purchase-scale));
  font-weight: 520;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.purchase-card dl {
  display: grid;
  gap: calc(3px * var(--purchase-scale));
  margin: 0;
}

.purchase-card dl div {
  display: grid;
  grid-template-columns: calc(52px * var(--purchase-scale)) minmax(0, 1fr);
  gap: calc(5px * var(--purchase-scale));
}

.purchase-card dt {
  color: var(--muted);
  font-weight: 520;
}

.purchase-card dd {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-detail,
.empty-stage {
  margin: calc(6px * var(--purchase-scale)) 0 0;
  color: var(--muted);
  font-size: calc(12px * var(--purchase-scale));
  line-height: 1.3;
}

.purchase-tracking-shell .active-filter,
.purchase-tracking-shell .purchase-metric span,
.purchase-tracking-shell .purchase-transit-panel > header span,
.purchase-tracking-shell .purchase-transit-panel > header small,
.purchase-tracking-shell .purchase-timeline-note,
.purchase-tracking-shell .purchase-timeline-corner,
.purchase-tracking-shell .purchase-timeline-date,
.purchase-tracking-shell .purchase-card dt,
.purchase-tracking-shell .purchase-request-serial,
.purchase-tracking-shell .purchase-detail,
.purchase-tracking-shell .empty-stage {
  color: var(--purchase-muted);
  font-weight: 560;
}

.purchase-tracking-shell .purchase-metric strong,
.purchase-tracking-shell .purchase-transit-panel > header strong,
.purchase-tracking-shell .purchase-column header,
.purchase-tracking-shell .purchase-timeline-lane-label strong,
.purchase-tracking-shell .purchase-title,
.purchase-tracking-shell .purchase-card dd,
.purchase-tracking-shell .purchase-timeline-block span {
  color: var(--purchase-text);
  font-weight: 560;
}

.purchase-tracking-shell .purchase-column header strong,
.purchase-tracking-shell .purchase-card-top strong,
.purchase-tracking-shell .purchase-timeline-block strong {
  color: var(--purchase-code);
  font-weight: 600;
}

.purchase-tracking-shell .purchase-card-top span,
.purchase-tracking-shell .purchase-transit-badge,
.purchase-tracking-shell .purchase-timeline-lane-label span {
  font-weight: 560;
}

.purchase-tracking-shell .purchase-timeline-date.today,
.purchase-tracking-shell .purchase-timeline-date.today span,
.purchase-tracking-shell .purchase-timeline-date.today strong {
  color: #ffffff;
}

.purchase-tracking-shell .purchase-timeline-block strong {
  color: #37308f;
}

.purchase-tracking-shell .purchase-timeline-block span {
  color: #17212b;
}

.purchase-tracking-shell .purchase-timeline-block small {
  color: #536271;
}

.purchase-tracking-shell .purchase-timeline-block.vencido span,
.purchase-tracking-shell .purchase-timeline-block.received span,
.purchase-tracking-shell .purchase-timeline-block.rented-machine span {
  color: #17212b;
}

.purchase-focus-panel {
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.purchase-focus-panel > header {
  min-height: 32px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.purchase-focus-panel > header div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.purchase-focus-panel > header span {
  color: var(--muted);
  font-size: calc(11px * var(--purchase-scale));
  font-weight: 520;
}

.small-btn {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-raised);
  color: var(--muted);
  padding: 0 8px;
  font-weight: 540;
  cursor: pointer;
}

.purchase-focus-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  align-content: start;
  gap: 7px;
  padding: 7px;
}

.purchase-provider-board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.purchase-provider-board > header {
  min-height: 36px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.purchase-provider-board > header div {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.purchase-provider-board > header span {
  color: var(--muted);
  font-size: 12px;
}

.purchase-provider-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  align-content: start;
  padding: 8px;
}

.purchase-provider-group {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid color-mix(in srgb, var(--corp) 18%, var(--line));
  border-radius: 8px;
  background: var(--surface-raised);
}

.purchase-provider-group > header {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  gap: 10px;
  align-items: start;
  margin: -9px -9px 0;
  padding: 8px 9px;
  border-bottom: 1px solid color-mix(in srgb, var(--corp) 28%, var(--line));
  border-radius: 8px 8px 0 0;
  background: color-mix(in srgb, var(--corp) 14%, var(--surface));
}

.purchase-provider-group > header strong {
  display: block;
  color: var(--text);
  font-size: 13px;
}

.purchase-provider-group > header span,
.purchase-provider-group > header small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.purchase-provider-counts {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.purchase-provider-counts span,
.purchase-provider-note-count {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.purchase-provider-copy {
  min-height: 24px;
  padding: 3px 8px;
  border-color: color-mix(in srgb, var(--corp) 30%, var(--line));
  background: var(--surface);
  color: var(--corp);
  font-size: 11px;
  font-weight: 650;
}

.purchase-provider-copy:disabled {
  opacity: 0.72;
}

.provider-copy-dialog form {
  width: min(420px, calc(100vw - 32px));
  padding: 14px;
  display: grid;
  gap: 12px;
}

.provider-copy-options {
  margin: 0;
  padding: 10px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
}

.provider-copy-options legend,
.provider-copy-hint {
  color: var(--muted);
  font-size: 12px;
}

.provider-copy-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 560;
}

.purchase-provider-items {
  display: grid;
  gap: 5px;
}

.purchase-provider-item {
  width: 100%;
  min-height: 34px;
  display: grid;
  gap: 6px;
  padding: 0;
  border: 1px solid color-mix(in srgb, #2b79c2 16%, var(--line));
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.purchase-provider-item-head {
  display: grid;
  grid-template-columns: 94px minmax(180px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 8px;
  border-bottom: 1px solid color-mix(in srgb, #2b79c2 14%, var(--line));
  border-radius: 7px 7px 0 0;
  background: color-mix(in srgb, #2b79c2 7%, var(--surface));
}

.purchase-provider-item:hover {
  border-color: var(--corp);
  box-shadow: 0 0 0 2px var(--corp-shadow);
}

.purchase-provider-stage,
.purchase-provider-time,
.purchase-provider-date,
.purchase-provider-contact,
.purchase-provider-products {
  color: var(--muted);
  font-size: 11px;
}

.purchase-provider-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 6px 8px 0;
}

.purchase-provider-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--text);
  font-size: 11px;
  font-weight: 590;
  line-height: 1;
}

.purchase-provider-meta small {
  color: color-mix(in srgb, currentColor 74%, white);
  font-size: 8px;
  font-weight: 560;
  text-transform: uppercase;
}

.purchase-provider-stage.solicitudes_pendientes { background: #607d8b; color: #ffffff; }
.purchase-provider-stage.pedidos_preparacion { background: #8a6f2a; color: #ffffff; }
.purchase-provider-stage.pendiente_aprobar { background: #cf7a12; color: #ffffff; }
.purchase-provider-stage.pendiente_enviar { background: #5c6bc0; color: #ffffff; }
.purchase-provider-stage.pendiente_recibir { background: #006cae; color: #ffffff; }
.purchase-provider-stage.pendiente_retirar { background: #7b3ff2; color: #ffffff; }
.purchase-provider-stage.no-delivery { background: #546a7b; color: #ffffff; }
.purchase-provider-time.vencido { background: #d71920; color: #ffffff; }
.purchase-provider-time.hoy { background: var(--corp); color: #ffffff; }
.purchase-provider-time.proximo { background: #2b79c2; color: #ffffff; }
.purchase-provider-time.sin-fecha,
.purchase-provider-time.sin-programacion { background: #7b8793; color: #ffffff; }
.purchase-provider-date { border: 1px solid var(--line); background: var(--surface); color: var(--muted); }

.purchase-provider-item strong {
  color: var(--corp);
  font-size: 12px;
}

.purchase-provider-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.purchase-provider-contact {
  padding: 0 8px;
}

.purchase-provider-product-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  border: 1px solid var(--line);
  border-radius: 0 0 7px 7px;
  overflow: hidden;
  background: var(--surface-raised);
}

.purchase-provider-product-table th,
.purchase-provider-product-table td {
  padding: 5px 7px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 11px;
}

.purchase-provider-product-table th {
  background: var(--surface);
  color: color-mix(in srgb, var(--muted) 88%, var(--text));
  text-transform: uppercase;
}

.purchase-provider-product-table th:nth-child(1),
.purchase-provider-product-table td:nth-child(1) {
  width: 58px;
  white-space: nowrap;
}

.purchase-provider-product-table th:nth-child(2),
.purchase-provider-product-table td:nth-child(2) {
  width: 92px;
  color: var(--corp);
  font-weight: 600;
}

.purchase-provider-product-table th:nth-child(3),
.purchase-provider-product-table td:nth-child(3) {
  width: 92px;
}

.purchase-provider-product-table th:nth-child(4),
.purchase-provider-product-table td:nth-child(4) {
  width: 120px;
}

.purchase-provider-product-table th:nth-child(5),
.purchase-provider-product-table td:nth-child(5) {
  width: auto;
}

.purchase-provider-product-table tr:last-child td {
  border-bottom: 0;
}

.purchase-provider-product-table th:last-child,
.purchase-provider-product-table td:last-child {
  border-right: 0;
}

.purchase-provider-no-products {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.ticket-table {
  width: 100%;
  min-width: 0;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.ticket-table col[data-col="code"] { width: 10%; }
.ticket-table col[data-col="title"] { width: 31%; }
.ticket-table col[data-col="module"] { width: 11%; }
.ticket-table col[data-col="owner"] { width: 12%; }
.ticket-table col[data-col="opened"] { width: 11%; }
.ticket-table col[data-col="status"] { width: 10%; }
.ticket-table col[data-col="priority"] { width: 10%; }
.ticket-table col[data-col="attachments"] { width: 2.5%; }
.ticket-table col[data-col="replies"] { width: 2.5%; }

.ticket-table th,
.ticket-table td {
  min-height: 30px;
  padding: 0 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.ticket-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 29px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
}

.ticket-table th {
  padding-right: 14px;
}

.sort-head {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  cursor: pointer;
  text-align: left;
  text-transform: uppercase;
  font-weight: 600;
}

.sort-head.center { justify-content: center; }

.resize-handle {
  display: none;
}

.resize-handle:hover,
.resize-handle:active {
  background: color-mix(in srgb, var(--corp) 28%, transparent);
}

.sort-icons {
  color: #98a5b1;
  font-size: 8px;
  letter-spacing: -1px;
}

.sort-head.sorted .sort-icons {
  color: var(--blue-dark);
}

.sort-head.sorted[data-direction="asc"] .sort-icons::before,
.sort-head.sorted[data-direction="desc"] .sort-icons::after {
  color: var(--blue-dark);
}

.ticket-table th:nth-child(8),
.ticket-table th:nth-child(9) { text-align: center; }

.ticket-table td:nth-child(8),
.ticket-table td:nth-child(9) { text-align: center; color: var(--muted); }

.ticket-table tbody tr {
  background: var(--surface-raised);
  cursor: pointer;
}

.ticket-table tbody tr:hover {
  background: var(--surface-soft);
}

.ticket-table tbody tr.selected {
  background: rgba(0, 108, 174, 0.1);
}

.ticket-table tbody tr.closed {
  opacity: 0.62;
}

.ticket-table tbody tr[data-status="pendiente"] .code-cell { border-left: 4px solid var(--blue); }
.ticket-table tbody tr[data-status="iniciado"] .code-cell { border-left: 4px solid var(--green); }
.ticket-table tbody tr[data-status="cerrado"] .code-cell,
.ticket-table tbody tr[data-status="descartado"] .code-cell { border-left: 4px solid #7b8793; }

.code-cell {
  color: var(--blue-dark);
  font-weight: 600;
  min-width: 145px;
  white-space: nowrap;
}

.ticket-table td.title-cell {
  font-weight: 560;
  padding-top: 4px;
  padding-bottom: 4px;
  white-space: normal;
}

.title-text {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.16;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.unread-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  border: 1px solid rgba(255, 255, 255, 0.85);
}

.new-ticket-dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 3px var(--badge-red-bg);
  vertical-align: 1px;
}

.reply-count {
  display: inline-flex;
  min-width: 24px;
  min-height: 22px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
}

.unread-reply-count {
  background: var(--red);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 0 0 3px var(--badge-red-bg);
}

.ticket-table tbody tr.unread {
  background: rgba(181, 29, 42, 0.06);
}

.ticket-table tbody tr.unread .title-cell {
  font-weight: 600;
}

.empty-row {
  height: 72px;
  text-align: center;
  color: var(--muted);
}

.ticket-layout {
  display: grid;
  grid-template-columns: minmax(330px, 34%) minmax(620px, 1fr);
  gap: 10px;
  height: calc(100vh - 158px);
  min-height: 540px;
}

.ticket-board,
.ticket-detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.board-toolbar {
  padding: 9px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  height: 32px;
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
}

.search-wrap input,
select,
textarea,
dialog input {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--text);
}

.search-wrap input {
  border: 0;
  outline: 0;
  flex: 1;
  min-width: 120px;
}

select {
  height: 32px;
  padding: 0 9px;
}

.ticket-list {
  height: calc(100% - 51px);
  overflow: auto;
  padding: 8px;
}

.ticket-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  background: var(--surface-raised);
  border-radius: 8px;
  padding: 9px 10px;
  margin-bottom: 7px;
  cursor: pointer;
  text-align: left;
}

.ticket-card.active {
  border-color: #8bbfe0;
  box-shadow: 0 0 0 3px rgba(0, 108, 174, 0.13);
}

.ticket-card.closed { opacity: 0.68; }
.ticket-card[data-priority="urgente"] { border-left-color: var(--red); }
.ticket-card[data-priority="alta"] { border-left-color: var(--orange); }
.ticket-card[data-priority="baja"] { border-left-color: var(--green); }

.card-title {
  display: block;
  font-weight: 600;
  margin-bottom: 3px;
}

.badges {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: end;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 560;
  background: var(--badge-default-bg);
  color: var(--badge-default-text);
}

.badge.urgente { background: var(--priority-red-bg); color: #fff; }
.badge.cerrado, .badge.descartado { background: var(--chip-bg); color: var(--muted); }
.badge.alta { background: var(--priority-orange-bg); color: #fff; }
.badge.baja { background: var(--priority-green-bg); color: #fff; }
.badge.media { background: var(--priority-yellow-bg); color: var(--yellow-text); }
.badge.pendiente { background: var(--badge-blue-bg); color: var(--blue-dark); }
.badge.iniciado { background: var(--badge-green-bg); color: var(--green); }

.editable-cell {
  padding: 0 5px;
}

.grid-select {
  width: 100%;
  height: 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--badge-default-bg);
  color: var(--badge-default-text);
  font-size: 10px;
  font-weight: 560;
  cursor: pointer;
}

.status-grid-select,
.priority-grid-select {
  padding: 0 5px;
}

.grid-select.status-pendiente {
  background: var(--badge-blue-bg);
  color: var(--blue-dark);
}

.grid-select.status-iniciado {
  background: var(--badge-green-bg);
  color: var(--green);
}

.grid-select.priority-baja {
  background: var(--priority-green-bg);
  color: #fff;
}

.grid-select.priority-media {
  background: var(--priority-yellow-bg);
  color: var(--yellow-text);
}

.grid-select.status-cerrado,
.grid-select.status-descartado {
  background: var(--chip-bg);
  color: var(--muted);
}

.grid-select.priority-alta {
  background: var(--priority-orange-bg);
  color: #fff;
}

.grid-select.priority-urgente {
  background: var(--priority-red-bg);
  color: #fff;
}

.ticket-detail {
  display: flex;
  flex-direction: column;
}

.ticket-detail-dialog {
  width: min(1220px, calc(100vw - 54px));
  max-width: none;
}

.ticket-detail-dialog form {
  height: min(760px, calc(100vh - 54px));
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.detail-top {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.ticket-code {
  margin-bottom: 3px;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 600;
}

.detail-grid {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(390px, 1.15fr) minmax(390px, 1fr) minmax(210px, 0.55fr);
  gap: 9px;
  padding: 10px;
  min-height: 0;
  overflow: hidden;
  background: var(--surface-soft);
}

.detail-panel {
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  min-height: 0;
  overflow: auto;
}

.detail-panel.original { border-top: 4px solid var(--blue-dark); }

.message-body {
  font-size: 14px;
  line-height: 1.32;
}

.message-body p { margin-bottom: 8px; }

.message-text {
  white-space: pre-wrap;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.reply-list {
  flex: 1;
  display: grid;
  align-content: start;
  gap: 7px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.replies-panel {
  display: flex;
  flex-direction: column;
}

.reply {
  position: relative;
  width: 100%;
  padding: 8px;
  background: var(--reply-bg);
  border-left: 3px solid #9cb4c7;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.reply:hover {
  box-shadow: 0 0 0 2px var(--corp-shadow);
}

.reply-main {
  display: block;
  width: 100%;
  cursor: pointer;
}

.reply-main:focus-visible {
  outline: 2px solid var(--corp);
  outline-offset: 3px;
  border-radius: 5px;
}

.reply-body {
  display: block;
}

.reply:not(.expanded) .reply-body .message-text {
  display: block;
  overflow: visible;
  white-space: normal;
}

.reply.expanded .reply-body .message-text {
  white-space: pre-wrap;
}

.reply.expanded {
  background: color-mix(in srgb, var(--reply-bg) 82%, var(--corp-soft));
  box-shadow: inset 0 0 0 1px rgba(55, 48, 143, 0.12);
}

.reply.unread-reply {
  border-left-color: var(--red);
  background: rgba(181, 29, 42, 0.07);
}

.reply strong {
  display: block;
  font-size: 11px;
  margin-bottom: 3px;
}

.reply-alert {
  float: right;
  padding: 2px 6px;
  font-size: 10px;
}

.reply-file-indicator {
  display: inline-flex;
  margin-left: 7px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--corp-soft);
  color: var(--corp);
  font-size: 10px;
  font-weight: 600;
}

.reply-thread-indicator {
  display: inline-flex;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--badge-blue-bg);
  color: var(--blue-dark);
  font-size: 10px;
  font-weight: 600;
}

.reply-command-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.reply-link-btn {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid rgba(55, 48, 143, 0.22);
  border-radius: 999px;
  background: var(--corp-soft);
  color: var(--corp);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.reply-link-btn:hover {
  border-color: var(--corp);
  box-shadow: 0 0 0 2px var(--corp-shadow);
}

.linked-replies {
  display: grid;
  gap: 6px;
  margin-top: 7px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
}

.linked-replies .reply {
  padding: 7px;
  background: color-mix(in srgb, var(--reply-bg) 86%, var(--surface));
}

.inline-media-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

.inline-media-grid.compact { margin-top: 6px; }

.inline-media {
  width: 104px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.thumb {
  height: 44px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  background:
    linear-gradient(135deg, rgba(0, 108, 174, 0.96), rgba(39, 68, 91, 0.96)),
    repeating-linear-gradient(45deg, transparent 0 8px, rgba(255, 255, 255, 0.18) 8px 10px);
}

.inline-media span {
  display: block;
  padding: 5px;
  font-size: 10px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-box {
  width: 100%;
  flex-shrink: 0;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  background: transparent;
}

.reply-box textarea,
dialog textarea,
.message-editor {
  display: block;
  width: 100%;
  min-height: 68px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
  color: var(--text);
  outline: 0;
  overflow: auto;
}

.message-editor:focus {
  border-color: #8bbfe0;
  box-shadow: 0 0 0 3px rgba(0, 108, 174, 0.13);
}

.message-editor.drag-over {
  border-color: var(--corp);
  background: var(--corp-soft);
  box-shadow: 0 0 0 3px var(--corp-shadow);
}

.file-input {
  display: none;
}

.message-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  font-weight: 500;
}

.message-editor.large {
  min-height: 310px;
}

.reply-actions {
  justify-content: space-between;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}

.reply-buttons {
  display: flex;
  align-items: center;
  gap: 7px;
}

.editor-media {
  width: 118px;
  display: inline-block;
  margin: 8px 7px 3px 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
  overflow: hidden;
  cursor: pointer;
  vertical-align: top;
}

.editor-media span {
  display: block;
  padding: 5px;
  font-size: 10px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-doc {
  display: inline-flex;
  max-width: 230px;
  align-items: center;
  gap: 6px;
  margin: 8px 7px 3px 0;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  vertical-align: middle;
}

.editor-doc strong {
  color: var(--blue-dark);
  font-size: 10px;
}

.editor-doc span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list {
  display: grid;
  gap: 7px;
}

.file-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  column-gap: 7px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  padding: 7px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.file-item span {
  grid-row: span 2;
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--blue-dark);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
}

.file-item strong,
.file-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item small {
  color: var(--muted);
}

.file-item.active {
  border-color: var(--corp);
  background: var(--corp-soft);
  box-shadow: 0 0 0 3px var(--corp-shadow);
}

dialog {
  border: 0;
  outline: 0;
  border-radius: 10px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop { background: var(--modal-backdrop); }

.ticket-dialog form {
  width: min(980px, calc(100vw - 70px));
  min-height: min(640px, calc(100vh - 70px));
  padding: 16px 18px;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto;
  gap: 12px;
}

.purchase-request-dialog form {
  --purchase-detail-text: color-mix(in srgb, var(--text) 86%, var(--muted));
  --purchase-detail-code: color-mix(in srgb, var(--corp) 78%, var(--text));
  --purchase-detail-muted: color-mix(in srgb, var(--muted) 90%, var(--text));
  --purchase-detail-band: color-mix(in srgb, #2b79c2 9%, var(--surface));
  --purchase-notes-band: color-mix(in srgb, #546a7b 9%, var(--surface));
  width: min(1560px, calc(100vw - 16px));
  height: min(900px, calc(100vh - 16px));
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--surface);
  overflow: hidden;
}

.purchase-request-dialog .dialog-head {
  align-items: flex-start;
  padding: 8px 18px 8px;
  border-bottom: 1px solid color-mix(in srgb, #2b79c2 18%, var(--line));
  background: linear-gradient(
    180deg,
    color-mix(in srgb, #2b79c2 12%, var(--surface)) 0%,
    color-mix(in srgb, #2b79c2 5%, var(--surface)) 100%
  );
}

.purchase-request-dialog .dialog-head > div {
  min-width: 0;
}

.purchase-request-dialog .dialog-head .icon-btn {
  width: 22px;
  min-width: 22px;
  min-height: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 68%, #2b79c2);
  border-color: color-mix(in srgb, #2b79c2 24%, var(--line));
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  box-shadow: none;
}

.purchase-request-dialog .dialog-head .icon-btn:hover {
  border-color: var(--corp);
  color: var(--corp);
  box-shadow: 0 0 0 2px var(--corp-shadow);
}

.purchase-request-dialog #purchaseRequestCode {
  color: var(--purchase-detail-code);
  font-weight: 600;
  font-size: 12px;
}

.purchase-request-dialog #purchaseRequestTitle {
  color: var(--purchase-detail-text);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.08;
}

.purchase-request-dialog .detail-meta {
  font-size: 11.5px;
  line-height: 1.2;
}

.purchase-request-dialog .detail-meta,
.purchase-request-dialog .purchase-request-orders-section h3,
.purchase-request-dialog .purchase-request-table th,
.purchase-request-dialog .purchase-request-order-table th {
  color: var(--purchase-detail-muted);
  font-weight: 560;
}

.purchase-request-dialog .purchase-request-table td,
.purchase-request-dialog .purchase-request-order-table td {
  color: var(--purchase-detail-text);
  font-weight: 560;
}

.purchase-detail-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(420px, 0.72fr) minmax(700px, 1.28fr);
  gap: 14px;
  padding: 16px 18px 18px;
  overflow: hidden;
}

.purchase-detail-main,
.purchase-detail-history {
  min-height: 0;
  display: grid;
  gap: 10px;
  align-content: start;
}

.purchase-detail-main {
  grid-template-rows: minmax(0, 1fr) auto;
  align-content: stretch;
  overflow: hidden;
  padding-right: 2px;
}

.purchase-detail-history {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-content: stretch;
  overflow: hidden;
}

.purchase-detail-history.with-supervisor-notes {
  grid-template-columns: minmax(420px, 1.18fr) minmax(260px, 0.82fr);
  gap: 12px;
}

.purchase-request-items {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
}

.purchase-request-orders-section {
  display: grid;
  gap: 6px;
  min-height: 0;
}

.purchase-request-orders-section h3,
.purchase-notes-section h3,
.purchase-note-compose-section h3 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
  text-transform: uppercase;
}

.purchase-request-orders {
  max-height: 170px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
}

.purchase-request-order-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.purchase-request-order-table th,
.purchase-request-order-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.purchase-request-order-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.purchase-request-order-table th:first-child,
.purchase-request-order-table td:first-child {
  width: 130px;
}

.purchase-request-order-table th:last-child,
.purchase-request-order-table td:last-child {
  width: 70px;
  text-align: center;
}

.purchase-request-provider-status {
  display: flex;
  align-items: center;
  justify-content: center;
}

.purchase-request-provider-status .request-started-light {
  display: block;
  width: 11px;
  height: 11px;
  min-width: 11px;
  padding: 0;
  border-radius: 50%;
}

.purchase-request-order strong {
  color: var(--corp);
  font-size: 12px;
  white-space: nowrap;
}

.purchase-request-order-table td:nth-child(2) {
  color: var(--text);
  font-weight: 540;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.15;
}

.purchase-request-order .request-started-light.partial {
  border: 1px solid color-mix(in srgb, #ffae00 74%, #ffffff);
  background: #ffae00;
  box-shadow: 0 0 0 2px #fff0cf, 0 0 9px color-mix(in srgb, #ffae00 52%, transparent);
  animation: request-partial-pulse 2.2s ease-in-out infinite;
}

.purchase-request-order .request-started-light.received {
  border: 1px solid color-mix(in srgb, #ff3b30 76%, #ffffff);
  background: #ff3b30;
  box-shadow: 0 0 0 2px #ffe3e0, 0 0 9px color-mix(in srgb, #ff3b30 54%, transparent);
  animation: request-received-pulse 2.2s ease-in-out infinite;
}

.purchase-request-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.purchase-request-table .purchase-col-qty {
  width: 58px;
}

.purchase-request-table .purchase-col-code {
  width: 92px;
}

.purchase-request-table .purchase-col-serial {
  width: 132px;
}

.purchase-request-table th,
.purchase-request-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 11.5px;
}

.purchase-request-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 10.5px;
  text-transform: uppercase;
}

.purchase-request-table td:first-child {
  white-space: nowrap;
  font-weight: 560;
}

.purchase-request-table td:last-child {
  color: var(--muted);
  font-weight: 520;
}

.purchase-product-code {
  color: var(--corp);
  font-weight: 600;
  white-space: nowrap;
}

.purchase-product-description {
  overflow-wrap: anywhere;
  line-height: 1.18;
}

.purchase-request-dialog .purchase-request-table td:first-child,
.purchase-request-dialog .purchase-request-table td:last-child,
.purchase-request-dialog .purchase-request-order-table td:nth-child(2) {
  font-weight: 540;
}

.purchase-request-dialog .purchase-product-code,
.purchase-request-dialog .purchase-request-order strong {
  color: var(--purchase-detail-code);
  font-weight: 560;
}

.purchase-request-dialog .purchase-product-description {
  color: var(--purchase-detail-text);
  font-weight: 520;
}

.purchase-transit-badge.notes {
  background: color-mix(in srgb, var(--corp) 12%, var(--surface));
  color: color-mix(in srgb, var(--corp) 84%, var(--text));
  border: 1px solid color-mix(in srgb, var(--corp) 24%, var(--line));
}

.purchase-notes-section {
  display: grid;
  gap: 7px;
  min-height: 0;
  padding: 9px;
  border: 1px solid color-mix(in srgb, #546a7b 22%, var(--line));
  border-radius: 8px;
  background: var(--purchase-notes-band);
}

.purchase-note-compose-section {
  display: grid;
  gap: 8px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.purchase-shared-notes-section {
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.purchase-supervisor-notes-section {
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-color: color-mix(in srgb, #7f5a16 28%, var(--line));
  background: color-mix(in srgb, #fff4d6 72%, var(--surface));
}

.purchase-supervisor-notes-list {
  background: color-mix(in srgb, #fffaf0 68%, var(--surface-raised));
}

.purchase-supervisor-note-item {
  border-color: color-mix(in srgb, #c28a1d 26%, var(--line));
}

.purchase-supervisor-note-item header strong {
  color: #7a4c00;
}

.purchase-notes-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 22px;
  padding: 0 2px;
}

.purchase-notes-head span,
.purchase-note-actions span {
  color: var(--muted);
  font-size: 11px;
}

.purchase-notes-list {
  min-height: 0;
  max-height: none;
  overflow: auto;
  display: grid;
  align-content: start;
  align-items: start;
  grid-auto-rows: max-content;
  gap: 7px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
}

.purchase-note-item {
  display: grid;
  align-self: start;
  gap: 5px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.purchase-note-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.purchase-note-item header strong {
  color: var(--text);
}

.purchase-note-item p {
  margin: 0;
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.3;
  white-space: pre-wrap;
}

.purchase-note-files,
.purchase-note-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.purchase-note-thumb,
.purchase-note-file,
.purchase-note-draft-file {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  max-width: 170px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
  font-size: 10.5px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.purchase-note-thumb img,
.purchase-note-draft-file img {
  width: 24px;
  height: 24px;
  object-fit: cover;
  border-radius: 5px;
}

.purchase-note-draft-file {
  cursor: pointer;
}

.purchase-note-editor {
  display: grid;
  gap: 8px;
  min-height: 0;
}

.purchase-note-text {
  min-height: 118px;
  max-height: none;
  overflow: auto;
  font-size: 11.5px;
  line-height: 1.35;
}

.purchase-note-compose-section .purchase-note-text {
  min-height: 112px;
  max-height: 160px;
}

.purchase-supervisor-note-editor .purchase-note-text {
  min-height: 112px;
  max-height: 160px;
}

.purchase-note-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.purchase-supervisor-note-editor .primary-btn {
  min-height: 30px;
  padding-inline: 14px;
}

.dialog-head,
.form-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 560;
}

dialog input,
dialog select {
  height: 32px;
  padding: 0 9px;
}

.form-row label { flex: 1; }

.new-ticket-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.image-dialog form {
  width: min(780px, 86vw);
  padding: 16px;
}

.floating-close { float: right; }

.image-preview {
  clear: both;
  height: 380px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 42px;
  font-weight: 600;
  background:
    linear-gradient(135deg, rgba(0, 108, 174, 0.98), rgba(30, 54, 70, 0.98)),
    repeating-linear-gradient(45deg, transparent 0 14px, rgba(255, 255, 255, 0.18) 14px 18px);
}

.image-preview.has-image {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  padding: 10px;
}

.image-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
}

@media (max-width: 1180px) {
  body { min-width: 980px; }
  .topbar { grid-template-columns: 260px 1fr 180px; }
  .nav-item { padding-inline: 10px; }
}
