:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-strong: #eef3ef;
  --ink: #1d2521;
  --muted: #66736d;
  --line: #d9e0dc;
  --accent: #2f6f5e;
  --accent-strong: #194d41;
  --amber: #a56211;
  --red: #b3261e;
  --green: #247344;
  --blue: #2d5f9a;
  --shadow: 0 18px 50px rgba(29, 37, 33, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.top-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  display: grid;
  gap: 6px;
  line-height: 1.05;
}

.brand-name {
  display: block;
  color: var(--accent-strong);
  font-size: clamp(3rem, 7vw, 5.4rem);
  font-weight: 900;
}

.brand-subtitle {
  display: block;
  color: var(--ink);
  font-size: clamp(1.15rem, 2.1vw, 1.8rem);
  font-weight: 750;
}

h2 {
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.risk-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 220px;
  justify-content: center;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.risk-pill small {
  display: block;
  margin-bottom: 4px;
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.risk-pill strong {
  display: block;
  font-size: 1.45rem;
  line-height: 1;
}

.risk-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 5px rgba(102, 115, 109, 0.14);
}

.risk-pill.cumple .risk-dot {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(36, 115, 68, 0.18);
}

.risk-pill.medio .risk-dot {
  background: var(--blue);
  box-shadow: 0 0 0 5px rgba(45, 95, 154, 0.18);
}

.risk-pill.alto .risk-dot {
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(165, 98, 17, 0.2);
}

.risk-pill.critico .risk-dot {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(179, 38, 30, 0.2);
}

.risk-pill.cumple {
  border-color: rgba(36, 115, 68, 0.35);
  background: #e7f3eb;
  color: #14552c;
}

.risk-pill.medio {
  border-color: rgba(45, 95, 154, 0.35);
  background: #e7eef8;
  color: #193f72;
}

.risk-pill.alto {
  border-color: rgba(165, 98, 17, 0.35);
  background: #fff1dc;
  color: #754309;
}

.risk-pill.critico {
  border-color: rgba(179, 38, 30, 0.35);
  background: #fbe8e6;
  color: #7f1711;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric span,
.indicator-grid span {
  display: block;
  min-height: 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
}

.metric-highlight {
  border-color: rgba(165, 98, 17, 0.38);
  background: #fff7ec;
}

.metric-highlight strong {
  color: var(--amber);
  font-size: 1.85rem;
}

.metric-highlight.high strong {
  color: var(--red);
}

.risk-banner {
  display: grid;
  grid-template-columns: minmax(170px, 0.35fr) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface-strong);
}

.risk-banner span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 850;
  text-transform: uppercase;
}

.risk-banner strong {
  display: block;
  margin-top: 4px;
  font-size: 2.35rem;
  line-height: 1;
}

.risk-banner p {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.4;
}

.risk-banner.cumple {
  border-color: rgba(36, 115, 68, 0.35);
  background: #e7f3eb;
}

.risk-banner.medio {
  border-color: rgba(45, 95, 154, 0.35);
  background: #e7eef8;
}

.risk-banner.alto {
  border-color: rgba(165, 98, 17, 0.38);
  background: #fff1dc;
}

.risk-banner.critico {
  border-color: rgba(179, 38, 30, 0.35);
  background: #fbe8e6;
}

.risk-banner.cumple strong {
  color: var(--green);
}

.risk-banner.medio strong {
  color: var(--blue);
}

.risk-banner.alto strong {
  color: var(--amber);
}

.risk-banner.critico strong {
  color: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(520px, 1.5fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--accent-strong);
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--accent);
}

.primary-button,
.secondary-button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  border: 1px solid var(--accent-strong);
  background: var(--accent-strong);
  color: #fff;
}

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

.secondary-button,
.secondary-link {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent-strong);
}

.secondary-button:hover,
.secondary-link:hover {
  border-color: var(--accent);
}

.compact-link {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.language-toggle {
  gap: 6px;
  white-space: nowrap;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef6;
  color: var(--ink);
  padding: 0 11px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 94, 0.16);
}

