* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: #f5f6f8;
  color: #1f2937;
}

a {
  color: #1d4ed8;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid #60a5fa;
  outline-offset: 2px;
}

.topbar {
  background: #111827;
  color: white;
  min-height: 54px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  z-index: 100;
}

.brand {
  color: #f9fafb;
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
  margin-right: 12px;
  padding: 18px 0;
  white-space: nowrap;
}

.brand:hover {
  color: white;
  text-decoration: none;
}

.menu-toggle {
  display: none;
}

.nav-shell {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.nav-dashboard,
.nav-group-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: #d1d5db;
  display: flex;
  font-size: 14px;
  font-weight: 600;
  gap: 5px;
  height: 100%;
  padding: 0 11px;
  white-space: nowrap;
}

.nav-dashboard:hover,
.nav-dashboard.active,
.nav-group:hover > .nav-group-toggle,
.nav-group.active > .nav-group-toggle,
.nav-group.is-open > .nav-group-toggle {
  background: #1f2937;
  color: white;
  text-decoration: none;
}

.nav-group {
  position: relative;
}

.dropdown-arrow {
  color: #9ca3af;
  font-size: 11px;
}

.nav-dropdown {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
  display: none;
  left: 0;
  min-width: 220px;
  padding: 6px;
  position: absolute;
  top: calc(100% - 1px);
}

.nav-mega-menu {
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  max-width: min(720px, calc(100vw - 32px));
  min-width: 280px;
}

.nav-list-menu {
  gap: 10px;
  grid-template-columns: minmax(170px, auto) minmax(320px, 1fr);
  max-width: min(880px, calc(100vw - 32px));
}

.nav-list-modules {
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 8px;
}

.nav-list-module-toggle {
  background: transparent;
  border: 0;
  border-radius: 5px;
  color: #1f2937;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 11px;
  text-align: left;
  white-space: nowrap;
}

.nav-list-module-toggle:hover {
  background: #f3f4f6;
}

.nav-list-module-toggle.is-selected {
  background: #eef2ff;
  color: #3730a3;
}

.nav-list-module-toggle.active {
  color: #1e40af;
}

.nav-list-panels {
  min-width: 0;
}

.nav-list-panel {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.nav-section {
  min-width: 0;
}

.nav-section-title {
  color: #6b7280;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  margin: 0;
  padding: 7px 11px 4px;
  text-transform: uppercase;
  white-space: nowrap;
}

.nav-section-links {
  display: grid;
}

.nav-group:hover .nav-dropdown,
.nav-group.is-open .nav-dropdown {
  display: grid;
}

.nav-dropdown a {
  border-radius: 5px;
  color: #1f2937;
  font-size: 14px;
  padding: 9px 11px;
  white-space: nowrap;
}

.nav-dropdown a:hover {
  background: #f3f4f6;
  text-decoration: none;
}

.nav-dropdown a.active {
  background: #dbeafe;
  color: #1e40af;
  font-weight: 700;
}

.userbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  min-width: 0;
  padding-left: 10px;
}

.working-location {
  display: flex;
  align-items: center;
  gap: 6px;
}

.working-location select {
  background: #1f2937;
  color: #e5e7eb;
  border: 1px solid #4b5563;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  max-width: 240px;
}

.working-location button {
  background: transparent;
  color: #e5e7eb;
  border: 1px solid #6b7280;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.user-identity {
  color: #d1d5db;
  font-size: 13px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout {
  display: inline;
}

.logout button {
  background: transparent;
  color: #e5e7eb;
  border: 1px solid #6b7280;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.logout button:hover {
  background: #1f2937;
  border-color: #9ca3af;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px;
}

.card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.page-heading,
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin: 0 0 16px;
  padding: 6px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
}

.section-tabs a {
  white-space: nowrap;
  padding: 7px 10px;
  border-radius: 6px;
  text-decoration: none;
}

.section-tabs a:hover {
  background: #f3f4f6;
}

.detail-section {
  scroll-margin-top: 80px;
}

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

.detail-grid div {
  min-width: 0;
}

.detail-grid dt {
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
}

.detail-grid dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

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

.grid {
  display: grid;
  gap: 16px;
}

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

.stat {
  font-size: 32px;
  font-weight: 700;
}

.muted {
  color: #6b7280;
}

.helper-text {
  color: #6b7280;
  font-size: 13px;
  margin-top: 6px;
}

.form-message {
  border-radius: 6px;
  font-size: 14px;
  margin-top: 8px;
  padding: 9px 10px;
}

.form-message-warning {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}

.button-small {
  font-size: 13px;
  margin-top: 8px;
  padding: 6px 9px;
}

.switch-control {
  display: inline-block;
  height: 24px;
  position: relative;
  width: 44px;
}

.switch-control input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.switch-slider {
  background: #9ca3af;
  border-radius: 999px;
  cursor: pointer;
  inset: 0;
  position: absolute;
  transition: background .15s ease;
}

.switch-slider::before {
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  content: "";
  height: 18px;
  left: 3px;
  position: absolute;
  top: 3px;
  transition: transform .15s ease;
  width: 18px;
}

