:root {
  color-scheme: light;
  --ui-ink: #132f32;
  --ui-muted: #5d7376;
  --ui-line: #c9dada;
  --ui-soft: #eef7f6;
  --ui-paper: #ffffff;
  --ui-brand: #0f766e;
  --ui-brand-dark: #0a4f4b;
  --ui-brand-soft: #dff3f0;
  --ui-warning: #b7791f;
  --ui-danger: #b23a2f;
  --ui-success: #1f9d55;
  --ui-info: #256d85;
  --ui-radius: 8px;
  --ui-shadow: 0 10px 28px rgba(19, 47, 50, .10);
  --ink: var(--ui-ink);
  --muted: var(--ui-muted);
  --line: var(--ui-line);
  --paper: var(--ui-paper);
  --soft: var(--ui-soft);
  --brand: var(--ui-brand);
  --brand-dark: var(--ui-brand-dark);
  --bad: var(--ui-danger);
  --danger: var(--ui-danger);
  --ok: var(--ui-success);
  --warn: var(--ui-warning);
  --shadow: var(--ui-shadow);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { background: #f5f8f8; }

body {
  margin: 0;
  color: var(--ui-ink);
  background: #f5f8f8;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.45;
}

[hidden] { display: none !important; }

button,
a.button,
.button,
.login-submit,
.session-button,
.menu-account-btn,
.back-menu-btn,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--ui-radius);
  padding: 9px 15px;
  color: #fff;
  background: var(--ui-brand);
  font: inherit;
  font-weight: 750;
  line-height: 1.15;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease, box-shadow .15s ease;
}

button:hover,
a.button:hover,
.button:hover,
.login-submit:hover,
.session-button:hover,
.menu-account-btn:hover,
.back-menu-btn:hover,
.file-button:hover {
  background: var(--ui-brand-dark);
  box-shadow: 0 6px 16px rgba(15, 118, 110, .18);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 109, 133, .25);
  outline-offset: 2px;
}

button:disabled,
.button:disabled {
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary,
.ghost,
button.secondary,
button.ghost,
a.secondary,
.menu-account-btn,
.session-button,
.back-menu-btn {
  border-color: #9fc0c2;
  color: var(--ui-brand-dark);
  background: #fff;
}

.secondary:hover,
.ghost:hover,
button.secondary:hover,
button.ghost:hover,
a.secondary:hover,
.menu-account-btn:hover,
.session-button:hover,
.back-menu-btn:hover {
  color: var(--ui-brand-dark);
  background: var(--ui-brand-soft);
  border-color: #77aaad;
}

.danger,
button.danger,
.remove,
button.remove {
  border-color: #e4aaa5;
  color: var(--ui-danger);
  background: #fff;
}

.danger:hover,
button.danger:hover,
.remove:hover,
button.remove:hover {
  color: #fff;
  background: var(--ui-danger);
  border-color: var(--ui-danger);
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #adc7c9;
  border-radius: var(--ui-radius);
  padding: 9px 11px;
  color: var(--ui-ink);
  background: #fff;
  font: inherit;
}

textarea { resize: vertical; }

input::placeholder,
textarea::placeholder { color: #6f8385; opacity: 1; }

input[readonly],
textarea[readonly],
select[disabled],
input[disabled],
textarea[disabled] {
  color: #4e6366;
  background: #eef4f4;
}

label {
  color: #28494d;
  font-weight: 750;
}

label:has(input[required])::after,
label:has(select[required])::after,
label:has(textarea[required])::after {
  content: "Obligatorio";
  justify-self: start;
  margin-top: -2px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--ui-brand-dark);
  background: var(--ui-brand-soft);
  font-size: .68rem;
  font-weight: 800;
}

.app-header,
.menu-header,
body > header {
  background: #0b5f64 !important;
  color: #fff;
  box-shadow: var(--ui-shadow);
}

.app-header img,
.menu-brand img,
body > header img {
  background: #fff;
  border-radius: 6px;
  padding: 4px;
  object-fit: contain;
}

.app-header h1,
.menu-header h1,
body > header h1 {
  letter-spacing: 0;
}

.app-shell,
.workspace,
.menu-shell,
main {
  max-width: 1220px;
}

.panel,
.card,
.auth-card,
.record-tools,
.history-card,
.chat-panel,
.manager-panel,
.context-panel,
.database-panel,
.result-doc-card,
section {
  border-radius: var(--ui-radius);
}

.panel,
.card,
.record-tools,
.history-card,
.manager-panel,
.context-panel,
.database-panel {
  border-color: var(--ui-line);
  background: var(--ui-paper);
}

.section-title p,
.eyebrow,
.auth-kicker {
  color: var(--ui-brand-dark);
  letter-spacing: .08em;
}

.actions,
.final-actions,
.step-actions,
.button-row,
.toolbar,
.preview-toolbar {
  gap: 10px;
}

.actions,
.final-actions {
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: rgba(255, 255, 255, .96);
}

table,
.results-table,
.doc-table {
  width: 100%;
  border-collapse: collapse;
}

th,
td,
.results-table th,
.results-table td,
.doc-table th,
.doc-table td {
  border-color: var(--ui-line);
  vertical-align: top;
}

th,
.results-table th,
.doc-table th {
  color: #143d41;
  background: #eaf3f2;
  font-weight: 850;
}

.table-wrap,
.results-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: #fff;
}

