:root {
  --navy: #1B2A6B;
  --blue: #3B82F6;
  --blue-dark: #2563EB;
  --bg: #F5F5F5;
  --card: #ffffff;
  --border: #e2e6ef;
  --text: #1f2433;
  --muted: #6b7280;
  --red: #dc2626;
  --teal: #2bc0d8;
  --shadow: 0 1px 3px rgba(16, 24, 64, 0.08), 0 1px 2px rgba(16, 24, 64, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ---------- Header ---------- */
.site-header {
  background: var(--navy);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.logo-chip {
  background: #fff;
  border-radius: 10px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
}
.logo-chip img { height: 44px; display: block; }
.portal-title { font-size: 1.15rem; font-weight: 700; color: #fff; }
.header-right { display: flex; align-items: center; gap: 14px; }

/* Language toggle */
.lang-toggle { display: inline-flex; border: 1px solid rgba(255,255,255,.5); border-radius: 8px; overflow: hidden; }
.lang-toggle button {
  background: transparent; color: #fff; border: 0; padding: 6px 14px;
  cursor: pointer; font-weight: 600; font-size: .85rem;
}
.lang-toggle button.active { background: #fff; color: var(--navy); }

.header-link { color: #cdd6ff; text-decoration: none; font-size: .9rem; }
.header-link:hover { color: #fff; }
.notif-badge { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: #ef4444; color: #fff; font-size: .72rem; font-weight: 700; text-align: center; line-height: 18px; }

/* ---------- Layout ---------- */
.container { max-width: 920px; margin: 0 auto; padding: 24px 16px 64px; }
.container-wide { max-width: 1360px; }

h1.page-title { color: var(--navy); font-size: 1.6rem; margin: 0 0 6px; }
.page-subtitle { color: var(--muted); margin: 0 0 22px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
}
.card-title { color: var(--navy); font-size: 1.05rem; font-weight: 700; margin: 0 0 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }

/* ---------- Type selection ---------- */
.type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.type-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 26px 20px; text-align: center; cursor: pointer; box-shadow: var(--shadow);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.type-card:hover { transform: translateY(-3px); border-color: var(--blue); box-shadow: 0 6px 18px rgba(59,130,246,.18); }
.type-card .icon { color: var(--blue); margin-bottom: 8px; line-height: 0; }
.type-card .icon svg { display: inline-block; }
.type-card .t-title { color: var(--navy); font-weight: 700; font-size: 1.1rem; margin: 10px 0 4px; }
.type-card .t-desc { color: var(--muted); font-size: .9rem; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; color: #2b3147; }
.field .help { font-weight: 400; color: var(--muted); font-size: .82rem; margin: 2px 0 6px; }
.req { color: var(--red); font-weight: 700; }
input[type=text], input[type=number], input[type=date], textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  font-size: .95rem; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
textarea { resize: vertical; min-height: 96px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row .field { flex: 1 1 200px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 10px; padding: 12px 18px; font-size: .95rem; font-weight: 600;
  cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-outline { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-outline:hover { background: #eff5ff; }
.btn-block { width: 100%; }
.btn svg { flex: none; vertical-align: middle; }
.btn-ghost { background: transparent; color: var(--blue); border: 0; padding: 6px 4px; cursor: pointer; font-weight: 600; font-size: .9rem; }
.btn-link { background: none; border: 0; color: var(--blue); cursor: pointer; font-weight: 600; font-size: .92rem; padding: 0; }

/* trash icon button */
.trash-btn { background: transparent; border: 0; cursor: pointer; color: var(--red); font-size: 1.1rem; line-height: 1; padding: 4px; border-radius: 6px; }
.trash-btn:hover { background: #fde8e8; }

/* Ticket photo / upload zones */
.ticket-box { border: 2px dashed #b9c2e0; border-radius: 12px; padding: 16px; background: #fafbff; margin-bottom: 14px; }
.ticket-box p { margin: 0 0 12px; color: var(--muted); font-size: .88rem; }

.dropzone { border: 2px dashed #b9c2e0; border-radius: 12px; padding: 26px; text-align: center; color: var(--muted);
  cursor: pointer; background: #fafbff; transition: border-color .12s, background .12s; }
.dropzone.dragover { border-color: var(--blue); background: #eff5ff; }
.dropzone .dz-icon { color: var(--muted); line-height: 0; margin-bottom: 6px; }
.file-list svg { vertical-align: -2px; color: var(--muted); flex: none; }
.trash-btn svg { display: block; }

.file-list { list-style: none; padding: 0; margin: 10px 0 0; }
.file-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: #f1f4fb; border-radius: 8px; padding: 7px 10px; font-size: .85rem; margin-top: 6px; }

/* Lot numbers highlighted box */
.lot-box { background: #eef2ff; border: 1px solid #c7d2fe; border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.lot-box .lot-heading { color: var(--navy); font-weight: 800; font-size: .82rem; letter-spacing: .04em; text-transform: uppercase; margin: 0 0 4px; }
.lot-box .lot-help { color: #4b5563; font-size: .84rem; margin: 0 0 12px; }
.lot-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.lot-row input { flex: 1; }

.po-card { border: 1px solid var(--border); border-radius: 14px; padding: 18px; margin-bottom: 16px; background: #fff; box-shadow: var(--shadow); }
.po-card .po-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.po-card .po-label { color: var(--navy); font-weight: 700; }

.back-link { background: none; border: 0; color: var(--blue); cursor: pointer; font-weight: 600; font-size: .92rem; padding: 0; margin-bottom: 14px; display: inline-flex; gap: 6px; }

/* Confirmation */
.confirm { text-align: center; padding: 40px 20px; }
.confirm .check { color: #16a34a; line-height: 0; }
.confirm h2 { color: var(--navy); margin: 12px 0 6px; }
.folio-badge { display: inline-block; background: var(--navy); color: #fff; font-size: 1.8rem; font-weight: 800;
  letter-spacing: .05em; padding: 12px 28px; border-radius: 12px; margin: 16px 0; }
.confirm-response { max-width: 520px; margin: 8px auto 0; background: #e6f7fb; color: #0e7490;
  border: 1px solid #bae6fd; border-radius: 10px; padding: 12px 16px; font-weight: 600; }
.confirm-followup { max-width: 520px; margin: 12px auto 0; background: #fff7ed; color: #9a3412;
  border: 1px solid #fed7aa; border-radius: 10px; padding: 12px 16px; font-size: .9rem; }

.hidden { display: none !important; }

/* ---------- Internal portal ---------- */
.login-wrap { max-width: 380px; margin: 60px auto; }
.login-wrap .card { padding: 28px; }
.alert { background: #fde8e8; color: #991b1b; border: 1px solid #f5c2c2; padding: 10px 12px; border-radius: 9px; font-size: .9rem; margin-bottom: 14px; }

table.tickets { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
table.tickets th, table.tickets td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: middle; }
table.tickets th { background: var(--navy); color: #fff; font-weight: 600; font-size: .82rem; }
table.tickets tr:hover td { background: #f7f9ff; }
table.tickets tr.clickable { cursor: pointer; }
table.tickets tr.row-mine td { background: #eef6ff; }
table.tickets tr.row-mine:hover td { background: #e2efff; }
table.tickets tr.row-mine td:first-child { box-shadow: inset 3px 0 0 var(--blue); }

/* Status traffic-light badge (read-only) */
.st-badge { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; }
.st-abierto { background: #dbeafe; color: #1d4ed8; }
.st-pausa { background: #fef3c7; color: #b45309; }
.st-cerrado { background: #dcfce7; color: #15803d; }

.readonly-field { padding: 10px 12px; background: #f1f4fb; border: 1px solid var(--border);
  border-radius: 9px; color: #334155; font-weight: 600; }

.notif-list { list-style: none; padding: 0; margin: 0; }
.notif-list li { display: flex; gap: 12px; align-items: flex-start; padding: 14px 4px; border-bottom: 1px solid var(--border); }
.notif-list li.unread { background: #eef6ff; border-radius: 8px; padding-left: 12px; padding-right: 12px; }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); margin-top: 6px; flex: none; }
.notif-dot.read { background: #cbd5e1; }
.notif-when { color: var(--muted); font-size: .8rem; }
.folio-link { color: var(--blue); font-weight: 700; text-decoration: none; }
.folio-link:hover { text-decoration: underline; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; }
.badge-type { background: #e8edff; color: var(--navy); }
.badge-area { background: #e6f7fb; color: #0e7490; }

.status-select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); font-size: .82rem; font-weight: 600; }
.status-abierto { color: #1d4ed8; }
.status-pausa { color: #b45309; }
.status-cerrado { color: #15803d; }

.days-pill { font-weight: 700; }
.days-neg { color: var(--red); }
.days-pos { color: #15803d; }
.days-warn { color: #b45309; }
.days-zero { color: var(--muted); }

/* Dashboard */
.dash-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.dash-card { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; background: #fff;
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; cursor: pointer;
  box-shadow: var(--shadow); text-align: left; transition: transform .1s, border-color .1s; font-family: inherit; }
.dash-card:hover { transform: translateY(-2px); border-color: var(--blue); }
.dash-num { font-size: 1.6rem; font-weight: 800; color: var(--navy); line-height: 1; }
.dash-label { font-size: .8rem; color: var(--muted); }
.dash-card.dash-danger .dash-num { color: var(--red); }
.dash-card.dash-mine { background: #eef6ff; }

/* Filter bar */
.filter-bar { padding: 14px 16px; }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-row input[type=search], .filter-row select { padding: 8px 10px; font-size: .88rem; }
.filter-row input[type=search] { flex: 1 1 240px; min-width: 200px; }
.filter-row select { flex: 0 0 auto; }
.filter-row-sub { margin-top: 10px; gap: 18px; }
.chk { font-size: .85rem; color: #2b3147; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.filter-count { margin-left: auto; color: var(--muted); font-size: .82rem; }

/* Priority select colors */
.prio-alta { color: #b91c1c; font-weight: 700; }
.prio-media { color: #b45309; font-weight: 600; }
.prio-baja { color: #475569; }

/* Priority badge (detail) */
.badge-prio-alta { background: #fee2e2; color: #b91c1c; }
.badge-prio-media { background: #ffedd5; color: #b45309; }
.badge-prio-baja { background: #e2e8f0; color: #475569; }

/* Comments / activity feed */
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.feed li:last-child { border-bottom: 0; }
.feed .feed-head { display: flex; gap: 8px; align-items: baseline; }
.feed .feed-author { font-weight: 700; color: var(--navy); font-size: .9rem; }
.feed .feed-when { color: var(--muted); font-size: .78rem; }
.feed .feed-body { margin-top: 2px; font-size: .92rem; }
.feed li.system { opacity: .9; }
.feed li.system .feed-author { color: var(--muted); font-weight: 600; }
.feed li.system .feed-body { color: #475569; font-style: italic; }

.detail-grid { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; }
.detail-grid dt { color: var(--muted); font-size: .85rem; }
.detail-grid dd { margin: 0; font-size: .92rem; }
.meta-bar { display: flex; gap: 18px; flex-wrap: wrap; align-items: end; }
.meta-bar .field { margin: 0; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #15803d; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; transition: opacity .25s; }
.toast.show { opacity: 1; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .detail-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .detail-grid dt { margin-top: 8px; }
  table.tickets { display: block; overflow-x: auto; white-space: nowrap; }
  .portal-title { font-size: 1rem; }
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-count { margin-left: 0; }
}