.schedule-table {
  margin-top: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.save-status {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.save-status.ok {
  color: var(--green);
}

.save-status.error {
  color: var(--red);
}

.schedule-head,
.schedule-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr 0.8fr;
  gap: 0;
}

.schedule-head {
  background: var(--accent-strong);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.schedule-head span,
.schedule-row > * {
  min-width: 0;
  padding: 9px;
  border-right: 1px solid var(--line);
}

.schedule-head span:last-child,
.schedule-row > *:last-child {
  border-right: 0;
}

.schedule-row {
  align-items: center;
  border-top: 1px solid var(--line);
  background: #fff;
}

.schedule-row input {
  height: 36px;
  background: #fffef6;
}

.hours-value {
  color: var(--ink);
  font-weight: 800;
  text-align: right;
}

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

.company-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.company-strip span {
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

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

.indicator-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfb;
}

.indicator-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 1.25rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

td {
  font-size: 0.93rem;
}

.status {
  display: inline-flex;
  align-items: center;
  min-width: 92px;
  justify-content: center;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.78rem;
  font-weight: 850;
}

.status.ok {
  background: #e7f3eb;
  color: var(--green);
}

.status.fail {
  background: #fbe8e6;
  color: var(--red);
}

.costs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.65fr);
  gap: 16px;
  margin-top: 18px;
}

.cost-table td:nth-child(2),
.cost-table td:nth-child(3),
.cost-table th:nth-child(2),
.cost-table th:nth-child(3) {
  text-align: right;
}

.cost-table tr.overcost-row td {
  background: #fff7ec;
  color: #754309;
  font-size: 1rem;
  font-weight: 850;
}

.cost-table tr.overcost-row td:nth-child(2),
.cost-table tr.overcost-row td:nth-child(3) {
  font-size: 1.2rem;
}

.notes {
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #f8faf8;
  padding: 14px;
}

.notes p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.disclaimer {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px 16px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.intro-modal {
  width: min(560px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 0;
}

.intro-modal::backdrop {
  background: rgba(29, 37, 33, 0.34);
}

.intro-content {
  display: grid;
  gap: 14px;
  padding: 24px;
}

.intro-content p,
.intro-content li {
  color: var(--muted);
  line-height: 1.5;
}

.intro-content ol {
  margin: 0;
  padding-left: 22px;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(320px, 420px);
  gap: 28px;
  width: min(1040px, 100%);
  align-items: center;
}

.auth-brand span {
  display: block;
  color: var(--accent-strong);
  font-size: clamp(4rem, 10vw, 7rem);
  font-weight: 950;
  line-height: 0.95;
}

.auth-brand h1 {
  display: block;
  margin-top: 14px;
  max-width: 650px;
  font-size: clamp(1.4rem, 3vw, 2.25rem);
  line-height: 1.1;
}

.auth-brand p {
  margin-top: 16px;
  color: var(--muted);
  font-size: 1.05rem;
}

.login-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.form-error {
  min-height: 20px;
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 700;
}

.demo-access {
  display: grid;
  gap: 6px;
  margin-top: 16px;
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.table-scroll {
  overflow-x: auto;
}

.admin-table {
  min-width: 960px;
}

.admin-table td:nth-child(7),
.admin-table td:nth-child(8),
.admin-table td:nth-child(9),
.admin-table td:nth-child(10),
.admin-table td:nth-child(11),
.admin-table th:nth-child(7),
.admin-table th:nth-child(8),
.admin-table th:nth-child(9),
.admin-table th:nth-child(10),
.admin-table th:nth-child(11) {
  text-align: right;
}

.user-panel {
  margin-top: 18px;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(200px, 1fr) minmax(160px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 8px;
}

.user-table {
  margin-top: 14px;
}

.user-table th:nth-child(6),
.user-table td:nth-child(6) {
  text-align: right;
}

.full-field {
  grid-column: 1 / -1;
}

.compact-input {
  min-width: 140px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffef6;
  color: var(--ink);
  padding: 0 10px;
}

.row-actions {
  display: inline-flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 1060px) {
  .workspace,
  .costs-layout {
    grid-template-columns: 1fr;
  }

  .summary-grid,
  .indicator-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .risk-banner {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions > * {
    flex: 1;
  }

  .summary-grid,
  .indicator-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .schedule-head,
  .schedule-row {
    grid-template-columns: 1fr 1fr;
  }

  .schedule-head span:nth-child(4),
  .schedule-row .hours-value {
    border-right: 0;
  }
}

@media (max-width: 820px) {
  .auth-shell,
  .admin-summary,
  .user-form {
    grid-template-columns: 1fr;
  }
}
