:root {
  color-scheme: light;
  --primary: #01509a;
  --primary-dark: #00509a;
  --ink: #404040;
  --heading: #13264d;
  --muted: rgba(0, 0, 0, 0.45);
  --line: #cce1f4;
  --table-line: #b3cbe1;
  --paper: #f8fbff;
  --card: #ffffff;
  --danger: #ff5252;
  --danger-bg: #ffe2e2;
  --success: #30af5b;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
  --sider: linear-gradient(261.31deg, #006ccf -29.57%, #00509a 121.11%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Montserrat, "Segoe UI", sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
}

a {
  color: var(--primary);
}

h1 {
  margin: 0 0 20px;
  color: var(--heading);
  font-size: 1.6rem;
  font-weight: 600;
}

label {
  display: block;
  margin-bottom: 16px;
  font-size: 0.875rem;
  font-weight: 500;
}

input,
select {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  color: var(--ink);
  background: white;
}

input:focus,
select:focus {
  outline: 2px solid rgba(1, 80, 154, 0.25);
  border-color: var(--primary);
}

input[type="radio"],
input[type="checkbox"],
input[type="file"] {
  display: inline-block;
  width: auto;
  margin: 0 6px 0 0;
  padding: 0;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin: 0 0 16px;
}

fieldset label {
  display: inline-flex;
  align-items: center;
  margin: 0 16px 0 0;
}

button,
.button {
  font: inherit;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border: 0;
  border-radius: 7px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
}

button:hover,
.button:hover {
  background: var(--primary-dark);
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--sider);
}

.login-card {
  width: min(100%, 420px);
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 36px 32px;
}

.login-card .brand {
  color: var(--primary);
}

.login-card h1 {
  margin-top: 8px;
}

.login-extra {
  margin: -8px 0 16px;
  text-align: right;
}

.login-extra a {
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.brand {
  margin: 0;
  color: white;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: 7px;
  padding: 10px 12px;
}

.shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  overflow: hidden;
}

.sidebar {
  background: var(--sider);
  color: white;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow: auto;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar a {
  color: white;
  text-decoration: none;
  border-radius: 7px;
  padding: 10px 12px;
  font-weight: 500;
}

.sidebar a.brand {
  padding: 0 12px 8px;
  font-size: 1.15rem;
  font-weight: 700;
}

.sidebar a.active,
.sidebar a:hover {
  background: rgba(255, 255, 255, 0.16);
}

.sidebar a.brand:hover {
  background: transparent;
}

.nav-group {
  margin-top: 8px;
}

.nav-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 7px;
  color: white;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-group summary::after {
  content: "";
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
}

.nav-group[open] summary::after {
  transform: rotate(180deg);
}

.nav-group summary:hover,
.nav-group[open] summary {
  background: rgba(255, 255, 255, 0.16);
}

.nav-group a {
  display: block;
  padding-left: 28px;
  font-weight: 400;
}

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

.topbar {
  height: 4.25rem;
  display: grid;
  grid-template-columns: 1fr minmax(240px, 460px) 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 32px;
}

.page-search {
  position: relative;
  grid-column: 2;
  width: 100%;
}

.topbar-actions {
  grid-column: 3;
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-search input {
  width: 100%;
  margin: 0;
  border-radius: 999px;
  padding: 10px 44px;
}

.page-search input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.page-search-icon,
.page-search-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  color: var(--primary);
}

.page-search-icon {
  left: 14px;
  pointer-events: none;
}

.page-search-toggle {
  right: 8px;
  padding: 0;
  background: transparent;
  color: var(--primary);
}

.page-search-toggle:hover,
.page-search-toggle[aria-pressed="true"] {
  background: transparent;
  color: var(--primary-dark);
}

.page-search-menu {
  position: absolute;
  z-index: 6;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  padding: 8px 0 12px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 380px;
  overflow: auto;
}

.page-search-menu[hidden],
.page-search-filter[hidden] {
  display: none;
}

.page-search-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.page-search-filter label {
  display: flex;
  align-items: center;
  margin: 0;
  font-weight: 500;
}

.page-search-results h3 {
  margin: 12px 16px 4px;
  color: var(--primary);
  font-size: 0.95rem;
}

.page-search-results a {
  display: block;
  padding: 10px 16px;
  color: var(--heading);
  font-weight: 600;
  text-decoration: none;
}

.page-search-results a:hover {
  background: rgba(1, 80, 154, 0.06);
}

.linkish {
  background: transparent;
  color: var(--primary);
  padding: 8px 12px;
  text-decoration: none;
}

.linkish:hover {
  background: rgba(1, 80, 154, 0.08);
}

.content {
  padding: 8px 32px 32px;
}

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

.notice {
  color: var(--success);
  font-weight: 600;
}

.toolbar,
.lookup-form,
#table-panel {
  min-width: 0;
}

#table-panel,
.content > table {
  background: var(--card);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

#table-panel table {
  background: transparent;
  box-shadow: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
  padding: 16px;
}

.toolbar form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar a {
  font-weight: 600;
  text-decoration: none;
}

.lookup-form,
.lookup-form form {
  display: grid;
  gap: 4px;
  max-width: 520px;
  margin-bottom: 16px;
  padding: 20px;
}

.lookup-form form {
  padding: 0;
  margin: 0;
  box-shadow: none;
  background: transparent;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--heading);
  font-size: 0.85rem;
  font-weight: 600;
  background: #f8fbff;
}

.row-actions {
  width: 1%;
  white-space: nowrap;
}

td.row-actions {
  white-space: nowrap;
}