.badge,
.status-pill,
.completion-state,
.record-completion,
.result-status,
.result-semaphore strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: .76rem;
  font-weight: 850;
}

.complete,
.status-complete,
.status-firmado,
.status-terminado,
.status-firmado-terminado,
.result-semaphore-green strong {
  color: #0b5b35;
  background: #dff6e8;
}

.incomplete,
.pending,
.status-pending,
.status-pendiente,
.status-incomplete,
.result-semaphore-yellow strong {
  color: #7a4a08;
  background: #fff1c2;
}

.result-semaphore-red strong,
.status-error,
.status-rechazado {
  color: #842720;
  background: #ffe1dd;
}

#toast,
.toast,
.login-error:not(:empty) {
  border-radius: var(--ui-radius);
  font-weight: 800;
}

#toast {
  background: #173337;
}

.login-error:not(:empty),
.message-error {
  color: #fff;
  background: var(--ui-danger);
}

.ui-home-dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.ui-home-card {
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: #fff;
  box-shadow: 0 5px 18px rgba(19, 47, 50, .06);
}

.ui-home-card small {
  display: block;
  color: var(--ui-muted);
  font-size: .76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.ui-home-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.45rem;
}

.ui-home-card span {
  display: block;
  margin-top: 3px;
  color: var(--ui-muted);
  font-size: .86rem;
}

.home-activity {
  display: grid;
  grid-template-columns: minmax(220px, .7fr) minmax(0, 1.3fr);
  gap: 14px;
  align-items: start;
  margin: 0 0 18px;
  padding: 16px;
  border: 1px solid var(--ui-line);
  border-radius: var(--ui-radius);
  background: #fff;
}

.home-activity h2,
.home-activity p {
  margin: 0;
}

.home-recent-list {
  display: grid;
  gap: 8px;
}

.home-recent-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #dce8e8;
  border-radius: var(--ui-radius);
  background: #f9fcfc;
}

.home-recent-item strong,
.home-recent-item small {
  display: block;
}

.home-recent-item small {
  color: var(--ui-muted);
}

.home-recent-item span {
  justify-self: end;
}

.module-grid {
  align-items: stretch;
}

.module-card {
  border-radius: var(--ui-radius) !important;
}

@media (max-width: 900px) {
  .ui-home-dashboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-activity { grid-template-columns: 1fr; }
  .actions,
  .final-actions,
  .step-actions,
  .button-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 640px) {
  .ui-home-dashboard { grid-template-columns: 1fr; }
  button,
  a.button,
  .button,
  .login-submit,
  .session-button,
  .menu-account-btn,
  .back-menu-btn {
    width: 100%;
  }
}

@media print {
  .ui-home-dashboard { display: none !important; }
}
