:root {
  --green: #245b49;
  --green-dark: #174132;
  --green-soft: #dfeede;
  --mint: #bde9d4;
  --ink: #17231f;
  --muted: #66736e;
  --line: #c9d5d0;
  --page: #f4f7f5;
  --white: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--green);
  text-decoration: none;
  font-weight: 700;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--white);
  color: var(--green);
  font-weight: 700;
  cursor: pointer;
}

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

button.danger {
  border-color: #9f2d20;
  background: #9f2d20;
  color: var(--white);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.table-actions form {
  margin: 0;
}

.table-actions .link-button {
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
}

.table-actions .link-button.danger {
  color: #9f2d20;
}

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

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

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

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 58px;
  padding: 0 24px;
  background: var(--green);
  color: var(--white);
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 4px;
  background: var(--white);
  line-height: 0;
}

.brand img {
  display: block;
  width: 185px;
  max-width: 34vw;
  height: 42px;
  object-fit: contain;
}

.topbar nav {
  display: flex;
  gap: 14px;
  flex: 1;
}

.topbar nav a,
.logout span {
  color: var(--white);
  font-size: 14px;
}

.logout {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.logout button {
  border-color: rgba(255, 255, 255, .6);
  background: transparent;
  color: var(--white);
}

.shell,
.auth-shell {
  width: min(1320px, calc(100vw - 32px));
  margin: 24px auto;
}

.auth-shell {
  min-height: calc(100vh - 48px);
  display: grid;
  place-items: center;
}

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

.login-card {
  width: min(420px, 100%);
}

.login-institutional {
  width: min(1080px, 100%);
}

.login-box {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.96), rgba(224,240,233,.92)),
    linear-gradient(180deg, #f7fbfa, #dcebe4);
  box-shadow: 0 22px 54px rgba(23, 65, 50, .14);
}

.login-identity {
  position: relative;
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(320px, 420px);
  column-gap: 56px;
  row-gap: 18px;
  align-items: start;
  justify-content: center;
  overflow: hidden;
  min-height: auto;
  padding: 38px 46px 34px;
  background: transparent;
}

.login-identity h1 {
  max-width: 520px;
  margin: 0 0 12px;
  color: var(--green-dark);
  font-size: 38px;
  line-height: 1.08;
}

.login-identity p {
  max-width: 520px;
}

.login-identity .home-logos {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 110px;
  margin-bottom: 10px;
}

.login-identity .home-kicker,
.login-identity > h1,
.login-identity > p {
  grid-column: 1;
}

.login-form-wrap {
  grid-column: 2;
  grid-row: 2 / span 4;
  align-self: center;
}

.login-identity .home-author {
  grid-column: 1 / -1;
  justify-self: center;
}

.login-identity .home-author {
  margin-top: 6px;
}

.login-card {
  align-self: start;
  width: 100%;
  margin-top: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 16px 34px rgba(23, 65, 50, .10);
  background: rgba(255, 255, 255, .84);
}

.login-card h1 {
  margin-bottom: 8px;
}

.login-institutional {
  width: min(960px, 100%);
}

.login-identity {
  grid-template-columns: minmax(420px, 1.35fr) minmax(300px, .9fr);
  column-gap: 8px;
  row-gap: 18px;
  padding: 34px 46px 26px;
}

.login-identity::before {
  content: "";
  display: block;
  grid-column: 1;
  grid-row: 2;
  min-height: 240px;
  background: var(--white) url("/public/img/sinah-logo.png") center / contain no-repeat;
}

.login-identity > .home-kicker,
.login-identity > h1,
.login-identity > p:not(.home-author) {
  display: none;
}

.login-identity .home-logos {
  justify-content: flex-start;
  gap: 130px;
  margin: 0 0 4px 8px;
}

.login-identity .home-logos img {
  height: 44px;
}

.login-form-wrap {
  grid-column: 2;
  grid-row: 2;
  align-self: stretch;
}

.login-form-wrap .login-card {
  display: grid;
  align-content: center;
  min-height: 240px;
  padding: 22px;
  background: rgba(255, 255, 255, .9);
}

.login-form-wrap .login-card h1 {
  color: var(--green-dark);
  font-size: 34px;
  line-height: 1.1;
}

