@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg-base: #f4efe6;
  --bg-elevated: #faf7f0;
  --surface: #fffdf8;
  --surface-strong: #e6f0ea;
  --text-main: #26332f;
  --text-muted: #6f746f;
  --border: #d8c8b0;
  --border-strong: #a68a64;
  --primary: #2f5d50;
  --primary-hover: #1f3d35;
  --primary-contrast: #fffdf8;
  --accent: #7a5c3e;
  --success: #2f7d32;
  --success-soft: #e6f0ea;
  --danger: #b42318;
  --danger-soft: #f7e3df;
  --warning: #b7791f;
  --warning-soft: #f5ead7;
  --info: #3f7a63;
  --info-soft: #e6f0ea;
  --radius-sm: 8px;
  --radius-md: 8px;
  --radius-lg: 8px;
  --control-height: 2.65rem;
  --shadow-sm: 0 2px 10px rgba(31, 61, 53, 0.07);
  --shadow-md: 0 10px 28px rgba(31, 61, 53, 0.1);
  --focus-ring: 0 0 0 3px rgba(63, 122, 99, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg-base);
  color: var(--text-main);
  font-family: 'Open Sans', 'Segoe UI', sans-serif;
  line-height: 1.45;
}

.topbar,
.section-head,
.btn,
label,
thead th,
tbody td,
.status,
.presupuesto-ref,
.readonly-field,
.metric-card,
.metric-detail-list,
.timeline,
.detail-grid,
.message,
.panel-actions,
.crm-panel-kicker,
.crm-panel-header,
.crm-panel-content,
.auth-hero,
.auth-card {
  text-transform: uppercase;
}

input,
textarea,
select,
option,
.no-uppercase {
  text-transform: none;
}

a {
  color: var(--primary);
  text-underline-offset: 3px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.35rem, 2vw, 1.85rem);
  font-weight: 700;
}

h2 {
  font-size: clamp(1.12rem, 1.5vw, 1.35rem);
  font-weight: 700;
}

h3 {
  font-size: 1rem;
  font-weight: 700;
}

label {
  display: block;
  margin-bottom: 0.42rem;
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.92rem;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: var(--control-height);
  padding: 0.68rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-main);
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

textarea {
  min-height: calc(var(--control-height) * 2.2);
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}

input.input-error,
select.input-error,
textarea.input-error {
  border-color: var(--danger);
  background: #fff7f4;
}

.field-error label {
  color: var(--danger);
}

.field-error-message {
  margin: 0.32rem 0 0;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 700;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: var(--radius-sm);
  min-height: var(--control-height);
  padding: 0.64rem 1rem;
  transition: transform 120ms ease, background-color 120ms ease, color 120ms ease;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible,
.btn:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--control-height);
  gap: 0.4rem;
  font-weight: 700;
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
  border-radius: var(--radius-sm);
  padding: 0.64rem 1rem;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--primary-hover);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.64rem 1rem;
}

.btn-secondary:hover {
  background: #eadfcc;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--primary-contrast);
}

.btn-ghost:hover {
  background: rgba(255, 253, 248, 0.12);
  color: var(--primary-contrast);
}

.field {
  min-width: 0;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.message {
  min-height: 2.1rem;
  margin-top: 0.55rem;
  padding: 0.52rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
}

.message.info {
  background: var(--info-soft);
  color: var(--primary-hover);
}

.message.success {
  background: var(--success-soft);
  color: var(--success);
}

.message.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-success {
  background: var(--success-soft);
  color: var(--success);
}

.status-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-info {
  background: var(--info-soft);
  color: var(--info);
}

.status-neutral {
  background: #efe5d4;
  color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.is-hidden {
  display: none !important;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-strong);
  color: var(--primary-hover);
  font-size: 0.79rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

tbody td {
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid #eadfcc;
  vertical-align: top;
  font-size: 0.9rem;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: #f8f3ea;
}

@media (max-width: 760px) {
  body {
    font-size: 14px;
  }

  .table-wrap {
    overflow: visible;
    border: none;
    background: transparent;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tbody tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 0.7rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
  }

  tbody td {
    display: grid;
    grid-template-columns: minmax(112px, 40%) 1fr;
    gap: 0.6rem;
    padding: 0.62rem 0.75rem;
    border-bottom: 1px solid #eadfcc;
  }

  tbody td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }
}
