:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-2: #f9fbff;
  --ink: #17202c;
  --muted: #667085;
  --line: #d8dee9;
  --brand: #2563eb;
  --brand-2: #0891b2;
  --ok: #12805c;
  --warn: #b7791f;
  --danger: #c2410c;
  --nav: #141a24;
  --nav-2: #202938;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.10);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(420px, 1.08fr);
  background:
    linear-gradient(120deg, rgba(37, 99, 235, 0.12), transparent 34%),
    linear-gradient(150deg, rgba(8, 145, 178, 0.12), transparent 45%),
    var(--bg);
}

.login-brief {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 56px;
  background: var(--nav);
  color: #fff;
}

.login-brief h1 {
  max-width: 620px;
  margin: 0;
  font-size: clamp(36px, 5vw, 68px);
  line-height: 0.98;
  font-weight: 760;
}

.login-brief p {
  max-width: 560px;
  margin: 22px 0 0;
  color: #cbd5e1;
  font-size: 17px;
  line-height: 1.7;
}

.login-card {
  width: min(460px, calc(100vw - 40px));
  align-self: center;
  justify-self: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 30px;
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

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

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field label {
  color: #344054;
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  font-weight: 650;
}

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  color: inherit;
}

.btn.danger {
  border-color: #fed7aa;
  color: var(--danger);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

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

.sidebar {
  background: var(--nav);
  color: #e5e7eb;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 10px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 15px;
}

.brand span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #aab3c2;
}

.nav {
  display: grid;
  gap: 4px;
  overflow: auto;
  padding-right: 2px;
}

.nav button {
  width: 100%;
  min-height: 38px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #cbd5e1;
  padding: 8px 10px;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: var(--nav-2);
  color: #fff;
}

.nav .ico {
  width: 24px;
  text-align: center;
  color: #8ec5ff;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
}

.title-block h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.title-block p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.user-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 11px;
  background: #fff;
  color: #344054;
  font-size: 13px;
}

.content {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
}

.stat {
  min-height: 96px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 25px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}

.panel-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 16px;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.filters input,
.filters select {
  width: 160px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  font-size: 13px;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: #475467;
  background: var(--panel-2);
  font-size: 12px;
  font-weight: 750;
}

td {
  color: #263244;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #eef2ff;
  color: #3730a3;
}

.status.enabled,
.status.active,
.status.approved,
.status.open {
  background: #dcfce7;
  color: #166534;
}

.status.pending {
  background: #fef3c7;
  color: #92400e;
}

.status.disabled,
.status.rejected,
.status.closed,
.status.cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.empty {
  padding: 26px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  display: grid;
  gap: 8px;
}

.toast div {
  max-width: 380px;
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 11px 13px;
  box-shadow: var(--shadow);
}

.toast .err {
  background: #991b1b;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.54);
  padding: 18px;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: min(760px, 100%);
  max-height: min(86vh, 840px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
}

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

.mobile-menu {
  display: none;
}

@media (max-width: 1100px) {
  .stats {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }
}

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

  .login-brief {
    min-height: 260px;
    padding: 34px 24px;
  }

  .login-card {
    margin: 26px 0;
  }

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 280px;
    z-index: 18;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-menu {
    display: inline-flex;
  }

  .topbar {
    align-items: flex-start;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

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

@media (max-width: 560px) {
  .content,
  .topbar {
    padding-left: 14px;
    padding-right: 14px;
  }

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

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .filters input,
  .filters select,
  .filters .btn {
    width: 100%;
  }
}