.login-identity .home-author {
  grid-column: 1 / -1;
  grid-row: 3;
  justify-self: center;
  margin: 0;
  font-size: 12px;
  letter-spacing: .02em;
}

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

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  color: var(--green);
}

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

.grid-2,
.grid-3 {
  display: grid;
  gap: 16px;
}

.grid-2 {
  grid-template-columns: minmax(320px, 420px) 1fr;
}

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

.metric strong {
  display: block;
  color: var(--green);
  font-size: 32px;
}

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

.home-hero {
  display: grid;
  grid-template-columns: minmax(520px, 1.35fr) minmax(500px, 1fr);
  gap: 0;
  align-items: stretch;
  min-height: 430px;
  margin-bottom: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #eef6f1 58%, #dcebe4 100%);
}

.home-copy {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: 42px 36px 36px;
  background: linear-gradient(90deg, rgba(255,255,255,.88), rgba(239,248,244,.9));
}

.home-logos {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 420px;
}

.home-logos img {
  width: auto;
  height: 54px;
  object-fit: contain;
}

.home-kicker {
  margin: 10px 0 0;
  color: #9f6f12;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.home-copy h1 {
  max-width: 660px;
  margin: 0;
  color: var(--green-dark);
  font-size: 40px;
  line-height: 1.05;
}

.home-summary {
  max-width: 620px;
  margin: 0;
  color: #3d514a;
  font-size: 16px;
  line-height: 1.55;
}

.home-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 4px;
}

.home-author {
  margin: 8px 0 0;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

.hydro-scene {
  position: relative;
  min-height: 430px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255,255,255,.96) 0%, rgba(239,248,244,.72) 54%, rgba(111,153,139,.34) 100%),
    linear-gradient(135deg, #e7f4f8, #f7fbf9);
}

.home-sinah-logo {
  position: absolute;
  z-index: 5;
  top: 54px;
  left: 30px;
  right: 22px;
  width: calc(100% - 52px);
  height: 245px;
  object-fit: contain;
  object-position: center;
  background: rgba(255, 255, 255, .82);
}

.scene-sun {
  position: absolute;
  top: 310px;
  right: 255px;
  width: 64px;
  height: 64px;
  border: 2px solid rgba(203, 150, 30, .8);
  border-radius: 50%;
  background: rgba(248, 210, 104, .22);
}

.scene-mountains span {
  position: absolute;
  bottom: 44px;
  width: 260px;
  height: 150px;
  background: #b9d3c8;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.scene-mountains span:nth-child(1) {
  left: 170px;
}

.scene-mountains span:nth-child(2) {
  left: 285px;
  bottom: 54px;
  background: #9fc0b4;
}

.scene-mountains span:nth-child(3) {
  right: -36px;
  bottom: 46px;
  background: #c7ddd3;
}

.gauge-card {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 7;
  width: 112px;
  border: 1px solid rgba(36, 91, 73, .35);
  border-radius: 6px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 16px 30px rgba(23, 65, 50, .14);
}

.gauge-title {
  border-bottom: 1px solid var(--line);
  padding: 6px 8px;
  color: var(--green);
  font-size: 7px;
  font-weight: 800;
}

.gauge-body {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  height: 94px;
  padding: 8px;
}

.staff-gauge {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-left: 5px solid #1d5b79;
  padding-left: 8px;
  color: #24473d;
  font-size: 8px;
  font-weight: 800;
}

.water-column {
  position: relative;
  align-self: stretch;
  overflow: hidden;
  border: 1px solid #7ba9b7;
  border-radius: 6px;
  background: repeating-linear-gradient(0deg, #ffffff 0 18px, #eef5f8 18px 19px);
}

.water-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  background: linear-gradient(180deg, #6fc3d8, #23799a);
  animation: waterLevel 4s ease-in-out infinite;
}

.data-card {
  position: absolute;
  right: 265px;
  bottom: 0;
  z-index: 7;
  width: 158px;
  display: grid;
  gap: 9px;
  border: 1px solid rgba(36, 91, 73, .28);
  border-radius: 8px;
  padding: 18px 14px;
  background: rgba(255, 255, 255, .84);
  box-shadow: 0 16px 30px rgba(23, 65, 50, .12);
}

.data-card span {
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), #6bb6c9);
  transform-origin: left;
  animation: dataPulse 2.8s ease-in-out infinite;
}

