:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #5d6978;
  --line: #d8dde5;
  --soft: #f4f6f8;
  --panel: #ffffff;
  --accent: #0d6b57;
  --accent-strong: #095444;
  --warning: #9a5b00;
  --danger: #a83b34;
  --class-bg: #fff2a8;
  --class-border: #f2b705;
  --class-ink: #1d2b3a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #edf1f4;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 38px;
  padding: 8px 12px;
}

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

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary,
.total-strip {
  display: grid;
  gap: 2px;
  min-width: 110px;
  text-align: right;
}

.summary span,
.total-strip span {
  color: var(--muted);
  font-size: 12px;
}

.summary strong {
  font-size: 28px;
}

.layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 91px;
  display: grid;
  gap: 16px;
}

.sidebar nav,
.status-panel,
.section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.sidebar nav {
  display: grid;
  overflow: hidden;
}

.sidebar a {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
}

.sidebar a:last-child {
  border-bottom: 0;
}

.sidebar a:hover {
  background: var(--soft);
}

.status-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
  color: var(--muted);
  font-size: 13px;
}

.content {
  display: grid;
  gap: 24px;
}

.section {
  padding: 20px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-actions {
  display: flex;
  justify-content: flex-end;
  margin: -6px 0 14px;
}

.split {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 10px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(13, 107, 87, 0.14);
}

.activity-groups {
  display: grid;
  gap: 14px;
}

.activity-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 10px;
  background: var(--soft);
}

.group-header strong {
  color: var(--accent-strong);
}

.activity-row {
  display: grid;
  grid-template-columns: 46px minmax(220px, 1fr) 72px 82px 82px 52px 52px;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  line-height: 1.25;
}

.activity-row.header {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.activity-row .code {
  color: var(--muted);
  font-weight: 700;
}

.activity-row .desc {
  min-width: 0;
}

.activity-row small {
  color: var(--muted);
  font-size: 11px;
}

.activity-row input {
  min-height: 28px;
  padding: 4px 6px;
  font-size: 13px;
}

.activity-row output {
  display: flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  font-size: 13px;
  font-weight: 700;
}

.activity-row.calculated {
  background: #fbfcfd;
}

.warning {
  grid-column: 2 / -1;
  color: var(--warning);
  font-size: 12px;
}

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

.import-box {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 12px;
}

.import-box summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 700;
}

.schedule-editor {
  width: 100%;
  border-collapse: collapse;
  min-width: 880px;
  font-size: 11px;
}

.schedule-editor th,
.schedule-editor td {
  border: 1px solid var(--line);
  padding: 5px;
  vertical-align: top;
}

.schedule-editor td.occupied-cell {
  background: var(--class-bg);
  border-color: var(--class-border);
}

.schedule-editor td.day-low {
  background: #fff0d8;
  border-color: #e28b27;
}

.schedule-editor td.day-high {
  background: #ffe4e1;
  border-color: #d75a50;
}

.schedule-editor td.day-ok.occupied-cell {
  background: #daf7e8;
  border-color: #28a46c;
}

.schedule-editor th {
  background: var(--soft);
  color: var(--muted);
  font-size: 10px;
  text-align: left;
}

.schedule-editor input {
  min-width: 110px;
  min-height: 28px;
  padding: 4px 6px;
  font-size: 11px;
}

.schedule-editor textarea {
  min-width: 128px;
  min-height: 68px;
  padding: 5px 6px;
  font-size: 11px;
  resize: vertical;
  white-space: pre-wrap;
}

.schedule-editor select {
  width: 100%;
  min-width: 128px;
  margin-top: 4px;
  min-height: 28px;
  padding: 4px 6px;
  font-size: 10px;
}

.schedule-editor td.occupied-cell textarea {
  border-color: var(--class-border);
  background: #fff8cf;
  color: var(--class-ink);
  font-weight: 700;
}

.schedule-editor td.day-low textarea {
  border-color: #e28b27;
  background: #fff7eb;
}

