:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #d7dee8;
  --surface: #ffffff;
  --soft: #f6f8fb;
  --page: #eef4f8;
  --green: #0f8a5f;
  --green-soft: #dff7ed;
  --red: #bc2f36;
  --red-soft: #ffe5e8;
  --amber: #a86600;
  --amber-soft: #fff0cc;
  --blue: #1557a6;
  --blue-soft: #e6f0ff;
  --violet: #6846a5;
  --violet-soft: #eee8ff;
  --shadow: 0 12px 34px rgba(15, 23, 42, 0.07);
  --shadow-soft: 0 4px 14px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f5f9fc 0%, var(--page) 220px);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

body.locked .app-layout {
  display: none;
}

.login-screen {
  align-items: center;
  background: linear-gradient(180deg, #f7fbff 0%, #eef4f8 100%);
  display: none;
  min-height: 100vh;
  padding: 24px;
  justify-content: center;
}

body.locked .login-screen {
  display: flex;
}

.login-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.12);
  margin: 0 auto;
  max-width: 430px;
  padding: 32px;
  width: 100%;
}

.login-box h1 {
  font-size: 34px;
  margin-bottom: 8px;
}

.login-box p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 18px;
}

.login-box input,
.login-box button {
  margin-top: 10px;
  width: 100%;
}

#loginError {
  color: var(--red);
  font-size: 13px;
  margin-top: 12px;
  min-height: 18px;
}

button,
input,
select {
  font: inherit;
}

.app-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.side-nav {
  background: rgba(255, 255, 255, 0.94);
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 34px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-block {
  border-bottom: 1px solid var(--line);
  padding: 6px 6px 18px;
}

.brand-block strong {
  display: block;
  font-size: 18px;
  font-weight: 600;
}

.brand-block span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 6px;
}

.sidebar-user {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 10px;
  grid-template-columns: 42px minmax(0, 1fr);
  padding: 10px;
}

.user-avatar {
  align-items: center;
  background: #dbeafe;
  border: 1px solid #bfdbfe;
  border-radius: 50%;
  color: var(--blue);
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.sidebar-user strong,
.sidebar-user span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user strong {
  font-size: 14px;
}

.sidebar-user span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

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

.nav-item {
  background: transparent;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 650;
  justify-content: flex-start;
  min-height: 42px;
  padding: 0 12px;
  text-align: left;
  white-space: normal;
}

.nav-item:hover {
  background: #edf4ff;
  filter: none;
}

.nav-item.active {
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(21, 87, 166, 0.18);
  color: #fff;
}

.logout-item {
  align-self: end;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  margin-top: auto;
  color: var(--red);
  width: 100%;
}

.app-shell {
  width: min(1520px, calc(100% - 36px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.view-panel {
  display: block;
}

.view-panel[hidden],
[hidden] {
  display: none !important;
}

.section-head {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 12px;
  padding: 16px 18px;
}

.section-head.compact {
  margin-top: 16px;
}

.section-head p {
  color: var(--muted);
  margin: 6px 0 0;
}

.gsm-date-row {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 12px;
}

.compact-date {
  min-width: 210px;
}

.admin-form-grid {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  margin-bottom: 12px;
  padding: 12px;
}

.admin-form-grid.reset-grid {
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
}

.status-line {
  color: var(--muted);
  font-size: 13px;
  min-height: 18px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 24px;
}

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

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 2.5vw, 42px);
  line-height: 1.08;
}

h2 {
  font-size: 18px;
}

.subtitle {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  margin: 8px 0 0;
  max-width: 760px;
}

.topbar-meta {
  align-items: stretch;
  display: flex;
  gap: 10px;
}

.session-status {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  line-height: 1.35;
  max-width: 220px;
  padding: 10px 12px;
}

.sync-btn {
  align-self: stretch;
  min-height: 69px;
  padding: 0 16px;
}

.sync-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.sync-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  min-width: 170px;
  padding: 12px 14px;
}

.sync-box span,
label span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.sync-box strong {
  font-size: 16px;
}

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

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 112px;
  padding: 16px;
}

.metric-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
}

.metric-card strong {
  display: block;
  font-size: 30px;
  line-height: 1;
}

.metric-card p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin: 10px 0 0;
}

.controls {
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 12px;
  grid-template-columns: 1.8fr 1fr 1fr 1fr auto;
  margin-bottom: 14px;
  padding: 14px;
}

.import-panel {
  align-items: end;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbfe 100%);
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(220px, 1fr) 210px auto minmax(260px, 340px);
  margin-bottom: 14px;
  padding: 14px 16px;
}

.date-picker span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

.date-picker input {
  height: 42px;
}

.import-panel p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.45;
  margin: 8px 0 0;
}

.import-actions {
  align-items: end;
  display: flex;
  gap: 8px;
}

.file-picker {
  align-items: center;
  background: var(--blue);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  height: 42px;
  justify-content: center;
  padding: 0 14px;
  white-space: nowrap;
}

.file-picker input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.file-picker span {
  color: #fff;
  font-size: 14px;
  margin: 0;
}

.file-picker.is-disabled {
  background: #d9e1ec;
  color: #667085;
  cursor: not-allowed;
}

.file-picker.is-disabled span {
  color: #667085;
}

