@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&display=swap');

:root {
  --bg: #edf3f8;
  --panel: #ffffff;
  --ink: #112a46;
  --muted: #4f6780;
  --brand: #005f8f;
  --brand-strong: #0a4f76;
  --brand-soft: #dcecf7;
  --brand-glow: #9bd0ef;
  --accent: #ffb703;
  --accent-soft: #fff4d6;
  --border: #d4e0eb;
  --shadow: 0 12px 26px rgba(14, 52, 89, .12);
  --danger: #b42318;
}

* { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 620px at 100% -90px, #d5eafb 5%, transparent 60%),
    radial-gradient(900px 420px at -160px 120px, #e6f2fb 8%, transparent 65%),
    linear-gradient(180deg, #f6fbff 0%, var(--bg) 52%);
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-card {
  width: min(420px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.4rem;
  box-shadow: 0 20px 35px rgba(16, 42, 67, 0.1);
}

.auth-card form,
.filters-grid,
#importForm {
  display: grid;
  gap: .7rem;
}

.auth-card input,
.filters-grid input,
.filters-grid select,
#importForm select,
#importForm input {
  padding: .65rem .7rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
}

button {
  border: none;
  border-radius: 10px;
  padding: .65rem .9rem;
  font-family: inherit;
  font-weight: 700;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 7px 14px rgba(0, 95, 143, .24);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(0, 95, 143, .28);
  filter: saturate(1.07);
}

button:active {
  transform: translateY(0);
}

.btn-secondary {
  background: linear-gradient(135deg, #355878, #2b4b67);
  box-shadow: 0 7px 14px rgba(43, 75, 103, .26);
}

.topbar {
  padding: 1rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #c8d8e7;
  background:
    linear-gradient(95deg, rgba(255,255,255,.96), rgba(233,244,252,.94)),
    linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,.9));
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 8px 22px rgba(16, 42, 67, .08);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  position: relative;
}

.password-panel {
  padding: .7rem .8rem;
}

.password-panel h2 {
  margin: 0 0 .5rem;
  font-size: 1.05rem;
}

.password-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr) minmax(170px, 1fr) auto;
  gap: .45rem;
  align-items: center;
}

.password-form input {
  padding: .5rem .55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 0;
}

#passwordStatus {
  margin: .45rem 0 0;
  min-height: 1rem;
  font-size: .9rem;
}

.topbar h1 { margin: 0; }
.topbar p { margin: .25rem 0 0; color: var(--muted); font-size: .9rem; }

.profile-menu {
  position: relative;
}

.profile-btn {
  border: 1px solid #b8d0e2;
  background: linear-gradient(180deg, #ffffff, #f3f9fe);
  color: #0e2c49;
  padding: .45rem .75rem;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 6px 12px rgba(31, 87, 130, .11);
}

.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + .35rem);
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(16, 42, 67, .12);
  padding: .35rem;
  display: none;
  z-index: 30;
}

.profile-dropdown.open {
  display: block;
}

.profile-dropdown button {
  width: 100%;
  text-align: left;
  background: #fff;
  color: var(--ink);
  padding: .55rem .65rem;
  border-radius: 8px;
  font-weight: 600;
}

.profile-dropdown button:hover {
  background: var(--brand-soft);
}

.container {
  width: min(1260px, 96vw);
  margin: 1rem auto 2rem;
  display: grid;
  gap: 1rem;
  min-width: 0;
  animation: fadeIn .3s ease-out both;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .8rem;
}

.card,
.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 14px;
  padding: .9rem;
  min-width: 0;
  box-shadow: var(--shadow);
}

.card strong {
  font-size: 1.5rem;
  display: block;
  margin-top: .4rem;
  color: #0b3f66;
}

.card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--brand-glow));
}

.cards .card:nth-child(2)::before { background: linear-gradient(90deg, #1f7a5d, #5dc7a0); }
.cards .card:nth-child(3)::before { background: linear-gradient(90deg, #0f5f8f, #4aa7d8); }
.cards .card:nth-child(4)::before { background: linear-gradient(90deg, #8a5b00, #ffb703); }
.cards .card:nth-child(5)::before { background: linear-gradient(90deg, #7f1d1d, #ef4444); }
.cards .card:nth-child(6)::before { background: linear-gradient(90deg, #6b21a8, #a855f7); }
.cards .card:nth-child(7)::before { background: linear-gradient(90deg, #374151, #94a3b8); }

.panel h2 {
  margin: .05rem 0 .8rem;
  font-size: 1.05rem;
  color: #0f3656;
}

.filters-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  min-width: 0;
}

.filter-actions { margin-top: .75rem; display: flex; gap: .5rem; flex-wrap: wrap; }

.chips {
  margin-top: .6rem;
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}

.chips span {
  background: linear-gradient(180deg, #edf7fd, var(--brand-soft));
  color: #0d4864;
  border: 1px solid #c8e1f1;
  border-radius: 999px;
  padding: .25rem .55rem;
  font-size: .8rem;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  max-height: 520px;
  min-width: 0;
}

table {
  width: max(100%, 1100px);
  border-collapse: collapse;
  font-size: .92rem;
}

#importForm input[type="file"] {
  width: 100%;
  min-width: 0;
}

.import-panel {
  padding: .7rem .8rem;
}

.import-panel h2 {
  margin: 0 0 .5rem;
  font-size: 1.05rem;
}

#importForm {
  grid-template-columns: minmax(220px, 2fr) minmax(180px, 1fr) auto;
  align-items: center;
  gap: .45rem;
}

#importForm input,
#importForm select {
  padding: .45rem .55rem;
}

#importForm button {
  padding: .5rem .8rem;
  white-space: nowrap;
}

#importStatus {
  margin: .4rem 0 0;
  min-height: 1rem;
  font-size: .9rem;
}

thead th {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #eef7fc, #deecf7);
  cursor: pointer;
  z-index: 1;
  color: #103756;
  font-weight: 700;
}

th, td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: .55rem;
  white-space: nowrap;
}

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

tbody tr:hover {
  background: #ecf6fd;
}

.pager {
  margin-top: .7rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

.error { color: var(--danger); min-height: 1.2rem; }

.bars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: .6rem;
  align-items: end;
  min-height: 180px;
}

.bar {
  background: linear-gradient(180deg, #2da0bf, #0f5e84);
  border-radius: 8px 8px 4px 4px;
  color: #fff;
  text-align: center;
  font-size: .78rem;
  padding-top: .35rem;
  box-shadow: 0 8px 15px rgba(21, 111, 153, .22);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; gap: .6rem; }
  .topbar-actions { justify-content: flex-start; }
  .profile-dropdown {
    left: 0;
    right: auto;
  }
  .filters-grid { grid-template-columns: 1fr; }
  #importForm { grid-template-columns: 1fr; }
  .password-form { grid-template-columns: 1fr; }
}
