:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #566573;
  --brand: #0f6b48;
  --brand-strong: #0a4f35;
  --line: #d8dee6;
  --error: #9f1d1d;
}

* { box-sizing: border-box; }

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

.site-header {
  background: #102f25;
  color: #ffffff;
}

.topbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
}

.brand,
.site-header a {
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
}

.account-nav,
.main-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-nav a,
.login-link,
.main-nav a {
  border-radius: 6px;
  padding: 8px 10px;
}

.account-nav a:hover,
.account-nav a:focus,
.account-nav a.active,
.login-link:hover,
.login-link:focus,
.main-nav a:hover,
.main-nav a:focus,
.main-nav a.active {
  background: rgba(255, 255, 255, 0.14);
}

.main-nav {
  min-height: 42px;
  justify-content: flex-start;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0 24px;
  background: #12382d;
}

.main-nav .menu-right {
  margin-left: auto;
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 28px auto;
}

.panel {
  max-width: 760px;
  margin: 12vh auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: var(--panel);
}

.wide-panel {
  max-width: 1180px;
  margin-top: 4vh;
}

.form-panel {
  max-width: 960px;
  margin-top: 4vh;
}

.login-panel {
  max-width: 420px;
}

.admin-panel {
  max-width: 960px;
  margin-top: 4vh;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.7rem;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-heading h1 {
  margin-top: 0;
}

.table-wrap {
  width: 100%;
  margin-top: 18px;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  table-layout: auto;
}

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

th {
  color: #304255;
  font-size: 0.86rem;
}

th a {
  color: #304255;
  text-decoration: none;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sort-link span {
  color: var(--brand-strong);
  font-size: 0.72rem;
  font-weight: 800;
}

td span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.meta-row td {
  padding-top: 0;
  background: #fbfcfd;
}

.meta-row span {
  margin: 0;
  color: #647484;
  font-size: 0.86rem;
  word-break: break-word;
}

code {
  display: inline-block;
  border-radius: 5px;
  padding: 4px 7px;
  background: #eef3f0;
  color: #0c5137;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
}

form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

label {
  font-weight: 700;
  color: #304255;
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  background: #ffffff;
}

input[type="search"] {
  min-width: min(100%, 320px);
}

select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  background: #ffffff;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.filter-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 190px) auto auto;
  gap: 10px;
  align-items: end;
  margin-top: 18px;
}

.result-summary {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 8px 13px;
  background: var(--brand);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.button.disabled,
.button.disabled:hover,
.button.disabled:focus {
  opacity: 0.55;
  pointer-events: none;
}

.button.small,
button.small {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 0.9rem;
  white-space: nowrap;
}

.button.secondary,
button.secondary {
  background: #e8eef5;
  color: #304255;
}

.button.danger,
button.danger {
  background: #b42318;
}

.button:hover,
.button:focus,
button:hover,
button:focus {
  background: var(--brand-strong);
}

.button.secondary:hover,
.button.secondary:focus,
button.secondary:hover,
button.secondary:focus {
  background: #dbe4ee;
}

.button.danger:hover,
.button.danger:focus,
button.danger:hover,
button.danger:focus {
  background: #981b1b;
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.help-panel {
  max-width: 1040px;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 26px;
  margin-top: 24px;
}

.help-grid section {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.help-grid h2 {
  margin: 0 0 8px;
  color: #102f25;
  font-size: 1.08rem;
}

.help-grid p {
  margin: 0 0 10px;
}

.help-grid ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.help-grid li + li {
  margin-top: 5px;
}

.admin-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.admin-subnav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  padding: 8px 13px;
  background: #eef3f0;
  color: var(--brand-strong);
  font-weight: 700;
  text-decoration: none;
}

.admin-subnav a:hover,
.admin-subnav a:focus {
  border-color: #a8c3b7;
  background: #e2eee8;
}

.content-settings {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.content-settings h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.content-settings p {
  margin: 0;
}

.scenario-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.scenario-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfd;
  color: var(--ink);
  text-decoration: none;
}

.scenario-card:hover,
.scenario-card:focus-within {
  border-color: #a8c3b7;
  background: #f4faf7;
}

.scenario-card strong {
  color: var(--ink);
  font-size: 1.05rem;
}

.scenario-card span {
  color: var(--muted);
  line-height: 1.35;
}

.scenario-status {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf6f2;
  color: var(--brand-strong) !important;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.scenario-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.scenario-manage {
  max-width: 1180px;
  margin-top: 4vh;
}

.manage-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
}

.manage-direction {
  margin-top: 28px;
}

.manage-direction h2 {
  margin: 0 0 12px;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 8px;
  color: #102f25;
  font-size: 1.05rem;
}

.manage-scenario-table {
  min-width: 940px;
}

.manage-turno {
  background: #f6faf8;
  color: var(--brand-strong);
  font-weight: 800;
}

.manage-stop-list {
  margin: 8px 0 0;
  padding-left: 20px;
}

.manage-stop-list li {
  margin-bottom: 6px;
}

.record-value-link {
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
}

.record-value-link:hover,
.record-value-link:focus {
  color: var(--brand-strong);
  text-decoration: underline;
}

.record-context-link {
  display: inline-block;
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.record-context-link:hover,
.record-context-link:focus {
  color: var(--brand-strong);
  text-decoration: underline;
}

.record-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.record-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf2f7;
  color: #304255;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

a.record-chip:hover,
a.record-chip:focus {
  background: #dbe4ee;
  color: var(--brand-strong);
}

.scenario-document {
  max-width: 1180px;
  margin-top: 4vh;
}

.scenario-note {
  margin: 16px 0 0;
  border-left: 4px solid var(--brand);
  padding: 10px 12px;
  background: #f6faf8;
  color: #304255;
}

.scenario-direction {
  margin-top: 28px;
}

.scenario-direction h2 {
  margin: 0 0 12px;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 8px;
  color: #102f25;
  font-size: 1.05rem;
  text-transform: uppercase;
}

.scenario-route-list {
  display: grid;
  gap: 10px;
}

.scenario-route-row {
  display: grid;
  grid-template-columns: 90px minmax(220px, 280px) minmax(0, 1fr);
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.scenario-route-time {
  display: grid;
  gap: 5px;
  align-content: start;
}

.scenario-route-time strong {
  color: #102f25;
  font-size: 1.2rem;
}

.scenario-route-time span {
  width: fit-content;
  border-radius: 999px;
  padding: 3px 7px;
  background: #eef3f0;
  color: #375646;
  font-size: 0.8rem;
  font-weight: 700;
}

.scenario-route-title h3 {
  margin: 0;
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.35;
}

.scenario-route-title p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.scenario-route-stops ol {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 22px;
}

.scenario-route-stops li {
  padding-left: 3px;
  line-height: 1.35;
}

.scenario-route-stops strong {
  color: var(--ink);
}

.scenario-route-stops span,
.scenario-route-stops small {
  display: inline;
  color: var(--muted);
}

.scenario-route-stops span::before {
  content: " (";
}

.scenario-route-stops span::after {
  content: ")";
}

.scenario-route-stops small {
  display: block;
  margin-top: 1px;
}

.route-stop-warning {
  margin: 0;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff7ed;
  color: #8a4b0f;
}

.drupal-preview {
  margin-top: 24px;
  overflow-x: auto;
}

.drupal-preview .table {
  width: 100%;
  min-width: 760px;
  margin: 0 0 24px;
  border-collapse: collapse;
  background: #ffffff;
}

.drupal-preview .table-bordered td {
  border: 1px solid #cfd8e3;
}

.drupal-preview .table-striped tr:nth-child(even) {
  background: #f8fafc;
}

.drupal-preview .table-hover tr:hover {
  background: #eef7f2;
}

.drupal-preview td {
  padding: 10px;
  vertical-align: top;
}

.drupal-preview h4,
.drupal-preview h5 {
  margin: 0;
  color: var(--ink);
}

.drupal-preview ol {
  margin: 0;
  padding-left: 22px;
}

.drupal-preview li {
  margin: 0 0 4px;
  line-height: 1.35;
}

.rtecenter {
  text-align: center;
  vertical-align: middle;
}

.rteleft {
  text-align: left;
}

.compact-heading h2 {
  margin: 0 0 6px;
  font-size: 1.2rem;
}

.compact-heading p {
  margin: 0;
}

.content-separator {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 16px 0 22px;
}

.preview-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.preview-actions .copy-feedback {
  flex-basis: 100%;
  text-align: right;
}

.copy-source {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.html-content-editor textarea {
  min-height: 460px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.4;
}

.copy-feedback {
  display: block;
  min-height: 22px;
  margin: 0;
  color: var(--brand-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions {
  flex-wrap: nowrap;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

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

.field {
  display: grid;
  gap: 6px;
  align-content: start;
}

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

.span-1 { grid-column: span 1; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: 1 / -1; }

.field-help {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.empty-state {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
}

.empty-state p {
  margin-bottom: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill.yes {
  background: #edf6f2;
  color: var(--brand-strong);
}

.status-pill.no {
  background: #f1f4f7;
  color: #5b6978;
}

.empty-value {
  color: #8a97a5;
}

.text-link {
  color: var(--brand-strong);
  font-weight: 700;
  text-decoration: none;
}

.text-link:hover,
.text-link:focus {
  text-decoration: underline;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.pagination span {
  color: var(--muted);
  font-size: 0.92rem;
}

.alert {
  margin: 12px 0;
  border: 1px solid #efb3b3;
  border-radius: 6px;
  padding: 10px;
  background: #fdecec;
  color: var(--error);
}

.success-alert {
  margin: 12px 0;
  border: 1px solid #8fc8aa;
  border-radius: 6px;
  padding: 10px;
  background: #edf8f1;
  color: var(--brand-strong);
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 16px;
  }

  .account-nav,
  .main-nav {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .main-nav {
    padding: 8px 16px;
  }

  .main-nav .menu-right {
    margin-left: 0;
  }

  .filter-form {
    grid-template-columns: 1fr;
  }

  .scenario-route-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .pagination {
    align-items: flex-start;
    flex-direction: column;
  }

  .page {
    width: min(100vw - 20px, 920px);
    margin: 14px auto;
  }

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

  .span-1,
  .span-2,
  .span-3,
  .span-4,
  .span-5,
  .span-6 {
    grid-column: 1 / -1;
  }

  .panel {
    margin-top: 8vh;
    padding: 18px;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }
}

/* Demandas */
.demand-list-panel,
.demand-detail,
.time-panel {
  box-shadow: 0 8px 30px rgba(16, 47, 37, 0.06);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 22px;
}

.summary-card {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #f8fbfa;
}

.summary-card strong {
  color: var(--brand-strong);
  font-size: 1.3rem;
}

.summary-card span {
  color: var(--muted);
  font-size: 0.85rem;
}

.timer-banner,
.active-timer-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  border: 1px solid #8fc8aa;
  border-radius: 9px;
  padding: 13px 15px;
  background: #edf8f1;
}

.timer-banner div,
.active-timer-card div {
  display: grid;
  gap: 3px;
}

.timer-banner a {
  color: var(--brand-strong);
  font-weight: 700;
  text-decoration: none;
}

.live-duration {
  color: var(--brand-strong);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}

.demand-filter {
  grid-template-columns: minmax(200px, 1.5fr) repeat(3, minmax(145px, 0.7fr)) auto auto;
}

.demand-title {
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.demand-title:hover,
.demand-title:focus {
  color: var(--brand);
  text-decoration: underline;
}

.blocked-reason {
  color: #8a5900 !important;
}

.priority-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.priority-urgente { background: #fce8e6; color: #a61b12; }
.priority-alta { background: #fff1db; color: #8a4b00; }
.priority-normal { background: #e7f0fb; color: #245b91; }
.priority-baixa { background: #edf1ef; color: #52615a; }
.status-pendente { background: #edf1ef; color: #52615a; }
.status-em_andamento { background: #e3f3ec; color: #0a6743; }
.status-concluida { background: #e4f2ff; color: #215b8f; }
.status-cancelada { background: #f2e9e9; color: #765050; }
.status-blocked { background: #fff3d6; color: #805600; }

.dependency-fieldset {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.dependency-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.check-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  cursor: pointer;
}

.check-option:hover { background: #f6faf8; }
.check-option input { width: auto; min-height: auto; margin-top: 3px; }
.check-option span { display: grid; gap: 2px; }
.check-option small { color: var(--muted); font-weight: 400; }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.empty-inline { margin: 4px 0 0; color: var(--muted); }

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-row { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; margin-top: 24px; }
.detail-section { border-top: 1px solid var(--line); padding-top: 18px; }
.detail-section + .detail-section { margin-top: 24px; }

.compact-section {
  margin: 0 0 16px !important;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  background: #fafcfb;
}

.prose { color: #34443d; line-height: 1.65; }
.relation-list { display: grid; gap: 7px; }

.relation-list a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  color: var(--ink);
  text-decoration: none;
}

.relation-list a:hover { border-color: #9ab9aa; background: #f4f9f7; }
.relation-list strong { color: var(--muted); font-size: 0.82rem; }
.stack-actions { display: grid; gap: 8px; }
.stack-actions .inline-form,
.stack-actions button { width: 100%; }
.detail-meta dl { display: grid; gap: 11px; margin: 14px 0 0; }
.detail-meta dl div { display: grid; gap: 2px; }
.detail-meta dt { color: var(--muted); font-size: 0.8rem; }
.detail-meta dd { margin: 0; font-weight: 650; word-break: break-word; }

.time-panel { margin-top: 18px; }
.time-total { color: var(--brand-strong); font-size: 1.35rem; }
.active-timer-card form { margin: 0; }

.timer-start-form {
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #f8fbfa;
}

.manual-time-entry {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.manual-time-entry summary {
  color: var(--brand-strong);
  font-weight: 750;
  cursor: pointer;
}

.notice {
  margin: 14px 0;
  border: 1px solid #bdd4c9;
  border-radius: 7px;
  padding: 11px 13px;
  background: #f1f8f5;
  color: #305647;
}

.notice.warning { border-color: #e8cf91; background: #fff8e8; color: #775000; }

@media (max-width: 900px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .demand-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-sidebar { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
}

@media (max-width: 640px) {
  .summary-grid,
  .demand-filter,
  .dependency-options,
  .detail-sidebar,
  .timer-start-form { grid-template-columns: 1fr; }

  .timer-banner,
  .active-timer-card { align-items: flex-start; flex-direction: column; }
}

