:root {
  --bg: #e8edf6;
  --panel: #ffffff;
  --ink: #17233b;
  --muted: #5f728f;
  --line: #d1d9e6;
  --accent: #1d3e9e;
  --accent-soft: #e8eeff;
  --header-gradient: linear-gradient(180deg, #18113a 0%, #1a1141 46%, #160f37 100%);
  --shadow-soft: 0 8px 26px rgba(20, 34, 70, 0.12);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body.logged-out .sidebar,
body.logged-out #appRoot,
body.logged-out #pageHead {
  display: none !important;
}
body.logged-in #loginCard {
  display: none !important;
}
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(180deg, #f3f6fc 0%, #ebf0f8 100%);
  font-family: "Segoe UI", Tahoma, sans-serif;
}

.shell {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 252px 1fr;
}

body.logged-in {
  overflow: hidden;
}

body.logged-in .shell {
  height: 100dvh;
  overflow: hidden;
}

body.logged-out .shell {
  grid-template-columns: 1fr;
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(129, 142, 175, 0.28);
  background: var(--header-gradient);
  color: #fff;
  padding: 18px 14px;
  box-shadow: 4px 0 20px rgba(9, 5, 32, 0.28);
}

body.logged-in .sidebar {
  height: 100dvh;
  overflow: hidden;
}

.sidebar-head {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.sidebar-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  margin: 0;
  color: #f2f6ff;
}

.menu {
  display: grid;
  gap: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-separator {
  flex: 0 0 100%;
  height: 1px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.24);
}

.menu-item {
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  text-align: left;
  padding: 0 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.menu-item:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.26);
}

.menu-item.active {
  background: #f9fbff;
  border-color: #f9fbff;
  color: #0f244e;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(120, 140, 190, 0.18);
}

.main-wrap {
  min-width: 0;
  position: relative;
  padding: 20px 22px;
}

body.logged-in .main-wrap {
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.page-head { margin-bottom: 14px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.page-head-copy {
  min-width: 0;
}

h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.2px;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.topbar-logo {
  height: 34px;
  width: auto;
  object-fit: contain;
  display: block;
}

.admin-name {
  color: #d7e2ff;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  max-width: 182px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  min-width: 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.login-card {
  width: min(520px, 100%);
  margin: 8vh auto 0;
  backdrop-filter: blur(2px);
  padding: 0;
  overflow: hidden;
}

body.logged-out .main-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(114deg, rgba(14, 9, 38, 0.86) 0%, rgba(24, 16, 64, 0.68) 42%, rgba(37, 24, 86, 0.56) 100%),
    url("./images/hero.jpg");
  background-size: cover;
  background-position: center;
  background-blend-mode: multiply;
  filter: saturate(1.18) contrast(1.04);
  z-index: 0;
}

body.logged-out .content {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 24px;
  row-gap: 12px;
}

body.logged-out .main-wrap {
  padding: 0;
}

body.logged-out .login-card {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(202, 215, 235, 0.92);
  box-shadow: 0 18px 44px rgba(13, 22, 42, 0.28);
  color: #17233b;
}

h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.login-panel-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 14px 16px;
  border-radius: 0;
  background: var(--header-gradient);
  border: none;
}

.login-panel-logo {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

body.logged-out .login-card h2 {
  color: #f2f6ff;
  margin: 0;
  font-size: 17px;
}

#loginForm {
  padding: 14px 16px 12px;
}

#loginMsg {
  padding: 0 16px 14px;
  margin-top: 0;
}

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

label {
  display: grid;
  gap: 6px;
  color: #516581;
  font-size: 13px;
  font-weight: 500;
}

body.logged-out .login-card label {
  color: #516581;
}

input {
  height: 38px;
  border: 1px solid #c7d2e1;
  border-radius: 9px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:focus {
  border-color: #8ea7dd;
  box-shadow: 0 0 0 3px rgba(94, 133, 232, 0.18);
  outline: none;
}

.btn {
  height: 38px;
  border: none;
  border-radius: 9px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 140ms ease, transform 120ms ease;
}

.btn:hover {
  background: #17358a;
}

.btn:active {
  transform: translateY(1px);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.28);
}
.icon-btn {
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 12px;
  padding: 0 10px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}
