:root {
  --bg: #f3f5f8;
  --ink: #182233;
  --muted: #748094;
  --line: #e4e8ef;
  --teal: #0d9488;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px system-ui, -apple-system, Segoe UI, Arial;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 11px;
  padding: 10px 14px;
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login form {
  background: #fff;
  padding: 28px;
  border-radius: 22px;
  width: min(420px, 100%);
  box-shadow: 0 16px 50px #14243a12;
}

.logo {
  font-size: 40px;
}

.login h1 {
  margin: 4px 0;
}

.login p {
  color: var(--muted);
  margin: 0 0 24px;
}

.login label {
  display: grid;
  gap: 8px;
  font-weight: 650;
}

.login input,
.field input,
.field select,
.field textarea,
.search {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  width: 100%;
}

.primary {
  background: var(--teal);
  color: #fff;
  font-weight: 700;
}

.secondary {
  background: #edf1f5;
  color: #263244;
}

.danger {
  background: #fee4e2;
  color: var(--danger);
  font-weight: 700;
}

.login .primary {
  width: 100%;
  margin-top: 16px;
}

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

aside {
  background: #111827;
  color: #fff;
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  font-size: 19px;
  font-weight: 750;
  padding: 8px;
}

nav {
  display: grid;
  gap: 5px;
}

nav button {
  background: transparent;
  color: #c6ced9;
  text-align: left;
  padding: 12px;
}

nav button.active,
nav button:hover {
  background: #ffffff16;
  color: #fff;
}

.logout {
  margin-top: auto;
  background: #ffffff14;
  color: #fff;
  text-decoration: none;
  padding: 11px;
  border-radius: 10px;
}

main {
  min-width: 0;
  padding: 25px clamp(14px, 3vw, 32px);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

header small {
  letter-spacing: .14em;
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
}

h1 {
  margin: 4px 0;
  font-size: 30px;
}

.refresh {
  background: #fff;
  border: 1px solid var(--line);
  font-size: 22px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 18px;
}

.card,
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 17px;
  padding: 17px;
}

.label {
  color: var(--muted);
  font-size: 13px;
}

.value {
  font-size: clamp(21px, 2.5vw, 29px);
  font-weight: 750;
  margin-top: 7px;
}

.loading {
  color: var(--muted);
}

.panelhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panelhead h2 {
  margin: 0;
  font-size: 17px;
}

.toolbar {
  display: flex;
  gap: 8px;
}

.wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 680px;
  background: #fff;
}

th,
td {
  text-align: left;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  background: #fafbfc;
  font-size: 12px;
}

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

.modal {
  position: fixed;
  inset: 0;
  background: #101827aa;
  display: grid;
  place-items: center;
  padding: 15px;
  z-index: 9;
}

.modalcard {
  background: #fff;
  border-radius: 20px;
  padding: 21px;
  width: min(640px, 100%);
  max-height: 90dvh;
  overflow: auto;
}

.modalhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modalhead h2 {
  margin: 0 0 16px;
}

.modalhead button {
  background: #eef1f5;
  font-size: 22px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 700;
  color: #4b5563;
}

.required-mark {
  color: var(--danger);
}

.field textarea {
  min-height: 85px;
}

.field.full {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 17px;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  background: #111827;
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  opacity: 0;
  transform: translateY(12px);
  transition: .2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  aside {
    position: sticky;
    top: 0;
    z-index: 4;
    padding: 8px;
  }

  .brand {
    padding: 5px;
  }

  nav {
    display: flex;
    overflow: auto;
  }

  nav button {
    white-space: nowrap;
    padding: 10px;
    font-size: 13px;
  }

  .logout {
    display: none;
  }

  main {
    padding: 15px 12px;
  }

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

@media (max-width: 520px) {
  nav button {
    font-size: 0;
  }

  nav button::first-letter {
    font-size: 18px;
  }

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

  .field.full {
    grid-column: auto;
  }

  .panelhead {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
  }

  .search {
    flex: 1;
    min-width: 100px;
  }
}

