:root {
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #172033;
  --muted: #6b778c;
  --line: #dfe6ee;
  --primary: #155e75;
  --primary-dark: #0f4357;
  --accent: #2f9e7e;
  --warning: #d97706;
  --danger: #c2410c;
  --shadow: 0 18px 45px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(21, 94, 117, 0.08), rgba(47, 158, 126, 0.08)),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-dark);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 290px;
  overflow-y: auto;
  padding: 24px 18px;
  color: #dce7ef;
  background: #102331;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  padding: 6px 8px 18px;
}

.brand:hover {
  color: #fff;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 4px;
  color: #9fb3c4;
  font-size: 0.76rem;
}

.role-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
  margin: 10px 0 24px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 8px;
}

.role-pill {
  display: block;
  padding: 8px 6px;
  color: #aebfcc;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}

.role-pill:hover,
.role-pill.active {
  color: #102331;
  background: #fff;
}

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

.nav-link,
.nav-group a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 9px 10px;
  color: #cbd8e1;
  border-radius: 8px;
  font-size: 0.92rem;
}

.nav-link {
  width: 100%;
  margin: 0;
  border: 0;
  text-align: left;
  background: transparent;
}

.nav-link span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.nav-toggle {
  justify-content: space-between;
}

.nav-toggle .bi-chevron-down {
  transition: transform 0.2s ease;
}

.nav-toggle:not(.collapsed) .bi-chevron-down {
  transform: rotate(180deg);
}

.submenu {
  display: grid;
  gap: 4px;
  padding: 4px 0 10px 32px;
}

.submenu a {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  color: #aebfcc;
  border-radius: 8px;
  font-size: 0.86rem;
}

.nav-group a:hover,
.nav-group a.active,
.submenu a:hover,
.submenu a.active,
.nav-link:hover,
.nav-link.active,
.nav-toggle:not(.collapsed) {
  color: #fff;
  background: rgba(255, 255, 255, 0.11);
}

.main-content {
  width: calc(100% - 290px);
  margin-left: 290px;
  padding: 28px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  margin-bottom: 24px;
  background: rgba(238, 243, 247, 0.86);
  border: 1px solid rgba(223, 230, 238, 0.8);
  border-radius: 8px;
  backdrop-filter: blur(14px);
}

.topbar h1,
.section-heading h2,
.panel h3 {
  margin: 0;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.login-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 28px;
}

.login-panel {
  width: min(100%, 420px);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 24px;
}

.login-panel h1 {
  margin: 0 0 24px;
  font-size: 1.65rem;
  font-weight: 800;
  text-align: center;
}

.input-icon {
  position: relative;
}

.input-icon i {
  position: absolute;
  top: 50%;
  left: 14px;
  color: var(--muted);
  transform: translateY(-50%);
}

.input-icon .form-control {
  padding-left: 42px;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.login-options .form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: auto;
  margin: 0;
  padding-left: 0;
}

.login-options .form-check-input {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

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

.eyebrow {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.view-section {
  scroll-margin-top: 116px;
  margin-bottom: 28px;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 0 16px;
}

.section-heading h2 {
  font-size: clamp(1.25rem, 2vw, 1.85rem);
}

.link-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
}

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

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

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

.kpi-card {
  min-height: 132px;
  padding: 18px;
}

.kpi-card span,
.calculator span {
  display: block;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
}

.kpi-card strong {
  display: block;
  margin: 12px 0 6px;
  font-size: clamp(1.5rem, 2vw, 2.1rem);
}

.kpi-card em {
  color: var(--accent);
  font-size: 0.8rem;
  font-style: normal;
  font-weight: 700;
}

.kpi-card.danger em {
  color: var(--danger);
}

.panel {
  padding: 20px;
}

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

.panel h3 {
  font-size: 1.05rem;
}

.table-panel {
  padding: 0;
  overflow-x: auto;
}

.table {
  min-width: 780px;
  margin: 0;
}

.table th {
  padding: 16px;
  color: #405267;
  background: var(--surface-soft);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.table td {
  padding: 16px;
  vertical-align: middle;
}

.table td a {
  margin-right: 10px;
  font-weight: 700;
}

.chart {
  display: flex;
  align-items: end;
  gap: 14px;
  height: 270px;
  padding: 22px;
  background: linear-gradient(180deg, var(--surface-soft), #fff);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.chart-bars span {
  flex: 1;
  min-width: 18px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
}

.bar-45 {
  height: 45%;
}

.bar-54 {
  height: 54%;
}

.bar-66 {
  height: 66%;
}

.bar-70 {
  height: 70%;
}

.bar-74 {
  height: 74%;
}

.bar-82 {
  height: 82%;
}

.bar-88 {
  height: 88%;
}

.bar-92 {
  height: 92%;
}

.status-stack,
.notification-list,
.timeline,
.calculator,
.mini-form,
.settings-grid,
.settings-list,
.upload-grid {
  display: grid;
  gap: 12px;
}

.status-stack a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  color: var(--ink);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-stack strong {
  color: var(--primary);
}

.form-control,
.form-select {
  min-height: 44px;
  border-color: #d7e0ea;
  border-radius: 8px;
}

.form-label {
  color: #405267;
  font-size: 0.83rem;
  font-weight: 800;
}

.form-check {
  padding-left: 2.6rem;
}

.form-check-input {
  width: 2rem;
  height: 1rem;
  margin-left: -2.6rem;
}

.mini-form .btn {
  justify-self: start;
}

.filter-panel {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr auto;
  gap: 12px;
}

.info-list {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 12px;
  margin: 0;
}

.info-list dt {
  color: var(--muted);
}

.info-list dd {
  margin: 0;
  font-weight: 800;
}

.timeline span {
  position: relative;
  padding-left: 28px;
  font-weight: 700;
}

.timeline span::before {
  position: absolute;
  top: 3px;
  left: 0;
  width: 14px;
  height: 14px;
  content: "";
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(47, 158, 126, 0.14);
}

.notification-list a,
.settings-grid a,
.upload-grid a {
  padding: 14px 16px;
  color: var(--ink);
  font-weight: 800;
  background: var(--surface-soft);
  border: 1px dashed #c8d5df;
  border-radius: 8px;
}

.settings-list span {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-list small {
  color: var(--muted);
  font-weight: 700;
}

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

.calculator strong {
  display: block;
  font-size: 1.65rem;
}

.btn {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

@media (max-width: 1200px) {
  .kpi-grid,
  .kpi-grid.compact {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filter-panel,
  .settings-grid,
  .upload-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .login-shell {
    padding: 18px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    max-height: none;
  }

  .main-content {
    width: 100%;
    margin-left: 0;
    padding: 18px;
  }

  .topbar,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .kpi-grid,
  .kpi-grid.compact,
  .filter-panel,
  .settings-grid,
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .table {
    min-width: 720px;
  }
}