.icon-btn.ghost {
  background: rgba(255, 255, 255, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.28);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

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

.row.between { justify-content: space-between; }
.row.compact { gap: 8px; }
.row.wrap { flex-wrap: wrap; }

.badge {
  border: 1px solid #d5deea;
  border-radius: 999px;
  background: #f5f8ff;
  padding: 5px 12px;
  color: #3e5578;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}

.kpi {
  background: linear-gradient(180deg, #f8fbff 0%, #f2f7ff 100%);
  border: 1px solid #d9e5fb;
  border-radius: 10px;
  padding: 12px;
}

.kpi .k {
  color: #566c8e;
  font-size: 11px;
}

.kpi .v {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
  color: #172849;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #dce5f2;
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  font-size: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
}

th {
  background: #f5f8ff;
  color: #324766;
  font-weight: 700;
}

.pager {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.pager > span {
  font-size: 13px;
  font-weight: 700;
  color: #223657;
}

.msg {
  margin-top: 10px;
  color: #37527b;
  font-size: 12px;
  min-height: 18px;
}

.company-signature {
  display: none;
}

body.logged-out .company-signature {
  display: inline-flex;
  position: absolute;
  top: 26px;
  left: 30px;
  z-index: 3;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 24px;
  border-radius: 16px;
  background: rgba(16, 18, 56, 0.8);
  border: 1px solid rgba(168, 183, 235, 0.24);
  color: #e6eeff;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(8, 11, 35, 0.35);
}

.company-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
}

.mobile-menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid #ccd7e6;
  border-radius: 10px;
  background: #ffffff;
  color: #1a2f5d;
  cursor: pointer;
  flex: 0 0 auto;
  padding: 0;
}

.sidebar-backdrop {
  display: none;
}

.sidebar-close-btn {
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #f1f5ff;
  font-size: 14px;
  font-weight: 700;
  width: 32px;
  height: 32px;
  padding: 0;
  line-height: 1;
  cursor: pointer;
}

.hamburger {
  position: relative;
  width: 18px;
  height: 2px;
  background: #1a2f5d;
  border-radius: 2px;
}

.hamburger::before,
.hamburger::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  background: #1a2f5d;
  border-radius: 2px;
}

.hamburger::before {
  top: -6px;
}

.hamburger::after {
  top: 6px;
}

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

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1001;
    width: min(86vw, 300px);
    min-height: 100dvh;
    border-right: 1px solid #2d447b;
    border-bottom: none;
    padding: 14px 12px;
    transform: translateX(-108%);
    transition: transform 180ms ease;
    overflow-y: auto;
  }

  body.logged-in.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(12, 17, 34, 0.46);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.logged-in.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

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

  .sidebar-footer {
    margin-top: 10px;
    padding-top: 0;
  }

  .menu-item {
    text-align: center;
    padding: 0 6px;
  }

  .main-wrap {
    padding: 12px;
  }

  .mobile-menu-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.logged-out .mobile-menu-btn {
    display: none;
  }

  .page-head {
    align-items: center;
    gap: 10px;
    margin: 0 0 10px;
    padding: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .page-head-copy h1 {
    color: #1a2f5d;
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
  }

  .page-head-copy .subtitle {
    margin-top: 2px;
    color: #5f728f;
    font-size: 11px;
  }

  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .row.between.wrap {
    gap: 8px;
    align-items: flex-start;
  }

  .row.compact {
    width: 100%;
    flex-wrap: wrap;
  }

  .row.compact label {
    width: 100%;
  }

  .row.compact .btn {
    width: 100%;
  }

  .pager {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .pager .btn {
    min-width: 92px;
  }

  .table-wrap {
    border: none;
    border-radius: 0;
    overflow: visible;
    background: transparent;
  }

  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap tr,
  .table-wrap th,
  .table-wrap td {
    display: block;
    width: 100%;
  }

  .table-wrap table {
    min-width: 0;
  }

  .table-wrap thead {
    display: none;
  }

  .table-wrap tbody {
    display: grid;
    gap: 10px;
  }

  .table-wrap tr {
    border: 1px solid #dce5f2;
    border-radius: 10px;
    padding: 6px 10px;
    background: #ffffff;
    box-shadow: 0 6px 16px rgba(25, 40, 78, 0.08);
  }

  .table-wrap td {
    padding: 8px 0;
    border-bottom: 1px solid #ecf1f8;
    display: grid;
    grid-template-columns: minmax(110px, 42%) 1fr;
    gap: 10px;
    align-items: start;
    overflow-wrap: anywhere;
  }

  .table-wrap td:last-child {
    border-bottom: none;
  }

  .table-wrap td::before {
    content: attr(data-label);
    color: #5c6f8c;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2px;
    text-transform: uppercase;
  }

  body.logged-out .content {
    min-height: calc(100dvh - 24px);
  }

  body.logged-out .company-signature {
    top: 14px;
    left: 14px;
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 15px;
  }

  .company-logo {
    height: 30px;
  }

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