td.row-actions .icon-button {
  margin-right: 8px;
  vertical-align: middle;
}

td.row-actions .icon-button:last-child {
  margin-right: 0;
}

.col-filter .row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
  vertical-align: -3px;
}

a.icon-button,
button.icon-button {
  display: inline-flex;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  background: white;
  color: var(--heading);
  border: 1px solid var(--line);
  border-radius: 7px;
}

a.icon-button:hover,
button.icon-button:hover {
  background: #f8fbff;
  color: var(--primary);
}

button.icon-button.danger {
  color: var(--danger);
  border-color: #ffc9c9;
}

button.icon-button.danger:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.ghost,
.row-actions a:not(.icon-button) {
  background: transparent;
  color: var(--primary);
  padding: 0;
  font-weight: 600;
  text-decoration: none;
}

.ghost:hover,
.row-actions a:not(.icon-button):hover {
  background: transparent;
  color: var(--primary-dark);
}

.field-error {
  color: var(--danger);
  font-size: 0.8rem;
}

.settings-index {
  list-style: none;
  margin: 0;
  padding: 8px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 420px;
}

.settings-index a {
  display: block;
  padding: 12px 14px;
  border-radius: 7px;
  text-decoration: none;
  font-weight: 500;
}

.settings-index a:hover {
  background: rgba(1, 80, 154, 0.06);
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.page-head h1 {
  margin: 0;
}

.create-menu {
  position: relative;
}

.create-menu summary {
  list-style: none;
  background: var(--primary);
  color: white;
  font-weight: 600;
  border-radius: 7px;
  padding: 10px 16px;
  cursor: pointer;
}

.create-menu summary::-webkit-details-marker {
  display: none;
}

.create-menu summary:hover {
  background: var(--primary-dark);
}

.create-menu div {
  position: absolute;
  z-index: 4;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 8px;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.create-menu a,
.create-menu span {
  display: block;
  padding: 10px 12px;
  border-radius: 7px;
  color: var(--heading);
  font-weight: 600;
  text-decoration: none;
}

.create-menu a:hover {
  background: rgba(1, 80, 154, 0.06);
}

.create-menu span {
  color: #b3b3b3;
}

.pager {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
}

.pager > span:first-child {
  margin-right: auto;
}

.pager a,
.pager .current,
.pager .ellipsis {
  min-width: 2rem;
  padding: 4px 8px;
  border-radius: 7px;
  text-align: center;
  text-decoration: none;
  font-weight: 600;
}

.pager a {
  color: var(--primary);
}

.pager .current {
  background: var(--primary);
  color: white;
}

.page-size {
  margin: 0 0 0 8px;
}

.page-size select {
  width: auto;
  margin: 0;
  padding: 4px 8px;
  font-size: 0.85rem;
}

.record-form {
  display: grid;
  gap: 4px;
}

.combo {
  position: relative;
}

.combo-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 240px;
  overflow: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: white;
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.combo-menu li {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.combo-menu li.muted {
  cursor: default;
}

.combo-menu li.active,
.combo-menu li[data-value]:hover {
  background: rgba(1, 80, 154, 0.08);
}

.record-form h2,
.modal h2 {
  margin: 0 0 16px;
  color: var(--heading);
  font-size: 1.15rem;
}

.modal {
  width: min(640px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal::backdrop {
  background: rgba(19, 38, 77, 0.45);
}

.modal-dismiss {
  position: absolute;
  top: 12px;
  right: 12px;
}

.modal-dismiss button {
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0 6px;
}

.import-switch {
  display: grid;
}

.import-switch > input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.import-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.import-tabs label {
  margin: 0;
  padding: 10px 4px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

#import-return:checked ~ .import-tabs label[for="import-return"],
#import-sheet:checked ~ .import-tabs label[for="import-sheet"] {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.import-panel {
  display: none;
  gap: 12px;
}

#import-return:checked ~ .import-panel[data-panel="return"],
#import-sheet:checked ~ .import-panel[data-panel="sheet"] {
  display: grid;
}

.import-panel .muted {
  margin: 0;
}

a.button.secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  background: white;
  color: var(--primary);
  border: 1px solid var(--line);
}

a.button.secondary:hover {
  background: #f8fbff;
}

.file-drop {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 6px;
  margin: 0;
  padding: 24px 16px;
  border: 1px dashed var(--primary);
  border-radius: 8px;
  background: #f8fbff;
  color: var(--heading);
  font-weight: 600;
  cursor: pointer;
}

.file-drop .file-name {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.file-drop input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.col-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.col-head > a {
  color: var(--heading);
  text-decoration: none;
}

.col-filter {
  position: relative;
  margin-left: auto;
}

.col-filter summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--primary);
  cursor: pointer;
  list-style: none;
}

th {
  white-space: nowrap;
}

.col-filter.active summary {
  color: var(--primary);
  background: rgba(1, 80, 154, 0.08);
  border-color: var(--primary);
}

.col-filter summary::-webkit-details-marker {
  display: none;
}

.col-filter form {
  position: absolute;
  z-index: 3;
  top: calc(100% + 6px);
  right: 0;
  width: 240px;
  padding: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filter-options {
  max-height: 220px;
  overflow: auto;
  margin-bottom: 8px;
}

.filter-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-weight: 400;
}

@media (max-width: 800px) {
  .shell {
    height: auto;
    overflow: visible;
    grid-template-columns: 1fr;
  }

  .main {
    overflow: visible;
  }

  .sidebar nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .nav-group {
    width: 100%;
  }

  .content,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }
}
