@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Sora:wght@500;700;800&display=swap");

:root {
  --bg: #0e1219;
  --panel: #141b26;
  --panel-2: #1a2230;
  --line: #2a3650;
  --text: #eef3ff;
  --muted: #9daccc;
  --accent: #3a74bf;
  --accent-2: #305f9b;
  --ok: #2cb67d;
  --bad: #e16060;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 18% 0%, #19253b 0%, #101722 42%, #0e1219 100%);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 430px 1fr;
  background: #0f141d;
}

.login-panel {
  padding: 38px 30px;
  border-right: 1px solid #26344d;
  display: flex;
  flex-direction: column;
  gap: 11px;
  justify-content: center;
}

.login-subtle-credit {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: #8e9fbe;
  line-height: 1.4;
}

.login-subtle-credit span {
  color: #c8d3ea;
}

.login-subtle-credit a {
  margin-left: 8px;
  color: #8ab8ff;
  text-decoration: none;
}

.login-subtle-credit a:hover {
  color: #bdd6ff;
  text-decoration: underline;
}

.login-badge {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: contain;
  border: 1px solid #355285;
  padding: 8px;
  background: radial-gradient(circle at 30% 20%, #223453, #151d29 65%);
  margin-bottom: 6px;
}

.login-hero {
  min-height: 100vh;
  background-size: cover;
  background-position: center;
  background-image: linear-gradient(130deg, #1c2d4a 0%, #151f30 42%, #111822 100%);
}

.hero {
  min-height: 170px;
  border-radius: 12px;
  border: 1px solid #2e3e5e;
  background-size: cover;
  background-position: center;
  background-image: linear-gradient(130deg, #1a2a45 0%, #132033 46%, #101823 100%);
  overflow: hidden;
}

.hero-overlay {
  min-height: 170px;
  background: linear-gradient(100deg, rgba(8, 12, 18, 0.84), rgba(7, 10, 17, 0.6));
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 14px;
  align-items: center;
  padding: 16px;
}

.hero-logo {
  width: 68px;
  height: 68px;
  border-radius: 10px;
  background: rgba(22, 30, 44, 0.92);
  border: 1px solid rgba(92, 123, 176, 0.75);
  object-fit: contain;
  padding: 6px;
}

.hero-center h1 {
  margin: 0;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-size: 2.05rem;
  letter-spacing: 0.01em;
}

.hero-center p {
  margin-top: 8px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 230px 1fr;
  background: #0f141d;
}

.sidebar {
  border-right: 1px solid #273650;
  background: linear-gradient(180deg, #131b28 0%, #0f1620 100%);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-title {
  font-size: 1.05rem;
  font-family: "Sora", "Segoe UI", sans-serif;
  font-weight: 700;
  margin: 0 6px 8px;
  padding: 8px 8px 10px;
  color: #dbe7ff;
  border-bottom: 1px solid #2a3955;
}

.nav-btn {
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #9fb1d2;
  font-weight: 600;
  padding: 11px 12px;
  margin: 0;
  cursor: pointer;
  text-align: left;
  display: block;
  transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.nav-btn:hover {
  color: #e8f0ff;
  background: rgba(70, 110, 176, 0.14);
}

.nav-btn.is-active {
  color: #f3f8ff;
  border-left-color: #7eb0ff;
  background: linear-gradient(90deg, rgba(63, 117, 212, 0.38), rgba(50, 89, 160, 0.07));
}

.shell-main {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.app-account {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 45;
}

.top-user-menu {
  position: relative;
}

.top-user-trigger {
  border: 1px solid #2e3e5d;
  border-radius: 999px;
  background: #172131;
  color: var(--text);
  min-height: 44px;
  padding: 5px 8px 5px 5px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.top-user-trigger:hover {
  border-color: #4b69a0;
}

.top-user-initial {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #b4d0ff;
  background: linear-gradient(150deg, #4d8cf5, #2d61be);
  color: #eef5ff;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.top-user-email {
  color: #d4e1f8;
  font-size: 0.95rem;
  max-width: 230px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-user-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: #182232;
  border: 1px solid #304263;
  border-radius: 10px;
  padding: 8px;
  min-width: 170px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 30;
}

.actions-row {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 9px;
  align-items: stretch;
}

.actions-row button {
  width: 100%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.top-user-popover button {
  width: 100%;
}

.top-user-menu:hover .top-user-popover,
.top-user-menu.is-open .top-user-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.module-view {
  display: grid;
  gap: 14px;
}

.module-block {
  margin: 14px 0 0;
  border: 1px solid #2e3f5f;
  border-radius: 12px;
  padding: 12px;
  background: linear-gradient(180deg, #192232 0%, #151d2b 100%);
}

.module-block.table-block {
  padding-bottom: 8px;
}

.block-title {
  margin: 0 0 10px;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #a6c8ff;
}

.card {
  background: linear-gradient(180deg, #182131 0%, #151d2b 100%);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 28px rgba(3, 7, 18, 0.32);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(160deg, #1a2536 0%, #161f2d 100%);
  padding: 12px;
}

.stat-card h4 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.stat-card p {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
}

h1,
h2,
h3 {
  font-family: "Sora", "Segoe UI", sans-serif;
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
  margin: 0 0 12px;
}

.grid {
  display: grid;
  gap: 10px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.92rem;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #131d2b;
  color: var(--text);
}

input:focus,
select:focus {
  outline: 0;
  border-color: #4e8ef9;
  box-shadow: 0 0 0 2px rgba(60, 130, 246, 0.24);
}

.row {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #eff6ff;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
}

button:hover {
  background: var(--accent-2);
}

button.ghost {
  background: #243248;
  color: var(--text);
}

button.ghost:hover {
  background: #2b3e5a;
}

button.danger {
  background: #6b1d2a;
  color: #ffd8df;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 14px 0;
}

.status {
  margin: 12px 0 0;
  padding: 10px;
  border-radius: 10px;
  background: #192334;
}

.status.ok {
  border: 1px solid #245f3a;
  color: #ccfbe0;
}

.status.bad {
  border: 1px solid #6d2530;
  color: #ffd7dc;
}

.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.qr-reader {
  margin-top: 10px;
  width: min(100%, 460px);
  border: 1px solid #3a4d70;
  border-radius: 12px;
  padding: 8px;
  background: #151f2d;
  box-shadow: 0 8px 22px rgba(2, 7, 18, 0.35);
}

.qr-reader > div,
.qr-reader video {
  border-radius: 10px;
}

.qr-reader video {
  object-fit: cover;
  max-height: 320px;
}

#qr-reader__scan_region {
  min-height: 210px;
}

.calendar-wrap {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #151f2d;
  margin-bottom: 10px;
}

.calendar-head {
  align-items: center;
  justify-content: space-between;
  margin-top: 0;
  margin-bottom: 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-cell {
  border: 1px solid #354866;
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
  font-size: 0.88rem;
  background: #1a2535;
}

.cal-cell.head {
  font-weight: 700;
  background: #24344c;
}

.cal-cell.day {
  cursor: pointer;
}

.cal-cell.day:hover {
  border-color: #629df8;
}

.cal-cell.day.today {
  outline: 1px solid #75a9ff;
}

.cal-cell.day.active {
  background: #2f62ba;
  border-color: #78a8fc;
}

.cal-cell.day.has-override {
  box-shadow: inset 0 0 0 2px #f59e0b;
}

.cal-cell.dim {
  opacity: 0.45;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  text-align: left;
  padding: 8px;
  white-space: nowrap;
}

th {
  color: #d9e7ff;
  background: rgba(84, 123, 196, 0.08);
}

tr.is-selected {
  background: #2a3f63;
}

@media (max-width: 980px) {
  .login-screen {
    grid-template-columns: 1fr;
  }

  .login-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    min-height: 52vh;
    padding: 26px 18px;
  }

  .login-subtle-credit {
    margin-top: 8px;
  }

  .login-hero {
    min-height: 48vh;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    position: sticky;
    top: 0;
    z-index: 20;
    gap: 8px;
    padding: 10px 12px;
    -webkit-overflow-scrolling: touch;
    background: #101722;
  }

  .sidebar-title {
    display: none;
  }

  .nav-btn {
    white-space: nowrap;
    min-width: max-content;
    border: 1px solid #2e4263;
    border-radius: 999px;
    border-left-width: 1px;
    padding: 8px 12px;
    background: #172133;
  }

  .shell-main {
    padding: 12px;
  }

  .app-account {
    top: 64px;
    right: 10px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .qr-reader {
    width: min(100%, 420px);
  }
}

@media (max-width: 760px) {
  .login-panel {
    min-height: auto;
    justify-content: flex-start;
  }

  .login-subtle-credit {
    font-size: 0.74rem;
  }

  .login-badge {
    width: 92px;
    height: 92px;
  }

  .login-hero {
    min-height: 36vh;
  }

  .hero-overlay {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 12px;
    min-height: 148px;
  }

  .hero-logo {
    margin: 0 auto;
    width: 56px;
    height: 56px;
  }

  .hero-center h1 {
    font-size: 1.45rem;
  }

  .nav-btn {
    font-size: 0.92rem;
  }

  .top-user-email {
    max-width: 150px;
    font-size: 0.86rem;
  }

  .top-user-popover {
    min-width: 150px;
  }

  .card {
    padding: 12px;
    border-radius: 10px;
  }

  .stat-card p {
    font-size: 1.4rem;
  }

  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 7px;
    font-size: 0.86rem;
  }

  input,
  select,
  button {
    font-size: 16px;
  }

  .row {
    gap: 6px;
  }

  .module-block {
    padding: 10px;
  }

  .actions-row {
    grid-template-columns: 1fr;
  }

  .qr-reader {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .shell-main {
    padding: 10px;
  }

  .card {
    padding: 10px;
  }

  .login-panel {
    padding: 20px 14px;
  }

  .hero-center h1 {
    font-size: 1.25rem;
  }

  .calendar-grid {
    gap: 4px;
  }

  .cal-cell {
    padding: 6px 4px;
    font-size: 0.8rem;
  }
}