.schedule-editor td.day-high textarea {
  border-color: #d75a50;
  background: #fff1ef;
}

.schedule-period-header td {
  padding: 5px 8px;
  font-weight: 700;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-left: none;
  border-right: none;
}

.schedule-period-header.period-manha td {
  background: #fef6e0;
  border-top: 2px solid #d4961a;
  border-bottom: 1px solid #e8c456;
  color: #7a5800;
}

.schedule-period-header.period-tarde td {
  background: #e6f2fb;
  border-top: 2px solid #2d7bbf;
  border-bottom: 1px solid #6aaed6;
  color: #1a4e7a;
}

.schedule-period-header.period-noite td {
  background: #f0ebfa;
  border-top: 2px solid #6b3aad;
  border-bottom: 1px solid #a07dd0;
  color: #3d1a72;
}

.schedule-editor td.day-ok textarea {
  border-color: #28a46c;
  background: #effcf4;
}

.schedule-validation {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
}

.resolution-note {
  color: var(--warning);
}

.regime-alert {
  grid-column: 1 / -1;
  padding: 10px 14px;
  border-radius: 7px;
  border-left: 4px solid;
  font-size: 13px;
  line-height: 1.4;
}

.regime-alert-low {
  background: #fff4e0;
  border-color: #d4861a;
  color: #6b4200;
}

.regime-alert-high {
  background: #ffeaea;
  border-color: #c0392b;
  color: #6b1a1a;
}

.daily-badges,
.activity-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.daily-badge,
.activity-badge {
  display: grid;
  gap: 2px;
  min-width: 104px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.daily-badge span,
.activity-badge span {
  font-weight: 700;
}

.daily-badge em,
.activity-badge em {
  font-size: 12px;
  font-style: normal;
}

.daily-badge.ok,
.activity-badge.ok {
  border-color: #28a46c;
  background: #daf7e8;
}

.daily-badge.low,
.activity-badge.low {
  border-color: #e28b27;
  background: #fff0d8;
}

.daily-badge.high,
.activity-badge.high {
  border-color: #d75a50;
  background: #ffe4e1;
}

.daily-badge.empty {
  color: var(--muted);
}

.activity-badge {
  min-width: 190px;
}

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

.schedule-editor button {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--danger);
}

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

#outputHtml,
#ritOutputHtml {
  min-height: 180px;
  margin-bottom: 18px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.rit-grid,
.history-grid {
  margin-bottom: 18px;
}

.rit-grid textarea {
  min-height: 132px;
  resize: vertical;
}

.preview {
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview:empty {
  display: none;
}

.sei-doc {
  color: #000;
  font-family: "Times New Roman", Times, serif;
  font-size: 12pt;
}

.sei-doc table {
  border-collapse: collapse;
  margin-left: auto;
  margin-right: auto;
  width: 600px;
}

.sei-doc td,
.sei-doc th {
  border: 1px solid #000;
  padding: 3px 5px;
  vertical-align: middle;
}

.sei-doc .shade {
  background: #bbb;
  font-weight: 700;
  text-align: center;
}

.sei-doc .subshade {
  background: #ddd;
  font-weight: 700;
  text-align: center;
}

.sei-doc .right {
  text-align: right;
}

.sei-doc .center {
  text-align: center;
}

.sei-doc .title {
  text-align: center;
  text-transform: uppercase;
}

.sei-doc .note-list {
  width: 600px;
  margin: 12px auto 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 11pt;
}

.sei-doc .narrative {
  min-height: 140px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .activity-row {
    grid-template-columns: 48px minmax(0, 1fr) 78px 82px 82px;
  }

  .activity-row.header span:nth-child(6),
  .activity-row.header span:nth-child(7),
  .activity-row small,
  .activity-row output {
    display: none;
  }
}

@media (max-width: 720px) {
  .topbar,
  .split {
    align-items: stretch;
    flex-direction: column;
  }

  .summary,
  .total-strip {
    text-align: left;
  }

  .layout {
    padding: 14px;
  }

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