:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #101a2b;
  --panel-2: #172338;
  --panel-3: #1d2a40;
  --line: #2c3d58;
  --line-strong: #3b82f6;
  --text: #f8fafc;
  --muted: #9fb0c7;
  --blue: #3b82f6;
  --cyan: #22d3ee;
  --green: #10b981;
  --green-dark: #0f9f7a;
  --red: #b91c1c;
  --amber: #eab308;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(circle at 16% 8%, rgba(59, 130, 246, 0.16), transparent 34%), var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
}

body::-webkit-scrollbar,
.records::-webkit-scrollbar {
  width: 10px;
}

body::-webkit-scrollbar-track,
.records::-webkit-scrollbar-track {
  background: #0a111e;
  border-radius: 999px;
}

body::-webkit-scrollbar-thumb,
.records::-webkit-scrollbar-thumb {
  background: rgba(159, 176, 199, 0.5);
  border: 2px solid #0a111e;
  border-radius: 999px;
}

body::-webkit-scrollbar-thumb:hover,
.records::-webkit-scrollbar-thumb:hover {
  background: rgba(203, 213, 225, 0.9);
}

.shell {
  width: min(100%, 1760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(18px, 2vw, 32px);
  display: grid;
  gap: 20px;
}

.hero,
.panel,
.actions,
.status {
  border: 1px solid var(--line);
  background: rgba(16, 26, 43, 0.94);
  border-radius: 14px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(390px, 0.52fr);
  gap: 22px;
  align-items: center;
  padding: 22px 24px;
}

.brand {
  display: flex;
  gap: 20px;
  align-items: center;
  min-width: 0;
}

.logo-box {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border: 1px solid #334155;
  border-radius: 14px;
  background: #0d1626;
  display: grid;
  place-items: center;
}

.logo-box img {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 2.7vw, 2.8rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  color: var(--blue);
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.1;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  margin-top: 8px;
}

.access-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #07101d;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 2.15fr) minmax(360px, 0.95fr);
  gap: 24px;
  min-height: 0;
}

.panel {
  padding: 24px;
  min-width: 0;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.panel-title.compact {
  display: block;
  margin-bottom: 16px;
}

form {
  display: grid;
  gap: 20px;
}

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

.grid.four {
  grid-template-columns: 1.08fr 1.1fr 0.92fr 0.8fr;
}

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

.grid.three {
  grid-template-columns: 1.25fr 0.8fr 0.8fr;
}

label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  caret-color: #ffffff;
  padding: 0 16px;
  font: inherit;
  outline: none;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 21px, calc(100% - 14px) 21px;
  background-size: 8px 8px, 8px 8px;
  background-repeat: no-repeat;
  padding-right: 44px;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35);
}

input[readonly] {
  color: var(--muted);
}

.native-select-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.custom-select {
  position: relative;
  width: 100%;
  min-width: 0;
}

.custom-select-button {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 0 14px 0 16px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.custom-select-button:focus-visible,
.custom-select.open .custom-select-button {
  border-color: var(--blue);
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.35);
  outline: none;
}

.custom-select-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-arrow {
  color: var(--muted);
  font-size: 0.95rem;
  transform: translateY(-1px);
}

.custom-select-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 242px;
  overflow: auto;
  display: none;
  padding: 6px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: #101a2b;
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.35);
}

.custom-select.open .custom-select-menu {
  display: grid;
  gap: 4px;
}

.custom-select-option {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.custom-select-option:hover,
.custom-select-option[aria-selected="true"] {
  background: #1d4ed8;
  color: #ffffff;
}

.custom-select-menu::-webkit-scrollbar {
  width: 10px;
}

.custom-select-menu::-webkit-scrollbar-track {
  background: #0a111e;
  border-radius: 999px;
}

.custom-select-menu::-webkit-scrollbar-thumb {
  background: rgba(159, 176, 199, 0.55);
  border: 2px solid #0a111e;
  border-radius: 999px;
}

.custom-select-menu::-webkit-scrollbar-thumb:hover {
  background: rgba(203, 213, 225, 0.9);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.status-filter {
  height: 42px;
}

.status-filter + .custom-select-button,
.toolbar .custom-select-button {
  height: 42px;
}

.records {
  max-height: min(52vh, 560px);
  overflow: auto;
  padding-right: 4px;
  display: grid;
  gap: 12px;
}

.record-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  padding: 14px;
  display: grid;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
}

.record-card strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.05rem;
}

.record-card span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

.record-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.record-actions .button,
.record-actions .button.success,
.record-actions .button.warn,
.record-actions .button.danger {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 8px;
  border-radius: 9px;
  font-size: 0.88rem;
  white-space: nowrap;
}

.record-action-button {
  width: 100%;
  min-width: 0;
  height: 42px;
  border-radius: 10px;
  border: 1px solid #334155;
  color: #ffffff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1;
  padding: 0 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-action-button.import {
  background: #0f9f7a;
  border-color: #10b981;
}

.record-action-button.archive {
  background: #5b3a08;
  border-color: #b45309;
  color: #fef3c7;
}

.record-action-button.delete {
  background: #4a171b;
  border-color: #b91c1c;
  color: #fecaca;
}

.record-action-button:hover {
  filter: brightness(1.12);
}

.empty {
  color: #64748b;
  text-align: center;
  padding: 46px 16px;
}

.actions {
  padding: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 14px;
}

.button {
  min-width: 148px;
  height: 48px;
  border: 1px solid #334155;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  padding: 0 20px;
  cursor: pointer;
}

.button:hover {
  border-color: #60a5fa;
}

.button.small {
  min-width: 0;
  height: 42px;
  padding: 0 14px;
}

.button.success {
  min-width: 260px;
  background: var(--green-dark);
  border-color: var(--green);
}

.button.blue {
  background: #1d4ed8;
  border-color: var(--blue);
}

.button.danger {
  min-width: 0;
  height: 38px;
  background: #4a171b;
  border-color: #991b1b;
  color: #fecaca;
}

.button.warn {
  min-width: 0;
  height: 38px;
  background: #4a3510;
  border-color: #b45309;
  color: #fef3c7;
}

.button.ghost {
  background: var(--panel-2);
}

.status {
  padding: 14px 18px;
  color: var(--muted);
}

.status.ok {
  color: #22d38a;
}

.status.error {
  color: #f87171;
}

.status.warn {
  color: #facc15;
}

@media (max-width: 1180px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) {
  .shell {
    padding: 14px;
  }

  .hero,
  .panel {
    padding: 18px;
  }

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

  .logo-box {
    width: 58px;
    height: 58px;
  }

  .logo-box img {
    width: 44px;
    height: 44px;
  }

  .panel-title,
  .actions,
  .access-card {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .grid.four,
  .grid.two,
  .grid.three,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .button,
  .button.success {
    width: 100%;
  }
}
