* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  color: var(--ink-950);
  background: var(--canvas);
  font-family: var(--font-family);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

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

button {
  color: inherit;
}

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(10, 145, 131, 0.25);
  outline-offset: 2px;
}

.icon-library {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.button,
.icon-button,
.search-trigger,
.filter-button,
.segmented-button {
  border: 0;
  cursor: pointer;
  transition:
    transform var(--motion-fast) var(--ease-standard),
    background var(--motion-ui) var(--ease-standard),
    border-color var(--motion-ui) var(--ease-standard),
    color var(--motion-ui) var(--ease-standard),
    box-shadow var(--motion-ui) var(--ease-standard);
}

.button:active,
.icon-button:active,
.search-trigger:active,
.filter-button:active,
.segmented-button:active {
  transform: scale(0.98);
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-md);
  padding: 0 var(--space-4);
  font-weight: 600;
  white-space: nowrap;
}

.button-primary {
  color: #fff;
  background: var(--brand-900);
  box-shadow: 0 7px 16px rgba(18, 54, 61, 0.18);
}

.button-primary:hover {
  background: var(--brand-800);
  box-shadow: 0 10px 22px rgba(18, 54, 61, 0.23);
  transform: translateY(-1px);
}

.button-secondary {
  color: var(--ink-800);
  background: var(--surface);
  border: 1px solid var(--ink-200);
}

.button-secondary:hover {
  border-color: var(--ink-300);
  background: var(--ink-50);
}

.button-ghost {
  min-height: 36px;
  padding-inline: var(--space-3);
  color: var(--brand-800);
  background: transparent;
}

.button-ghost:hover {
  background: var(--brand-50);
}

.button-danger {
  color: var(--red-700);
  background: var(--red-50);
}

.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-md);
  color: var(--ink-700);
  background: var(--surface);
  border: 1px solid var(--ink-100);
}

.icon-button:hover {
  color: var(--brand-900);
  border-color: var(--ink-200);
  background: var(--ink-50);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 26px;
  padding: 2px 9px;
  border-radius: var(--radius-round);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success {
  color: var(--accent-700);
  background: var(--accent-50);
}

.badge-warning {
  color: var(--amber-700);
  background: var(--amber-50);
}

.badge-danger {
  color: var(--red-700);
  background: var(--red-50);
}

.badge-neutral {
  color: var(--ink-600);
  background: var(--ink-50);
}

.badge-info {
  color: var(--blue-700);
  background: var(--blue-50);
}

.card {
  background: var(--surface);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.card-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--ink-100);
}

.card-header h2,
.card-header h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.4;
}

.card-header p {
  margin: 3px 0 0;
  color: var(--ink-600);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  color: var(--ink-950);
  background: var(--surface);
  transition: border-color var(--motion-ui), box-shadow var(--motion-ui);
}

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

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: var(--ink-300);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent-600);
  box-shadow: 0 0 0 3px rgba(10, 145, 131, 0.1);
  outline: 0;
}

.field [aria-invalid="true"] {
  border-color: var(--red-700);
  box-shadow: 0 0 0 3px rgba(180, 59, 69, 0.09);
}

.field-error {
  color: var(--red-700);
  font-size: 12px;
  min-height: 18px;
}

.table-wrap {
  overflow-x: auto;
  scrollbar-width: thin;
}

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

.data-table th,
.data-table td {
  padding: 14px 18px;
  text-align: right;
  border-bottom: 1px solid var(--ink-100);
  white-space: nowrap;
}

.data-table th {
  color: var(--ink-600);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 600;
}

.data-table td {
  color: var(--ink-700);
  font-size: 13px;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr {
  transition: background var(--motion-ui);
}

.data-table tbody tr:hover {
  background: #fafcfb;
}

.primary-cell {
  color: var(--ink-950) !important;
  font-weight: 600;
}

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

.empty-state {
  min-height: 300px;
  display: grid;
  place-items: center;
  padding: var(--space-8);
  text-align: center;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin: 0 auto var(--space-4);
  color: var(--brand-700);
  border-radius: var(--radius-xl);
  background: var(--brand-50);
}

.empty-state-icon .icon {
  width: 28px;
  height: 28px;
}

.empty-state h3 {
  margin: 0 0 var(--space-2);
  font-size: 18px;
}

.empty-state p {
  max-width: 380px;
  margin: 0 auto var(--space-5);
  color: var(--ink-600);
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--ink-100);
  border-radius: var(--radius-sm);
}

.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
  to { transform: translateX(-100%); }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton::after { animation: none; }
}
