* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.display-font {
  font-family: var(--font-display);
}

.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--brand-600);
}

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.icon {
  width: 22px;
  height: 22px;
  flex: none;
  display: inline-block;
  vertical-align: middle;
}

.icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: var(--fs-small);
  font-weight: 600;
  line-height: 1.3;
  background: var(--surface-2);
  color: var(--text);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  background: var(--border);
}

.btn-primary {
  background: var(--brand-700);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--brand-600);
}

.btn-gold {
  background: var(--gold-400);
  color: #231806;
}

.btn-gold:hover {
  background: var(--gold-300);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

html[data-theme="dark"] .btn-danger {
  color: #1a0b0a;
}

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

.btn-block {
  width: 100%;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0;
}

.icon-btn:hover {
  background: var(--surface-2);
}

.icon-btn .icon {
  width: 20px;
  height: 20px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: var(--fs-small);
  font-weight: 600;
  margin-bottom: 6px;
}

.input,
.select-btn {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-body);
  padding: 11px 13px;
  line-height: 1.35;
}

.input:focus {
  border-color: var(--brand-500);
  box-shadow: var(--focus-ring);
  outline: none;
}

.input.invalid {
  border-color: var(--danger);
}

.field-error {
  display: none;
  color: var(--danger);
  font-size: var(--fs-cap);
  margin-top: 5px;
  line-height: 1.4;
}

.field-error.show {
  display: block;
}

.input-wrap {
  position: relative;
}

.input-wrap .input {
  padding-inline-end: 46px;
}

.input-eye {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--muted);
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
}

.input-eye:hover {
  background: var(--surface-2);
}

.type-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.type-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 14px 8px 11px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-small);
  font-weight: 600;
  line-height: 1.3;
}

.type-card .icon {
  width: 26px;
  height: 26px;
  color: var(--muted);
}

.type-card:hover {
  border-color: var(--brand-400);
}

.type-card.active {
  border-color: var(--brand-600);
  background: var(--brand-50);
  color: var(--brand-800);
}

html[data-theme="dark"] .type-card.active {
  background: var(--brand-900);
  color: var(--brand-100);
}

.type-card.active .icon {
  color: var(--brand-600);
}

html[data-theme="dark"] .type-card.active .icon {
  color: var(--brand-300);
}

.alert {
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: var(--fs-small);
  line-height: 1.5;
  margin-bottom: 16px;
  display: none;
}

.alert.show {
  display: block;
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.dd {
  position: relative;
}

.select-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: start;
}

.select-btn .icon {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.dd-panel {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  min-width: 100%;
  max-height: 300px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  z-index: 120;
  display: none;
  padding: 6px;
}

.dd-panel.open {
  display: block;
}

.dd-search {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-small);
  padding: 8px 10px;
  margin-bottom: 6px;
}

.dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: start;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: var(--fs-small);
  line-height: 1.4;
}

.dd-item:hover,
.dd-item.focused {
  background: var(--surface-2);
}

.dd-item.selected {
  background: var(--brand-50);
  color: var(--brand-800);
  font-weight: 600;
}

html[data-theme="dark"] .dd-item.selected {
  background: var(--brand-900);
  color: var(--brand-100);
}

.dd-empty {
  padding: 12px 10px;
  color: var(--muted);
  font-size: var(--fs-small);
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 26, 20, 0.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal {
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
}

.modal h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  line-height: var(--lh-head);
}

.modal p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: var(--fs-small);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.toast-wrap {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(92vw, 380px);
}

.toast {
  background: var(--brand-900);
  color: #eaf5f0;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: var(--fs-small);
  line-height: 1.5;
  box-shadow: var(--shadow-pop);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.toast-error {
  background: var(--danger);
  color: #ffffff;
}

html[data-theme="dark"] .toast-error {
  color: #1a0b0a;
}

.toast .icon {
  width: 19px;
  height: 19px;
  margin-top: 2px;
}

.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.acc-item + .acc-item {
  border-top: 1px solid var(--border);
}

.acc-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: var(--text);
  padding: 15px 18px;
  font-size: var(--fs-body);
  font-weight: 600;
  text-align: start;
  line-height: 1.4;
}

.acc-head .icon-chev {
  margin-inline-start: auto;
  width: 19px;
  height: 19px;
  color: var(--muted);
  transition: transform 0.18s ease;
}

.acc-item.open .acc-head .icon-chev {
  transform: rotate(180deg);
}

.acc-body {
  display: none;
  padding: 2px 18px 16px;
  color: var(--muted);
  font-size: var(--fs-small);
}

.acc-item.open .acc-body {
  display: block;
}

.filterbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.filterbar .f-field {
  min-width: 150px;
  flex: 1 1 150px;
}

.filterbar .f-field label {
  display: block;
  font-size: var(--fs-cap);
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

.filterbar .f-search {
  flex: 2 1 220px;
}

.kbd-tip {
  position: fixed;
  z-index: 500;
  background: var(--brand-950);
  color: #eaf5f0;
  font-size: var(--fs-cap);
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 7px;
  box-shadow: var(--shadow-pop);
  pointer-events: none;
  display: none;
  align-items: center;
  gap: 8px;
}

.kbd-tip.show {
  display: flex;
}

.kbd {
  font-family: var(--font-num);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  white-space: nowrap;
}

.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-small);
}

.shortcut-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.shortcut-table .kbd {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
