:root {
  --navy: #172554;
  --indigo: #4f46e5;
  --indigo-dark: #3730a3;
  --canvas: #f4f6fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #718096;
  --line: #e5e9f2;
  --danger: #dc2626;
  --amber: #d97706;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--navy);
  color: white;
  box-shadow: 0 8px 24px rgba(23,37,84,.16);
}
.topbar-inner {
  max-width: 760px;
  height: 78px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.12);
  font-weight: 800;
  letter-spacing: -.5px;
}
.brand h1 { margin: 0; font-size: 20px; }
.brand p { margin: 2px 0 0; color: #bfc8e6; font-size: 12px; }
.icon-button {
  border: 0;
  background: transparent;
  color: inherit;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 24px;
}
.topbar .icon-button:hover { background: rgba(255,255,255,.1); }
.dots { font-size: 16px; letter-spacing: 2px; }

.shell { max-width: 760px; margin: 0 auto; padding: 18px 16px 110px; }
.search-row { margin-bottom: 12px; }
.search-box {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  box-shadow: 0 4px 14px rgba(23,32,51,.04);
}
.search-box span { color: var(--muted); font-size: 19px; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; }

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.tab {
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  border-radius: 12px;
  height: 42px;
  font-weight: 700;
  font-size: 13px;
}
.tab span {
  min-width: 20px;
  height: 20px;
  margin-left: 3px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: #eef1f7;
  font-size: 11px;
}
.tab.active { color: white; border-color: var(--indigo); background: var(--indigo); }
.tab.active span { background: rgba(255,255,255,.18); }

.process-list { display: grid; gap: 12px; }
.process-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 6px 18px rgba(23,32,51,.055);
}
.process-card.urgent { border-left: 4px solid var(--amber); }
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.card-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.badge {
  border-radius: 999px;
  padding: 5px 8px;
  background: #eef1f7;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.badge.attention { background: #fff7df; color: #9a6700; }
.comarca { color: var(--muted); font-size: 12px; }
.card-actions { display: flex; gap: 2px; }
.card-actions button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #94a3b8;
  font-weight: 800;
}
.card-actions button:hover { background: #eef2ff; color: var(--indigo); }
.card-actions .delete:hover { background: #fff1f2; color: var(--danger); }
.process-card h2 { margin: 10px 0 4px; font-size: 17px; line-height: 1.25; }
.cnj-row { display: flex; align-items: center; gap: 5px; color: #64748b; font-family: Consolas, monospace; font-size: 12px; }
.copy-button { border: 0; background: transparent; color: #94a3b8; padding: 4px; }
.deadline { margin-top: 10px; color: #64748b; font-size: 12px; font-weight: 700; }
.deadline.overdue { color: var(--danger); }
.deadline.soon { color: var(--amber); }
.notes {
  margin-top: 12px;
  border-radius: 12px;
  background: #f7f8fb;
  border: 1px solid #edf0f5;
  padding: 10px 11px;
  color: #5d6678;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.process-card.urgent .notes { background: #fff5f5; border-color: #fee2e2; color: #b91c1c; }
.card-footer { display: grid; grid-template-columns: 1fr 44px; gap: 8px; margin-top: 14px; }
.open-button, .share-button {
  height: 48px;
  border: 0;
  border-radius: 12px;
  text-decoration: none;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
}
.open-button { background: var(--navy); color: white; }
.open-button:hover { background: #1e347b; }
.share-button { background: #ecfdf5; color: #12845a; border: 1px solid #d1fae5; }

.fab {
  position: fixed;
  right: max(20px, calc((100vw - 760px)/2));
  bottom: 24px;
  z-index: 25;
  width: 58px;
  height: 58px;
  border: 0;
  border-radius: 50%;
  background: var(--indigo);
  color: white;
  font-size: 34px;
  line-height: 1;
  box-shadow: 0 12px 28px rgba(79,70,229,.38);
}

.menu-panel {
  position: fixed;
  right: max(12px, calc((100vw - 760px)/2));
  top: 68px;
  z-index: 30;
  width: 210px;
  padding: 7px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(23,32,51,.16);
}
.menu-panel button {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 11px;
  text-align: left;
  color: #334155;
}
.menu-panel button:hover { background: #f3f4f8; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(15,23,42,.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal {
  width: min(620px, 100%);
  max-height: 92vh;
  overflow-y: auto;
  background: white;
  border-radius: 24px 24px 0 0;
  padding: 20px;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-header h2 { margin: 0; font-size: 20px; }
.process-form { display: grid; gap: 13px; }
.process-form label { color: #475569; font-size: 12px; font-weight: 800; }
.process-form input, .process-form textarea {
  width: 100%;
  margin-top: 6px;
  border: 1px solid #dfe4ed;
  border-radius: 11px;
  background: #fafbfc;
  color: var(--text);
  outline: 0;
  padding: 11px 12px;
}
.process-form input { height: 44px; }
.process-form textarea { resize: vertical; }
.process-form input:focus, .process-form textarea:focus { border-color: #818cf8; box-shadow: 0 0 0 3px #eef2ff; }
.quick-fill { background: #eef2ff; border: 1px solid #e0e7ff; border-radius: 12px; padding: 10px 12px; }
.quick-fill input { background: white; }
.two-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 11px;
  cursor: pointer;
}
.check-card input { width: 18px; height: 18px; margin: 0; accent-color: var(--amber); }
.check-card strong, .check-card small { display: block; }
.check-card small { margin-top: 2px; color: #a16207; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding-top: 4px; }
.btn { height: 46px; border: 0; border-radius: 12px; font-weight: 800; }
.btn-primary { background: var(--indigo); color: white; }
.btn-secondary { background: #eef1f5; color: #475569; }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; }
.confirm-card { width: min(380px, calc(100% - 32px)); margin: auto; background: white; border-radius: 20px; padding: 24px; text-align: center; }
.confirm-card h2 { margin: 0; }
.confirm-card p { color: var(--muted); margin: 8px 0 18px; }

.pin-screen { position: fixed; inset: 0; z-index: 100; background: var(--navy); align-items: center; justify-content: center; padding: 20px; }
.pin-screen:not(.hidden) { display: flex; }
.pin-card { width: min(340px, 100%); background: white; border-radius: 22px; padding: 28px; text-align: center; }
.pin-card .brand-mark { margin: 0 auto 16px; background: var(--navy); color: white; }
.pin-card h1 { margin: 0; font-size: 21px; }
.pin-card p { color: var(--muted); font-size: 13px; }
.pin-input { height: 52px; width: 100%; margin: 12px 0; border: 1px solid #dfe4ed; border-radius: 12px; text-align: center; font-size: 24px; letter-spacing: 8px; outline: 0; }
.text-button { border: 0; background: transparent; color: var(--danger); margin-top: 14px; font-size: 12px; }
.empty-state { text-align: center; padding: 50px 15px; color: var(--muted); }
.empty-icon { width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 50%; display: grid; place-items: center; background: #e8ebf2; font-size: 22px; }
.empty-state h2 { margin: 0; color: #475569; font-size: 16px; }
.empty-state p { margin: 6px 0; font-size: 13px; }
.toast {
  position: fixed;
  left: 50%;
  top: 18px;
  z-index: 110;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  border-radius: 999px;
  background: #1e293b;
  color: white;
  padding: 11px 16px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(15,23,42,.25);
}

@media (min-width: 700px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 24px; }
  .process-card { padding: 18px; }
}