.switch-control input:checked + .switch-slider {
  background: #2563eb;
}

.switch-control input:checked + .switch-slider::before {
  transform: translateX(20px);
}

.switch-control input:focus-visible + .switch-slider {
  outline: 3px solid #60a5fa;
  outline-offset: 2px;
}

.switch-control input:disabled + .switch-slider {
  cursor: wait;
  opacity: .65;
}

[hidden] {
  display: none !important;
}

.table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: white;
}

.table th,
.table td {
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  padding: 10px;
  vertical-align: top;
}

.table th {
  background: #f9fafb;
  font-weight: 700;
}

.form-row {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

input,
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font: inherit;
}

input[type="checkbox"] {
  width: auto;
  min-width: 18px;
  height: 18px;
}

textarea {
  min-height: 80px;
}

button,
.button {
  display: inline-block;
  background: #1f2937;
  color: white;
  border: 0;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
}

.button-secondary {
  background: #6b7280;
}

.button-danger {
  background: #991b1b;
}

.inline {
  display: inline;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: #e5e7eb;
}

.badge-here {
  background: #dcfce7;
  color: #166534;
}

.badge-away {
  background: #fee2e2;
  color: #991b1b;
}

.flash {
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.flash-success {
  background: #dcfce7;
  color: #166534;
}

.error-box {
  background: #fee2e2;
  color: #991b1b;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.login-wrap {
  max-width: 420px;
  margin: 70px auto;
}

@media (max-width: 1100px) {
  .topbar {
    flex-wrap: wrap;
    min-height: 52px;
    padding: 0 14px;
  }

  .brand {
    margin-right: 0;
  }

  .menu-toggle {
    align-items: center;
    background: transparent;
    border: 1px solid #4b5563;
    color: #f9fafb;
    display: flex;
    gap: 8px;
    margin-left: auto;
    padding: 7px 10px;
  }

  .menu-toggle-icon,
  .menu-toggle-icon::before,
  .menu-toggle-icon::after {
    background: currentColor;
    content: "";
    display: block;
    height: 2px;
    width: 17px;
  }

  .menu-toggle-icon {
    position: relative;
  }

  .menu-toggle-icon::before {
    left: 0;
    position: absolute;
    top: -5px;
  }

  .menu-toggle-icon::after {
    left: 0;
    position: absolute;
    top: 5px;
  }

  .nav-shell {
    background: #111827;
    border-top: 1px solid #374151;
    display: none;
    flex: 0 0 calc(100% + 28px);
    flex-direction: column;
    margin: 0 -14px;
    order: 4;
    padding: 8px 14px 14px;
  }

  .topbar.nav-open .nav-shell {
    display: flex;
  }

  .nav-dashboard,
  .nav-group-toggle {
    border-radius: 5px;
    height: auto;
    justify-content: space-between;
    padding: 10px;
    width: 100%;
  }

  .nav-group:hover .nav-dropdown {
    display: none;
  }

  .nav-group.is-open .nav-dropdown {
    display: grid;
  }

  .nav-dropdown {
    background: #1f2937;
    border: 0;
    border-radius: 5px;
    box-shadow: none;
    margin: 0 0 5px;
    min-width: 0;
    padding: 5px;
    position: static;
  }

  .nav-mega-menu {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .nav-list-menu {
    grid-template-columns: 1fr;
    max-width: none;
  }

  .nav-list-modules {
    border-bottom: 1px solid #374151;
    border-right: 0;
    padding: 0 0 6px;
  }

  .nav-list-module-toggle {
    color: #e5e7eb;
  }

  .nav-list-module-toggle:hover {
    background: #374151;
  }

  .nav-list-module-toggle.is-selected {
    background: #1e3a5f;
    color: #bfdbfe;
  }

  .nav-section-title {
    color: #9ca3af;
    padding-left: 18px;
  }

  .nav-dropdown a {
    color: #e5e7eb;
    padding-left: 18px;
    white-space: normal;
  }

  .nav-dropdown a:hover {
    background: #374151;
  }

  .nav-dropdown a.active {
    background: #1e3a5f;
    color: #bfdbfe;
  }

  .userbar {
    flex: 0 1 auto;
  }
}

@media (max-width: 620px) {
  .userbar {
    border-top: 1px solid #374151;
    flex: 0 0 calc(100% + 28px);
    justify-content: space-between;
    margin: 0 -14px;
    order: 3;
    padding: 8px 14px;
  }

  .user-identity {
    max-width: calc(100vw - 115px);
  }
}

@media (max-width: 900px) {
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-heading,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .detail-grid .detail-wide {
    grid-column: auto;
  }

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

  .card {
    overflow-x: auto;
  }
}

/* Page customization: subtle lowercase "i" marker for customized pages and
   compact numeric inputs on the field customization table. */
.customized-marker {
  display: inline-block;
  font-style: italic;
  font-weight: 700;
  font-size: 0.75em;
  line-height: 1;
  margin-right: 0.3em;
  opacity: 0.65;
  vertical-align: super;
}

.input-narrow {
  width: 5rem;
}