.import-status {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  min-height: 42px;
  line-height: 1.4;
  padding: 12px;
}

.auth-panel {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
  grid-template-columns: 180px 180px auto auto minmax(220px, 1fr);
  margin-bottom: 14px;
  padding: 12px 14px;
}

.admin-sidebar {
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 40px rgba(20, 33, 61, 0.12);
  display: grid;
  gap: 18px;
  grid-auto-rows: max-content;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  position: fixed;
  right: 0;
  top: 0;
  width: min(420px, 100%);
  z-index: 10;
}

.sidebar-head {
  align-items: start;
  display: flex;
  justify-content: space-between;
}

.admin-sidebar section {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 16px;
}

.admin-sidebar h3 {
  font-size: 15px;
  margin: 0;
}

#createUserStatus {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.auth-panel input {
  height: 38px;
}

.auth-panel button {
  height: 38px;
}

#authStatus {
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  background: #fbfdff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: var(--ink);
  height: 42px;
  outline: none;
  padding: 0 12px;
  width: 100%;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(30, 90, 167, 0.14);
}

select:disabled,
input:disabled {
  background: #eef2f7;
  color: #475467;
  cursor: not-allowed;
}

.button-row {
  display: flex;
  gap: 8px;
}

button {
  background: var(--blue);
  border: 0;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 650;
  height: 42px;
  padding: 0 14px;
  white-space: nowrap;
}

button:hover {
  filter: brightness(0.97);
}

button.secondary {
  background: #eef2f7;
  color: var(--ink);
}

button.danger {
  background: #c62828;
}

.account-actions {
  display: grid;
  gap: 8px;
  margin-top: auto;
}

.split-panel {
  display: grid;
  gap: 14px;
  grid-template-columns: 340px minmax(0, 1fr);
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-chip {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
}

.filter-chip strong {
  color: var(--blue);
}

.filter-chip span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.filter-chip.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.filter-chip.active strong,
.filter-chip.active span {
  color: #fff;
}

.insight-panel,
.table-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-soft);
  min-width: 0;
  overflow: hidden;
}

.gsm-list-panel,
.user-list-panel {
  margin-top: 12px;
}

.gsm-table-wrap,
.user-table-wrap {
  min-height: 360px;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: #f8fbff;
}

.panel-head,
.table-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 18px;
}

.panel-head span,
.table-head p {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.issue-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.issue-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  padding: 12px;
}

.issue-card:hover {
  background: var(--soft);
}

.issue-card strong {
  display: flex;
  font-size: 24px;
  justify-content: space-between;
  line-height: 1;
}

.issue-card span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 8px;
}

.table-wrap {
  max-height: calc(100vh - 300px);
  min-height: 500px;
  overflow: auto;
}

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

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

th {
  background: #f6f8fb;
  color: #475467;
  font-size: 12px;
  font-weight: 700;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

td {
  font-size: 13px;
}

tr {
  cursor: pointer;
}

tbody tr:nth-child(even) td {
  background: #fcfdff;
}

tr:hover td,
tbody tr:nth-child(even):hover td {
  background: #f7fbff;
}

.main-text {
  display: block;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.sub-text {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.45;
  margin-top: 4px;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  padding: 7px 9px;
}

.badge.ok {
  background: var(--green-soft);
  color: var(--green);
}

.badge.bad {
  background: var(--red-soft);
  color: var(--red);
}

.badge.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.info {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge.extra {
  background: var(--violet-soft);
  color: var(--violet);
}

dialog {
  border: 0;
  border-radius: 10px;
  box-shadow: 0 28px 90px rgba(20, 33, 61, 0.24);
  max-width: 820px;
  padding: 0;
  width: min(calc(100% - 24px), 820px);
}

.reset-dialog {
  max-width: 520px;
}

.muted-line {
  color: var(--muted);
  margin: 0;
}

dialog::backdrop {
  background: rgba(20, 33, 61, 0.45);
}

.dialog-head {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 18px;
}

.icon-btn {
  align-items: center;
  background: #eef2f7;
  color: var(--ink);
  display: inline-flex;
  font-size: 26px;
  height: 36px;
  justify-content: center;
  padding: 0;
  width: 36px;
}

.dialog-content {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.detail-box {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.detail-box h3 {
  font-size: 14px;
  margin: 0 0 10px;
}

.detail-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 120px minmax(0, 1fr);
  padding: 6px 0;
}

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

.empty {
  color: var(--muted);
  padding: 32px;
  text-align: center;
}

@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .side-nav {
    height: auto;
    position: static;
  }

  .logout-item {
    margin-top: 8px;
  }

  .topbar-meta {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

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

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

  .import-panel {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    grid-template-columns: 1fr;
  }


  .button-row {
    grid-column: 1 / -1;
  }

  .split-panel {
    grid-template-columns: 1fr;
  }

  .admin-form-grid,
  .admin-form-grid.reset-grid {
    grid-template-columns: 1fr;
  }

  .table-wrap {
    max-height: none;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1520px);
    padding-top: 18px;
  }

  .topbar {
    align-items: stretch;
    display: grid;
  }

  .topbar-meta {
    display: grid;
  }

  .metrics-grid,
  .controls,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .button-row {
    display: grid;
  }
}
