:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --ink: #17211f;
  --muted: #60706b;
  --line: #dce4df;
  --primary: #0b6b57;
  --primary-strong: #084d40;
  --primary-deep: #092d27;
  --accent: #c78a22;
  --accent-soft: #f1c66b;
  --blue: #2c6fbb;
  --rose: #b24b63;
  --shadow: 0 18px 45px rgba(22, 37, 34, 0.12);
}

* {
  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;
}

body:not(.is-authenticated) {
  background:
    linear-gradient(135deg, rgba(8, 28, 24, 0.96), rgba(18, 60, 52, 0.98)),
    #0d211d;
}

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

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-screen {
  align-items: center;
  display: grid;
  gap: clamp(28px, 7vw, 96px);
  grid-template-columns: minmax(320px, 0.95fr) minmax(340px, 440px);
  min-height: 100vh;
  overflow: auto;
  padding: clamp(18px, 5vw, 64px);
  position: relative;
}

.login-screen::before {
  background:
    linear-gradient(135deg, transparent 0 54%, rgba(255, 255, 255, 0.05) 54% 100%),
    linear-gradient(90deg, rgba(241, 198, 107, 0.12), rgba(44, 111, 187, 0.08));
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.login-visual {
  color: #ffffff;
  display: grid;
  gap: 34px;
  min-height: auto;
  position: relative;
  z-index: 1;
}

.login-brand {
  align-items: flex-start;
  animation: fadeUp 680ms ease both;
  display: flex;
  gap: 18px;
  max-width: 720px;
  position: relative;
}

.login-brand strong {
  display: block;
  font-size: clamp(3.4rem, 9vw, 7.5rem);
  letter-spacing: 0;
  line-height: 0.82;
  text-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.login-brand small {
  color: rgba(255, 255, 255, 0.78);
  display: block;
  font-size: 1rem;
  margin-top: 10px;
  max-width: 620px;
}

.login-brand::after {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  content: "";
  height: 1px;
  left: 0;
  position: absolute;
  top: calc(100% + 28px);
  width: min(44vw, 520px);
}

.login-copy {
  animation: fadeUp 760ms 80ms ease both;
  border-left: 4px solid var(--accent-soft);
  color: rgba(255, 255, 255, 0.82);
  display: grid;
  gap: 8px;
  margin-top: clamp(26px, 8vw, 92px);
  max-width: 520px;
  padding-left: 18px;
}

.login-copy p {
  color: #ffffff;
  font-size: clamp(1.35rem, 3vw, 2.2rem);
  font-weight: 800;
  line-height: 1.1;
  margin: 0;
}

.login-copy span {
  font-size: 1rem;
}

.login-card {
  animation: fadeUp 700ms 180ms ease both;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(8, 28, 23, 0.24);
  display: grid;
  gap: 22px;
  justify-self: end;
  padding: clamp(22px, 4vw, 36px);
  position: relative;
  width: 100%;
  z-index: 1;
}

.login-card::before {
  background: linear-gradient(90deg, var(--primary), var(--accent-soft), var(--blue));
  border-radius: 8px 8px 0 0;
  content: "";
  height: 5px;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.login-card-header h1 {
  font-size: clamp(2rem, 5vw, 3.15rem);
  line-height: 1;
  margin: 8px 0 12px;
}

.login-card-header p:last-child {
  color: var(--muted);
  margin: 0;
}

.login-form,
.role-picker {
  display: grid;
  gap: 14px;
}

.login-form label {
  color: var(--muted);
  display: grid;
  font-size: 0.9rem;
  gap: 7px;
}

.login-form input {
  box-shadow: 0 1px 0 rgba(8, 77, 64, 0.04);
  min-height: 50px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(11, 107, 87, 0.12);
  outline: 0;
}

.login-submit {
  min-height: 50px;
  position: relative;
  overflow: hidden;
}

.login-submit::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  content: "";
  inset: 0 auto 0 -60%;
  position: absolute;
  transform: skewX(-18deg);
  width: 45%;
}

.login-submit:hover::after {
  animation: buttonShine 700ms ease;
}

.login-feedback {
  color: var(--primary-strong);
  font-weight: 700;
  margin: 0;
  min-height: 22px;
}

.role-picker {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.role-picker h2 {
  margin: 3px 0 0;
}

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

.role-option {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 4px;
  min-height: 78px;
  padding: 14px;
  text-align: left;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.role-option:hover {
  border-color: var(--primary);
  box-shadow: 0 14px 28px rgba(11, 107, 87, 0.13);
  transform: translateY(-2px);
}

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

.app-shell {
  display: grid;
  grid-template-columns: 292px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #102520;
  color: #f7fbf9;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.sigae-logo {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.24), transparent),
    linear-gradient(135deg, var(--accent-soft), #f7df9c);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.18);
  display: inline-block;
  flex: 0 0 auto;
  height: 44px;
  overflow: hidden;
  position: relative;
  width: 44px;
}

.sigae-logo.large {
  border-radius: 14px;
  height: 76px;
  width: 76px;
}

.sigae-logo::before {
  background: linear-gradient(180deg, var(--primary), var(--primary-deep));
  border-radius: 10px 10px 18px 18px;
  bottom: 8px;
  content: "";
  height: 44%;
  left: 16%;
  position: absolute;
  right: 16%;
}

.logo-book,
.logo-book::after {
  background: #ffffff;
  border-radius: 4px 4px 8px 8px;
  bottom: 11px;
  content: "";
  height: 18px;
  position: absolute;
  width: 14px;
}

.logo-book {
  left: 11px;
  transform: skewY(8deg);
}

.logo-book::after {
  bottom: 0;
  left: 12px;
  transform: skewY(-16deg);
}

.logo-signal {
  background: var(--primary-deep);
  border-radius: 999px;
  height: 7px;
  left: 50%;
  position: absolute;
  top: 10px;
  transform: translateX(-50%);
  width: 7px;
}

.logo-signal::before,
.logo-signal::after {
  border: 2px solid var(--primary-deep);
  border-bottom: 0;
  border-left-color: transparent;
  border-right-color: transparent;
  border-radius: 999px 999px 0 0;
  content: "";
  left: 50%;
  position: absolute;
  top: -5px;
  transform: translateX(-50%);
}

.logo-signal::before {
  height: 15px;
  width: 25px;
}

.logo-signal::after {
  height: 25px;
  top: -10px;
  width: 39px;
}

.logo-path {
  background: var(--blue);
  border-radius: 999px;
  bottom: 9px;
  height: 4px;
  position: absolute;
  right: 8px;
  transform: rotate(-34deg);
  transform-origin: right center;
  width: 18px;
}

.sigae-logo.large::before {
  bottom: 13px;
}

.sigae-logo.large .logo-book,
.sigae-logo.large .logo-book::after {
  bottom: 20px;
  height: 28px;
  width: 22px;
}

.sigae-logo.large .logo-book {
  left: 19px;
}

.sigae-logo.large .logo-book::after {
  left: 20px;
}

.sigae-logo.large .logo-signal {
  height: 10px;
  top: 16px;
  width: 10px;
}

.sigae-logo.large .logo-signal::before {
  height: 24px;
  width: 42px;
}

.sigae-logo.large .logo-signal::after {
  height: 38px;
  top: -16px;
  width: 62px;
}

.sigae-logo.large .logo-path {
  bottom: 16px;
  height: 6px;
  right: 14px;
  width: 30px;
}

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

.brand small {
  color: #b8cbc5;
  margin-top: 2px;
}

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

.nav-item {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #d7e5e1;
  min-height: 42px;
  padding: 10px 12px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: #1d3d35;
  color: #ffffff;
}

.sidebar-footer {
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  color: #c3d5d0;
  display: flex;
  font-size: 0.88rem;
  gap: 8px;
  margin-top: auto;
  padding-top: 18px;
}

.status-dot {
  background: #6fdb93;
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(111, 219, 147, 0.16);
  height: 9px;
  width: 9px;
}

.workspace {
  min-width: 0;
  padding: 20px clamp(16px, 3vw, 34px) 34px;
}

.topbar {
  align-items: center;
  display: grid;
  gap: 14px;
  grid-template-columns: auto minmax(220px, 1fr) auto auto;
  margin-bottom: 20px;
}

.icon-button,
.primary-action,
.secondary-action,
.chip,
.table-action {
  border-radius: 8px;
  min-height: 40px;
}

.icon-button {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  display: inline-flex;
  font-size: 1.25rem;
  justify-content: center;
  width: 42px;
}

.menu-button {
  display: none;
}

.search-wrap {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  min-height: 46px;
  padding: 0 14px;
}

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

.profile-switcher {
  align-items: center;
  display: flex;
  gap: 8px;
}

.profile-switcher label {
  color: var(--muted);
  font-size: 0.88rem;
}

select,
input,
textarea {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 40px;
  padding: 8px 10px;
}

.primary-action {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #ffffff;
  font-weight: 700;
  padding: 0 16px;
}

.secondary-action,
.table-action {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0 14px;
}

.hero-panel {
  background:
    linear-gradient(120deg, rgba(11, 107, 87, 0.95), rgba(26, 74, 96, 0.92)),
    url("https://images.unsplash.com/photo-1577896851231-70ef18881754?auto=format&fit=crop&w=1800&q=80");
  background-position: center;
  background-size: cover;
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: #ffffff;
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  margin-bottom: 22px;
  min-height: 220px;
  overflow: hidden;
  padding: clamp(24px, 4vw, 42px);
}

.hero-panel h1 {
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 1;
  margin: 8px 0 14px;
  max-width: 880px;
}

.hero-panel p {
  max-width: 760px;
}

.eyebrow {
  color: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.hero-metrics {
  align-self: end;
  display: grid;
  gap: 10px;
}

.hero-metrics span {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  display: grid;
  min-height: 62px;
  padding: 12px 14px;
}

.hero-metrics strong {
  font-size: 1.45rem;
}

.content-grid {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) 330px;
}

.main-column,
.side-column {
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

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

.panel h2,
.panel h3,
.dialog-card h2 {
  margin: 3px 0 0;
}

.kpi-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 132px;
  padding: 18px;
}

.kpi-card span {
  color: var(--muted);
  display: block;
  font-size: 0.9rem;
}

.kpi-card strong {
  display: block;
  font-size: 2rem;
  margin: 10px 0;
}

.trend {
  color: var(--primary);
  font-weight: 800;
}

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

.module-card {
  background: #fbfcfb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  min-height: 150px;
  padding: 16px;
}

.module-card strong {
  font-size: 1.05rem;
}

.module-card p {
  color: var(--muted);
  margin: 0;
}

.module-card ul {
  color: var(--muted);
  margin: 0;
  padding-left: 18px;
}

.chart-row {
  display: grid;
  gap: 18px;
  grid-template-columns: 1.1fr 0.9fr;
}

.bar-chart {
  display: grid;
  gap: 12px;
}

.bar-line {
  display: grid;
  gap: 10px;
  grid-template-columns: 128px 1fr 52px;
  align-items: center;
}

.bar-track {
  background: var(--surface-soft);
  border-radius: 999px;
  height: 13px;
  overflow: hidden;
}

.bar-fill {
  background: var(--primary);
  border-radius: inherit;
  height: 100%;
}

.donut {
  align-items: center;
  background: conic-gradient(var(--primary) 0 78%, var(--accent) 78% 91%, var(--rose) 91% 100%);
  border-radius: 50%;
  display: flex;
  height: 190px;
  justify-content: center;
  margin: 8px auto;
  width: 190px;
}

.donut::after {
  align-items: center;
  background: #ffffff;
  border-radius: 50%;
  content: "78%";
  display: flex;
  font-size: 2rem;
  font-weight: 900;
  height: 112px;
  justify-content: center;
  width: 112px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.legend span {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  gap: 6px;
}

.legend i {
  border-radius: 50%;
  display: inline-block;
  height: 10px;
  width: 10px;
}

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

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.badge {
  background: var(--surface-soft);
  border-radius: 999px;
  color: var(--primary-strong);
  display: inline-flex;
  font-weight: 800;
  min-height: 28px;
  padding: 5px 10px;
}

.badge.warning {
  background: #fff2d9;
  color: #7a4d00;
}

.badge.danger {
  background: #ffe4e9;
  color: #8d2940;
}

.timeline,
.activity-list {
  display: grid;
  gap: 12px;
}

.timeline-item,
.activity-item {
  border-left: 3px solid var(--primary);
  display: grid;
  gap: 3px;
  padding-left: 12px;
}

.timeline-item strong,
.activity-item strong {
  display: block;
}

.timeline-item span,
.activity-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 0 13px;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

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

.progress-list {
  display: grid;
  gap: 14px;
}

.progress-item {
  display: grid;
  gap: 7px;
}

.progress-top {
  display: flex;
  justify-content: space-between;
}

.progress {
  background: var(--surface-soft);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.progress span {
  background: var(--blue);
  border-radius: inherit;
  display: block;
  height: 100%;
}

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

.form-grid label {
  color: var(--muted);
  display: grid;
  font-size: 0.9rem;
  gap: 6px;
}

dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 720px;
  padding: 0;
  width: calc(100% - 28px);
}

dialog::backdrop {
  background: rgba(12, 24, 22, 0.45);
}

.dialog-card {
  padding: 20px;
}

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

@media (max-width: 1180px) {
  .login-screen {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .login-visual {
    max-width: 720px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    box-shadow: var(--shadow);
    left: 0;
    max-width: 320px;
    position: fixed;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    width: 88vw;
    z-index: 10;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-button {
    display: inline-flex;
  }

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

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

@media (max-width: 860px) {
  body:not(.is-authenticated) {
    background: linear-gradient(180deg, #0d211d 0 44%, #f4f8f5 44% 100%);
  }

  .login-screen {
    align-items: start;
    gap: 18px;
    min-height: 100svh;
    padding: 14px;
  }

  .login-visual {
    gap: 16px;
    min-height: auto;
  }

  .login-brand {
    align-items: flex-start;
    gap: 12px;
  }

  .login-brand::after {
    display: none;
  }

  .login-brand strong {
    font-size: clamp(2.6rem, 17vw, 4.2rem);
  }

  .login-brand small {
    font-size: 0.86rem;
    max-width: 300px;
  }

  .login-copy {
    margin-top: 12px;
  }

  .login-card {
    gap: 16px;
    justify-self: stretch;
    padding: 22px 18px;
  }

  .login-card-header h1 {
    font-size: 2.15rem;
  }

  .role-options {
    grid-template-columns: 1fr;
  }

  .topbar {
    grid-template-columns: auto 1fr;
  }

  .profile-switcher,
  .topbar > .primary-action,
  #logoutButton {
    grid-column: span 2;
  }

  .profile-switcher {
    justify-content: space-between;
  }

  .hero-panel,
  .chart-row,
  .split-list {
    grid-template-columns: 1fr;
  }

  .kpi-grid,
  .module-grid,
  .side-column,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .data-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

@media (max-width: 520px) {
  .login-screen {
    padding: 10px;
  }

  .login-visual {
    gap: 12px;
  }

  .sigae-logo.large {
    border-radius: 12px;
    height: 58px;
    width: 58px;
  }

  .sigae-logo.large .logo-book,
  .sigae-logo.large .logo-book::after {
    bottom: 15px;
    height: 22px;
    width: 17px;
  }

  .sigae-logo.large .logo-book {
    left: 15px;
  }

  .sigae-logo.large .logo-book::after {
    left: 16px;
  }

  .sigae-logo.large .logo-signal::after {
    width: 48px;
  }

  .login-card-header p:last-child,
  .login-copy span {
    font-size: 0.88rem;
  }

  .login-form input,
  .login-submit {
    min-height: 48px;
  }

  .workspace {
    padding: 12px;
  }

  .hero-panel {
    padding: 22px;
  }

  .panel {
    padding: 14px;
  }

  .bar-line {
    grid-template-columns: 1fr;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes floatCard {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-12px) rotate(4deg);
  }
}

@keyframes growBar {
  from {
    transform: scaleY(0.2);
    transform-origin: bottom;
  }
  to {
    transform: scaleY(1);
    transform-origin: bottom;
  }
}

@keyframes sweep {
  from {
    transform: translateX(-10%) rotate(8deg);
  }
  to {
    transform: translateX(240%) rotate(8deg);
  }
}

@keyframes buttonShine {
  from {
    left: -60%;
  }
  to {
    left: 120%;
  }
}
