:root {
  color-scheme: light;
  --bg: #eef2f5;
  --panel: #ffffff;
  --ink: #1f252b;
  --muted: #68737d;
  --line: #d6dee5;
  --green: #23704d;
  --green-soft: #e5f3eb;
  --amber: #a86400;
  --amber-soft: #fff1d8;
  --red: #b73535;
  --red-soft: #ffe4e0;
  --blue: #245f91;
  --blue-soft: #e5f0f9;
  --input: #fffbe6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

.app-shell {
  min-height: 100vh;
  padding: 22px;
}

.access-gate {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 22px;
}

.access-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 14px 40px rgba(31, 37, 43, 0.11);
  display: grid;
  gap: 12px;
  margin: 0 auto;
  max-width: 430px;
  padding: 22px;
  width: 100%;
}

.access-card p {
  color: var(--muted);
  margin-top: 5px;
}

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

.topbar-actions {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.user-chip {
  align-self: center;
  background: var(--blue-soft);
  border: 1px solid #c5dced;
  border-radius: 999px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  max-width: 280px;
  overflow: hidden;
  padding: 7px 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  font-weight: 720;
  line-height: 1.15;
}

h2 {
  font-size: 16px;
  margin-bottom: 12px;
}

.topbar p {
  color: var(--muted);
  margin-top: 5px;
}

.specialty-picker {
  min-width: 260px;
}

.range-controls,
.form-actions,
.table-toolbar,
.legend,
.row-actions,
.mini-rules,
.admin-login,
.tabs {
  align-items: center;
  display: flex;
  gap: 10px;
}

.range-controls {
  flex-wrap: wrap;
  justify-content: flex-end;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  gap: 5px;
}

input,
select,
textarea {
  background: var(--input);
  border: 1px solid #ccc89f;
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  min-height: 36px;
  padding: 7px 9px;
  width: 100%;
}

textarea {
  resize: vertical;
}

button,
.button-secondary {
  align-items: center;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 650;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  text-decoration: none;
  white-space: nowrap;
}

.button-secondary {
  background: white;
  color: var(--green);
}

.danger-button {
  background: white;
  border-color: var(--red);
  color: var(--red);
}

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

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

.public-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 360px;
  margin-bottom: 16px;
}

.request-panel {
  border-color: #b7d9c3;
}

.admin-login-panel {
  align-self: start;
}

.admin-login {
  align-items: end;
  flex-wrap: wrap;
}

.admin-login label {
  flex: 1 1 180px;
}

.admin-area {
  display: grid;
  gap: 16px;
}

.public-planning,
.public-requests {
  margin-bottom: 16px;
}

.admin-toolbar {
  padding: 12px 16px;
}

.tabs {
  flex-wrap: wrap;
  padding: 10px;
}

.tab-button {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.tab-button.is-active {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.tab-panel {
  display: grid;
  gap: 16px;
}

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

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

.metric {
  padding: 13px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.metric strong {
  display: block;
  font-size: 28px;
  margin-top: 3px;
}

.metric.warn strong {
  color: var(--amber);
}

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

.panel {
  padding: 16px;
}

.collapsible-toggle {
  background: #f6f8fa;
  border-color: var(--line);
  color: var(--ink);
  font-size: 15px;
  justify-content: space-between;
  margin-bottom: 12px;
  width: 100%;
}

.collapsible-toggle:hover {
  border-color: #aeb8c2;
}

.collapsible-marker {
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-weight: 800;
  margin-left: 12px;
}

.panel.is-collapsed > .collapsible-body {
  display: none;
}

.table-toolbar .collapsible-toggle {
  margin-bottom: 0;
  max-width: 340px;
}

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

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

.raw-source-panel {
  grid-column: 1 / -1;
}

.raw-search {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin: 12px 0;
}

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

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

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

.wide {
  grid-column: 1 / -1;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
  padding: 10px;
}

.notice.good {
  background: var(--green-soft);
  border-color: #b6d8c4;
}

.notice.danger {
  background: var(--red-soft);
  border-color: #efb6af;
}

.mini-rules {
  background: #f6f8fa;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  flex-wrap: wrap;
  font-size: 13px;
  margin-top: 12px;
  padding: 10px;
}

.muted {
  color: var(--muted);
}

.table-toolbar {
  justify-content: space-between;
  margin-bottom: 10px;
}

.legend {
  color: var(--muted);
  flex-wrap: wrap;
  font-size: 13px;
}

.dot {
  border-radius: 999px;
  display: inline-block;
  height: 10px;
  margin-left: 6px;
  width: 10px;
}

.dot.ok {
  background: var(--green);
}

.dot.risk {
  background: var(--amber);
}

.dot.conflict {
  background: var(--red);
}

.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

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

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

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

th {
  background: #e7edf2;
  color: #36424d;
  font-size: 12px;
  position: sticky;
  top: 0;
  z-index: 1;
}

td {
  background: white;
}

tr:last-child td {
  border-bottom: 0;
}

.status {
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 750;
  padding: 4px 8px;
}

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

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

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

.stack {
  display: grid;
  gap: 6px;
}

.pill {
  background: var(--blue-soft);
  border-radius: 999px;
  color: var(--blue);
  display: inline-block;
  font-size: 12px;
  margin: 0 4px 4px 0;
  padding: 3px 7px;
}

.issue {
  border-radius: 6px;
  font-size: 12px;
  padding: 6px 8px;
}

.issue.conflicto {
  background: var(--red-soft);
  color: var(--red);
}

.issue.riesgo {
  background: var(--amber-soft);
  color: var(--amber);
}

.item-list,
.source-summary,
.source-list {
  display: grid;
  gap: 8px;
}

.list-item,
.source-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
}

.list-item {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.row-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.row-actions button {
  min-height: 32px;
  padding: 5px 9px;
}

.state-label {
  font-weight: 700;
}

.source-list {
  max-height: 390px;
  overflow: auto;
  padding-right: 4px;
}

.source-item.bad {
  background: var(--red-soft);
  border-color: #f1b7b0;
}

.source-item.good {
  background: var(--green-soft);
  border-color: #b7d9c3;
}

.source-path,
.source-note {
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

code {
  background: #f1f4f7;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #1e4d76;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
  padding: 5px 8px;
}

@media (max-width: 1180px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .work-grid,
  .bottom-grid,
  .public-grid,
  .input-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell,
  .access-gate {
    padding: 14px;
  }

  .topbar,
  .topbar-actions,
  .range-controls,
  .form-actions {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr;
  }

  .user-chip {
    max-width: 100%;
  }

  .summary-grid,
  .public-summary-grid,
  .form-grid,
  .raw-search {
    grid-template-columns: 1fr;
  }

  .list-item {
    grid-template-columns: 1fr;
  }

  .row-actions {
    justify-content: flex-start;
  }
}
