:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e2ec;
  --navy: #123a63;
  --navy-2: #0b2d4f;
  --blue: #0f6cbd;
  --blue-2: #1d4ed8;
  --blue-soft: #e8f2ff;
  --cyan: #0891b2;
  --violet: #6d5dfc;
  --rose: #e11d48;
  --amber: #b7791f;
  --amber-soft: #fff4d6;
  --red: #b42318;
  --red-soft: #fee4e2;
  --green: #13795b;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  background: var(--navy-2);
  color: white;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: #ffffff;
  color: var(--navy);
  font-weight: 800;
  letter-spacing: 0;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.sidebar-heading {
  margin: -4px 6px 2px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-item {
  border: 0;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  padding: 12px 12px;
  border-radius: var(--radius);
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.icon {
  width: 22px;
  display: inline-grid;
  place-items: center;
}

.sidebar-card {
  margin-top: auto;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 16px;
}

.label,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-card .label,
.sidebar-card small {
  color: rgba(255, 255, 255, 0.68);
}

.sidebar-card strong {
  display: block;
  font-size: 30px;
  margin: 4px 0;
}

.workspace {
  min-width: 0;
  padding: 0 28px 36px;
}

.modulebar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  margin-bottom: 10px;
  background: rgba(244, 247, 251, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.module-item {
  min-height: 42px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--navy);
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 800;
}

.module-item:hover,
.module-item.active {
  background: white;
  border-color: var(--line);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

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

.topbar h1 {
  margin: 4px 0 0;
  font-size: 30px;
}

.eyebrow {
  margin: 0;
}

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

.role-switch {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding-left: 10px;
}

.role-switch span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.role-switch select {
  border: 0;
  min-height: 38px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 330px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.search-box span {
  color: var(--muted);
  font-size: 13px;
}

.search-box input {
  border: 0;
  outline: 0;
  min-width: 0;
  width: 100%;
}

select,
.ghost-button,
.primary-button,
.text-button {
  border-radius: var(--radius);
  min-height: 40px;
}

select {
  border: 1px solid var(--line);
  background: white;
  padding: 0 12px;
}

.primary-button,
.ghost-button,
.text-button {
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--blue);
  color: white;
}

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

.ghost-button {
  background: white;
  border-color: var(--line);
  color: var(--navy);
}

.text-button {
  background: transparent;
  color: var(--blue);
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.kpi-card,
.panel,
.table-card,
.course-card,
.report-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi-card {
  padding: 16px;
  min-height: 118px;
  display: grid;
  align-content: space-between;
}

.kpi-card strong {
  font-size: 30px;
}

.kpi-card small {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

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

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

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

.dashboard-grid,
.settings-grid {
  display: grid;
  grid-template-columns: 1.15fr 1.15fr 0.9fr;
  gap: 16px;
}

.span-2 {
  grid-column: span 2;
}

.panel {
  padding: 18px;
}

.panel-header,
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel h2,
.section-header h2 {
  margin: 0;
  font-size: 18px;
}

.panel p,
.section-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.bar-chart {
  height: 240px;
  display: flex;
  align-items: end;
  gap: 18px;
  padding: 22px 4px 0;
}

.bar-month {
  flex: 1;
  display: grid;
  align-items: end;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  min-width: 44px;
  height: 190px;
  position: relative;
}

.bar {
  border-radius: 6px 6px 0 0;
}

.bar.up {
  background: linear-gradient(180deg, #38bdf8 0%, var(--blue) 100%);
}

.bar.down {
  background: linear-gradient(180deg, #fb7185 0%, var(--rose) 100%);
}

.bar-month span {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 12px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 18px;
}

.donut {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: conic-gradient(var(--blue) 0 38%, var(--cyan) 38% 64%, #f59e0b 64% 82%, var(--violet) 82% 94%, #94a3b8 94% 100%);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 34px;
  background: white;
  border-radius: 50%;
}

.legend {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
  color: var(--muted);
}

.legend b {
  color: var(--ink);
}

.task-list,
.template-list,
.timeline,
#custom-fields,
#roles-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.task-row,
.template-row,
.timeline-row,
.field-row,
.role-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.task-row strong,
.template-row strong,
.field-row strong,
.role-row strong {
  display: block;
}

.task-row small,
.template-row small,
.timeline-row small,
.field-row small,
.role-row small {
  color: var(--muted);
}

.quick-actions,
.utility-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.action-tile {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--navy);
  border-radius: var(--radius);
  min-height: 70px;
  padding: 12px;
  text-align: left;
  font-weight: 800;
}

.section-header {
  margin-bottom: 16px;
}

.button-row,
.filters {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filters {
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.filter-chip {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
}

.filter-chip.active {
  background: var(--navy);
  color: white;
  border-color: var(--navy);
}

.table-card {
  overflow: hidden;
}

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

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

th {
  background: #eef3f8;
  color: var(--navy);
  font-size: 13px;
}

td {
  font-size: 14px;
}

.row-action {
  border: 0;
  background: var(--blue-soft);
  color: var(--blue-2);
  border-radius: 6px;
  padding: 7px 10px;
  font-weight: 800;
}

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

.course-grid,
.report-grid,
.catalog-grid,
.utility-panel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.course-card,
.report-card,
.catalog-card,
.utility-card {
  padding: 18px;
}

.course-card h3,
.report-card h3,
.catalog-card h3,
.utility-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.catalog-card,
.utility-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.permission-note {
  display: none;
  margin: 0 0 16px;
  background: var(--amber-soft);
  color: var(--amber);
  border: 1px solid #f6d38b;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 800;
}

body.role-gestor .admin-only {
  opacity: 0.42;
  pointer-events: none;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.meta {
  background: var(--panel-2);
  border-radius: var(--radius);
  padding: 10px;
}

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

.meta strong {
  display: block;
  margin-top: 2px;
}

.communication-layout {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(720px, 100%);
  border: 0;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.25);
}

.modal::backdrop {
  background: transparent;
}

.modal-close {
  position: absolute;
  right: 16px;
  top: 12px;
  border: 0;
  background: transparent;
  font-size: 26px;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.checkbox-line {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 10px !important;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.checkbox-line input {
  width: auto !important;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: white;
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.field-preview {
  margin-top: 14px;
  padding: 14px;
  background: var(--panel-2);
  border: 1px dashed var(--blue);
  border-radius: var(--radius);
}

.field-preview strong {
  display: block;
  margin-bottom: 10px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: var(--navy-2);
  color: white;
  padding: 14px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .brand div:not(.brand-mark),
  .nav-item:not(.active) {
    font-size: 0;
  }

  .nav-item {
    justify-content: center;
  }

  .sidebar-card {
    display: none;
  }

  .kpi-grid,
  .course-grid,
  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .settings-grid,
  .communication-layout {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

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

  .topbar-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
  }

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

  .nav-item:not(.active) {
    font-size: 14px;
  }

  .workspace {
    padding: 18px;
  }

  .kpi-grid,
  .course-grid,
  .report-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .search-box {
    min-width: 100%;
  }

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