.data-card span:nth-child(2) {
  width: 74%;
  animation-delay: .2s;
}

.data-card span:nth-child(3) {
  width: 58%;
  animation-delay: .4s;
}

.data-card span:nth-child(4) {
  width: 86%;
  animation-delay: .6s;
}

.river {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 126px;
  overflow: hidden;
  background: linear-gradient(180deg, #8ed0dc, #276f83);
}

.river-wave {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 70px;
  border-radius: 45%;
  background: rgba(255, 255, 255, .28);
  animation: riverMove 7s linear infinite;
}

.wave-one {
  top: -24px;
}

.wave-two {
  top: 14px;
  opacity: .55;
  animation-duration: 10s;
  animation-direction: reverse;
}

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

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

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.chart-head h2 {
  margin-bottom: 4px;
  color: var(--green-dark);
}

.chart-head p {
  margin: 0;
}

.chart-box {
  position: relative;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.chart-box canvas,
.highchart-box {
  display: block;
  min-width: 900px;
  width: 100%;
  height: 360px;
}

.highchart-box {
  height: 380px;
}

.datatable-toolbar,
.datatable-footer {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.datatable-toolbar label {
  max-width: 260px;
}

.datatable-pages {
  display: flex;
  align-items: center;
  gap: 8px;
}

.datatable-pages button {
  min-height: 32px;
  padding: 0 10px;
}

.datatable-pages button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.compact-table th,
.compact-table td {
  padding: 5px 7px;
}

.empty-chart {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  background: rgba(255, 255, 255, .8);
  color: var(--muted);
  font-weight: 800;
}

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

.home-workflow article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--white);
}

.home-workflow strong {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
}

.home-workflow h2 {
  margin-bottom: 6px;
  color: var(--green-dark);
  font-size: 18px;
}

.home-workflow p {
  margin: 0;
}

@keyframes waterLevel {
  0%, 100% {
    height: 38%;
  }
  50% {
    height: 57%;
  }
}

@keyframes dataPulse {
  0%, 100% {
    transform: scaleX(.72);
    opacity: .72;
  }
  50% {
    transform: scaleX(1);
    opacity: 1;
  }
}

@keyframes riverMove {
  from {
    transform: translateX(-8%);
  }
  to {
    transform: translateX(8%);
  }
}

.actions,
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.filters label {
  min-width: 170px;
  flex: 1;
}

.flash {
  width: min(1320px, calc(100vw - 32px));
  margin: 16px auto 0;
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 700;
}

.flash.success {
  background: #dff3e8;
  color: #145134;
}

.flash.error {
  background: #fde3df;
  color: #7c1d14;
}

.table-wrap,
.annex-scroll {
  overflow: auto;
}

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

.capture-table th,
.capture-table td,
.data-table th,
.data-table td {
  border: 1px solid var(--line);
  padding: 7px;
  text-align: left;
}

.capture-table th {
  width: 80px;
  text-align: center;
  background: var(--green-soft);
}

.capture-table input {
  min-width: 92px;
  text-align: right;
}

.form-note {
  margin: 0 0 12px;
  color: #4d5f59;
}

.data-table input,
.data-table select {
  width: 100%;
  min-width: 90px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.justification-field {
  margin-bottom: 14px;
}

.justification-text {
  min-width: 260px;
  white-space: normal;
}

.check {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
}

.annex-page {
  position: relative;
  width: 100%;
  margin: 0 auto;
  padding: 8px 0 24px;
  background: var(--white);
}

.annex-brand {
  display: grid;
  grid-template-columns: 240px 1fr 240px;
  align-items: center;
  min-width: 1120px;
  min-height: 66px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--green);
}

.annex-logo {
  display: block;
  width: auto;
  height: 52px;
  object-fit: contain;
}

.annex-logo-left {
  justify-self: start;
}

.annex-logo-right {
  justify-self: end;
}

.annex-watermarked::before {
  content: "NO OFICIAL";
  position: absolute;
  top: 44%;
  left: 50%;
  z-index: 20;
  width: 100%;
  color: rgba(70, 70, 70, .28);
  font-size: 128px;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  text-align: center;
  text-shadow: 0 0 1px rgba(255, 255, 255, .35);
  transform: translate(-50%, -50%) rotate(-24deg);
  pointer-events: none;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.annex-page > * {
  position: relative;
  z-index: 2;
}

.seal {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid #c99f30;
  border-radius: 50%;
  color: #b58116;
  font-weight: 800;
}

.ministry {
  color: #bd8a1e;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.12;
}

.senamhi {
  color: #31518f;
  font-size: 24px;
  font-weight: 900;
  text-align: right;
}

.annex-page h1 {
  min-width: 1120px;
  margin: 0;
  border-top: 2px solid var(--green);
  border-bottom: 2px solid var(--green);
  padding: 6px 8px;
  color: var(--green);
  text-align: center;
  font-size: 24px;
  letter-spacing: 0;
}

.annex-page h2 {
  min-width: 1120px;
  margin: 0;
  border-left: 2px solid var(--green);
  border-right: 2px solid var(--green);
  padding: 6px 8px;
  text-align: center;
  font-size: 11px;
}

.annex-table {
  min-width: 1120px;
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 10px;
  background: var(--white);
}

.annex-table th,
.annex-table td {
  width: 29px;
  height: 14px;
  border: 1px solid #111;
  padding: 1px 2px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.annex-table th:first-child,
.annex-table td:first-child {
  width: 32px;
}

.annex-table .green {
  background: var(--green);
  color: var(--white);
  font-weight: 800;
}

.annex-table tbody tr:nth-child(even):not(.stat-row) {
  background: var(--green-soft);
}

.annex-table td.annex-cell-max {
  background: #ff0000;
  color: #ffffff;
  font-weight: 800;
}

.annex-table td.annex-cell-min {
  background: #003cff;
  color: #ffffff;
  font-weight: 800;
}

.annex-footer {
  min-width: 1120px;
  margin-top: 8px;
  border-top: 1px solid var(--green);
  padding-top: 6px;
}

.annex-footer p {
  margin: 0 0 5px;
  color: #9f2d20;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.annex-footer img {
  display: block;
  width: 100%;
  max-height: 42px;
  object-fit: contain;
}

.stat-row td,
.stat-row th {
  border-color: transparent;
  font-weight: 800;
}

.stat-row.max td {
  color: red;
}

.stat-row.min {
  background: var(--mint);
}

.stat-row.min td {
  color: blue;
}

.stat-row.avg td {
  color: #111;
}

@media (max-width: 800px) {
  .topbar,
  .topbar nav,
  .logout,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .home-hero,
  .login-institutional,
  .home-metrics,
  .query-summary,
  .home-workflow {
    grid-template-columns: 1fr;
  }

  .datatable-toolbar,
  .datatable-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .datatable-toolbar label {
    max-width: none;
  }

  .login-box {
    grid-template-columns: 1fr;
  }

  .login-identity {
    grid-template-columns: 1fr;
    min-height: 430px;
    padding: 24px;
  }

  .login-identity .home-logos {
    justify-content: space-between;
    gap: 20px;
  }

  .login-identity::before {
    grid-column: 1;
    grid-row: auto;
    min-height: 180px;
  }

  .login-form-wrap {
    grid-column: 1;
    grid-row: auto;
    align-self: stretch;
  }

  .login-identity .home-author {
    grid-column: 1;
    grid-row: auto;
  }

  .login-card {
    border: 0;
  }

  .login-identity h1 {
    font-size: 30px;
  }

  .home-copy {
    padding: 24px;
  }

  .home-copy h1 {
    font-size: 30px;
  }

  .hydro-scene {
    min-height: 360px;
  }

  .gauge-card {
    left: 22px;
    width: 170px;
  }

  .data-card {
    right: 22px;
    width: 160px;
  }

  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: landscape;
    margin: 8mm;
  }

  body {
    background: var(--white);
  }

  .no-print,
  .topbar,
  .flash {
    display: none !important;
  }

  .shell {
    width: 100%;
    margin: 0;
  }

  .annex-page {
    padding: 0;
  }

  .annex-scroll {
    overflow: visible;
  }

  .annex-table,
  .annex-page h1,
  .annex-page h2,
  .annex-brand,
  .annex-footer {
    min-width: 0;
  }

  .annex-watermarked::before {
    position: fixed;
    top: 48%;
    left: 50%;
    z-index: 9999;
    color: rgba(55, 55, 55, .32) !important;
    font-size: 112px;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
