* {
  box-sizing: border-box;
}

:is(html, body, .ds-app, .ds-app *) {
  scrollbar-color: var(--ds-color-scrollbar-thumb) var(--ds-color-scrollbar-track);
  scrollbar-width: thin;
}

:is(html, body, .ds-app, .ds-app *)::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

:is(html, body, .ds-app, .ds-app *)::-webkit-scrollbar-track {
  border-radius: 999px;
  background: var(--ds-color-scrollbar-track);
}

:is(html, body, .ds-app, .ds-app *)::-webkit-scrollbar-thumb {
  min-width: 36px;
  min-height: 36px;
  border: 2px solid transparent;
  border-radius: 999px;
  background: var(--ds-color-scrollbar-thumb);
  background-clip: padding-box;
}

:is(html, body, .ds-app, .ds-app *)::-webkit-scrollbar-thumb:hover {
  background: var(--ds-color-scrollbar-thumb-hover);
  background-clip: padding-box;
}

:is(html, body, .ds-app, .ds-app *)::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

:is(html, body, .ds-app, .ds-app *)::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  min-width: 320px;
  margin: 0;
  font-family: var(--ds-font-sans);
  color: var(--ds-color-text);
  background: var(--ds-body-bg);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  box-shadow: var(--ds-focus-ring);
}

.ds-app {
  width: min(1500px, calc(100% - 40px));
  margin: 48px auto;
  overflow: hidden;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-color-bg);
  box-shadow: var(--ds-shadow-app);
}

.ds-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 820px;
  background: var(--ds-shell-bg);
}

.ds-sidebar {
  padding: 30px 24px;
  border-right: 1px solid var(--ds-color-sidebar-border);
  background: var(--ds-color-sidebar);
}

.ds-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 34px;
  color: var(--ds-color-brand);
  font-size: var(--ds-text-lg);
  font-weight: 800;
}

.ds-brand-mark {
  width: 28px;
  height: 28px;
  border: 1px solid var(--ds-color-border-strong);
  border-radius: var(--ds-radius-md);
  background: var(--ds-gradient-brand);
  box-shadow: var(--ds-shadow-glow);
}

.ds-nav {
  display: grid;
  gap: 8px;
}

.ds-nav-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 44px;
  gap: 12px;
  padding: 0 14px;
  border-radius: var(--ds-radius-md);
  color: var(--ds-color-text-soft);
  text-decoration: none;
  font-size: var(--ds-text-md);
  font-weight: 700;
}

.ds-nav-item.is-active {
  color: var(--ds-color-text);
  background: var(--ds-color-primary-soft);
  box-shadow: inset 0 0 0 1px var(--ds-color-border-strong);
}

.ds-nav-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--ds-color-primary);
}

.ds-main {
  min-width: 0;
  padding: 28px;
}

.ds-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-4);
  margin-bottom: 28px;
}

.ds-breadcrumbs {
  color: var(--ds-color-text-muted);
  font-size: var(--ds-text-sm);
  font-weight: 700;
}

.ds-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.ds-icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--ds-color-border);
  border-radius: 50%;
  color: var(--ds-color-text-soft);
  background: var(--ds-color-control-surface);
}

.ds-theme-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(58px, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--ds-color-border);
  border-radius: 999px;
  background: var(--ds-color-control-surface);
}

.ds-theme-toggle button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  color: var(--ds-color-text-muted);
  background: transparent;
  font-size: var(--ds-text-xs);
  font-weight: 900;
  text-transform: uppercase;
}

.ds-theme-toggle button.is-selected {
  color: var(--ds-color-primary-contrast);
  background: var(--ds-color-primary);
  box-shadow: var(--ds-shadow-glow);
}

.ds-palette-panel {
  display: grid;
  gap: 12px;
  margin: 0 0 24px;
  padding: 14px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-md);
  background: var(--ds-color-control-surface-soft);
}

.ds-palette-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ds-palette-panel-title {
  color: var(--ds-color-text-soft);
  font-size: var(--ds-text-xs);
  font-weight: 900;
  text-transform: uppercase;
}

.ds-palette-current {
  color: var(--ds-color-primary);
  font-size: var(--ds-text-sm);
  font-weight: 900;
}

.ds-palette-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.ds-palette-choice {
  display: flex;
  align-items: center;
  min-width: 0;
  min-height: 48px;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-md);
  color: var(--ds-color-text-soft);
  background: var(--ds-color-control-surface);
  text-align: left;
}

.ds-palette-choice:hover,
.ds-palette-choice.is-selected {
  border-color: var(--ds-color-border-strong);
  box-shadow: var(--ds-shadow-glow);
}

.ds-palette-choice.is-selected {
  color: var(--ds-color-text);
  background: var(--ds-color-primary-soft);
}

.ds-palette-swatch {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ds-swatch-primary), var(--ds-swatch-secondary));
  box-shadow: 0 0 16px color-mix(in srgb, var(--ds-swatch-primary) 34%, transparent);
}

.ds-palette-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.ds-palette-name {
  overflow: hidden;
  font-size: var(--ds-text-sm);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ds-palette-tone {
  color: var(--ds-color-text-muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.ds-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-md);
  color: var(--ds-color-text);
  background: var(--ds-color-control-surface);
  font-size: var(--ds-text-sm);
  font-weight: 800;
  text-decoration: none;
}

.ds-button:hover,
.ds-icon-button:hover,
.ds-theme-toggle:hover {
  border-color: var(--ds-color-border-strong);
  box-shadow: var(--ds-shadow-glow);
}

.ds-button.is-primary {
  border-color: transparent;
  color: var(--ds-color-primary-contrast);
  background: var(--ds-gradient-primary);
}

.ds-button.is-accent {
  border-color: transparent;
  color: var(--ds-color-success-contrast);
  background: var(--ds-color-success);
}

.ds-media-player {
  display: grid;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--ds-color-border-strong);
  border-radius: var(--ds-radius-md);
  color: var(--ds-color-text);
  background: var(--ds-color-media-surface);
  box-shadow: var(--ds-shadow-card), var(--ds-shadow-glow);
}

.ds-media-player.is-compact {
  grid-template-columns: 42px minmax(0, 1fr) auto;
}

.ds-media-player.is-compact > .ds-media-range,
.ds-media-player.is-compact > .ds-media-volume {
  grid-column: 1 / -1;
}

.ds-media-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  color: var(--ds-color-primary-contrast);
  background: var(--ds-color-primary);
}

.ds-media-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.ds-media-meta {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  color: var(--ds-color-text-soft);
}

.ds-media-meta > * {
  min-width: 0;
}

.ds-media-meta strong,
.ds-media-meta small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ds-media-meta small,
.ds-media-time {
  color: var(--ds-color-text-muted);
  font-size: var(--ds-text-xs);
}

.ds-media-time {
  font-weight: 900;
}

.ds-media-range {
  width: 100%;
  height: 16px;
  margin: 0;
  background: transparent;
  accent-color: var(--ds-color-primary);
  appearance: none;
}

.ds-media-range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--ds-color-media-track);
}

.ds-media-range::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: var(--ds-color-primary);
  box-shadow: var(--ds-shadow-glow);
  appearance: none;
}

.ds-media-range::-moz-range-track {
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--ds-color-media-track);
}

.ds-media-range::-moz-range-progress {
  height: 6px;
  border-radius: 999px;
  background: var(--ds-color-primary);
}

.ds-media-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: var(--ds-color-primary);
  box-shadow: var(--ds-shadow-glow);
}

.ds-media-volume {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  color: var(--ds-color-text-muted);
  font-size: var(--ds-text-xs);
  font-weight: 900;
}

.ds-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--ds-space-4);
  align-items: end;
  margin-bottom: 24px;
}

.ds-title {
  margin: 0;
  font-size: var(--ds-text-display);
  line-height: 1.05;
}

.ds-lead {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--ds-color-text-soft);
  font-size: var(--ds-text-md);
  line-height: 1.6;
}

.ds-segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-md);
  background: var(--ds-color-control-surface);
}

.ds-segmented button {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--ds-radius-sm);
  color: var(--ds-color-text-muted);
  background: transparent;
  font-size: var(--ds-text-sm);
  font-weight: 800;
}

.ds-segmented button.is-selected {
  color: var(--ds-color-primary-contrast);
  background: var(--ds-color-primary);
}

.ds-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--ds-space-4);
}

.ds-card,
.ds-panel {
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-md);
  background: var(--ds-card-surface);
  box-shadow: var(--ds-shadow-card);
}

.ds-card {
  padding: var(--ds-space-5);
}

.ds-card h2,
.ds-card h3,
.ds-card h4 {
  margin: 0;
}

.ds-card p {
  color: var(--ds-color-text-soft);
  line-height: 1.55;
}

.ds-card.is-span-4 {
  grid-column: span 4;
}

.ds-card.is-span-6 {
  grid-column: span 6;
}

.ds-card.is-span-8 {
  grid-column: span 8;
}

.ds-card.is-span-12 {
  grid-column: span 12;
}

.ds-kpi {
  display: grid;
  gap: 12px;
}

.ds-kpi-label {
  color: var(--ds-color-text-muted);
  font-size: var(--ds-text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

.ds-kpi-value {
  margin: 0;
  color: var(--ds-color-primary);
  font-size: 30px;
  font-weight: 900;
}

.ds-field {
  display: grid;
  gap: 8px;
}

.ds-label {
  color: var(--ds-color-text-muted);
  font-size: var(--ds-text-xs);
  font-weight: 800;
  text-transform: uppercase;
}

.ds-input,
.ds-select,
.ds-textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-md);
  color: var(--ds-color-text);
  background: var(--ds-color-control-surface);
  padding: 0 13px;
}

.ds-textarea {
  min-height: 96px;
  padding-top: 12px;
  resize: vertical;
}

.ds-checkbox {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  gap: 9px;
  color: var(--ds-color-text-soft);
  cursor: pointer;
  font-size: var(--ds-text-sm);
  font-weight: 800;
  line-height: 1.35;
}

.ds-checkbox > input[type="checkbox"] {
  display: grid;
  flex: 0 0 auto;
  place-content: center;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1px solid var(--ds-color-border-strong);
  border-radius: var(--ds-radius-sm);
  background: var(--ds-color-control-surface);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ds-color-primary) 8%, transparent);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.ds-checkbox > input[type="checkbox"]::before {
  width: 8px;
  height: 4px;
  border-bottom: 2px solid var(--ds-color-primary-contrast);
  border-left: 2px solid var(--ds-color-primary-contrast);
  content: "";
  transform: rotate(-45deg) scale(0);
  transition: transform 140ms ease;
}

.ds-checkbox > input[type="checkbox"]:hover:not(:disabled) {
  border-color: var(--ds-color-border-strong);
  box-shadow: var(--ds-shadow-glow);
}

.ds-checkbox > input[type="checkbox"]:checked {
  border-color: transparent;
  background: var(--ds-color-primary);
  box-shadow: var(--ds-shadow-glow);
}

.ds-checkbox > input[type="checkbox"]:checked::before {
  transform: rotate(-45deg) scale(1);
}

.ds-checkbox > input[type="checkbox"]:focus-visible {
  box-shadow: var(--ds-focus-ring);
}

.ds-checkbox > input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.ds-checkbox:has(> input[type="checkbox"]:checked) {
  color: var(--ds-color-text);
}

.ds-checkbox:has(> input[type="checkbox"]:disabled) {
  cursor: not-allowed;
}

.ds-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--ds-color-success-contrast);
  background: var(--ds-color-success);
  font-size: var(--ds-text-xs);
  font-weight: 900;
}

.ds-status.is-warning {
  color: var(--ds-color-warning-contrast);
  background: var(--ds-color-warning);
}

.ds-status.is-danger {
  color: var(--ds-color-danger-contrast);
  background: var(--ds-color-danger);
}

.ds-status.is-info {
  color: var(--ds-color-info-contrast);
  background: var(--ds-color-info);
}

.ds-table-wrap {
  overflow: auto;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-md);
}

.ds-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: var(--ds-text-sm);
}

.ds-table th,
.ds-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ds-color-border);
  text-align: left;
}

.ds-table th {
  color: var(--ds-color-text-muted);
  font-size: var(--ds-text-xs);
  text-transform: uppercase;
}

.ds-table tr:last-child td {
  border-bottom: 0;
}

.ds-calendar-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.ds-date-cell {
  display: grid;
  place-items: center;
  min-height: 66px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-md);
  color: var(--ds-color-text-soft);
  background: var(--ds-color-control-surface-soft);
}

.ds-date-cell.is-active {
  color: var(--ds-color-primary-contrast);
  border-color: transparent;
  background: var(--ds-color-primary);
}

.ds-date-cell strong {
  font-size: var(--ds-text-lg);
}

.ds-date-cell span {
  font-size: var(--ds-text-xs);
  font-weight: 800;
}

.ds-schedule-list {
  display: grid;
  gap: 10px;
}

.ds-schedule-card {
  padding: 14px 16px;
  border-left: 4px solid var(--ds-color-primary);
  border-radius: var(--ds-radius-md);
  background: var(--ds-color-schedule-surface);
}

.ds-schedule-card.is-blue {
  border-left-color: var(--ds-color-secondary);
}

.ds-schedule-card.is-green {
  border-left-color: var(--ds-color-success);
}

.ds-schedule-card h4,
.ds-schedule-card p {
  margin: 0;
}

.ds-schedule-card p {
  margin-top: 4px;
  color: var(--ds-color-text-muted);
  font-size: var(--ds-text-sm);
}

.ds-avatar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ds-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  color: var(--ds-color-primary-contrast);
  background: var(--ds-color-primary);
  font-size: var(--ds-text-xs);
  font-weight: 900;
}

.ds-note {
  padding: 14px;
  border-radius: var(--ds-radius-md);
  color: var(--ds-color-text-soft);
  background: var(--ds-color-primary-soft);
}

.ds-control-stack {
  display: grid;
  gap: 14px;
}

.ds-custom-select {
  position: relative;
  display: grid;
  gap: 8px;
}

.ds-select-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  gap: 12px;
  width: 100%;
  padding: 0 13px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-md);
  color: var(--ds-color-text);
  background: var(--ds-color-control-surface);
  font-size: var(--ds-text-sm);
  font-weight: 800;
}

.ds-select-button::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  opacity: 0.7;
}

.ds-select-menu,
.ds-calendar-popover {
  border: 1px solid var(--ds-color-border-strong);
  border-radius: var(--ds-radius-md);
  background: var(--ds-color-overlay-surface);
  box-shadow: var(--ds-shadow-card), var(--ds-shadow-glow);
}

.ds-select-menu {
  display: grid;
  gap: 4px;
  padding: 6px;
}

.ds-select-option {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--ds-radius-sm);
  color: var(--ds-color-text-soft);
  background: transparent;
  text-align: left;
  font-size: var(--ds-text-sm);
  font-weight: 800;
}

.ds-select-option:hover,
.ds-select-option.is-selected {
  color: var(--ds-color-primary-contrast);
  background: var(--ds-color-primary);
}

.ds-calendar-popover {
  width: min(100%, 280px);
  padding: 14px;
}

.ds-calendar-header,
.ds-calendar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ds-calendar-title {
  color: var(--ds-color-text);
  font-size: var(--ds-text-sm);
  font-weight: 900;
}

.ds-calendar-nav {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--ds-color-border);
  border-radius: var(--ds-radius-sm);
  color: var(--ds-color-text-soft);
  background: var(--ds-color-control-surface);
}

.ds-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin: 12px 0;
}

.ds-calendar-weekday,
.ds-calendar-day {
  display: grid;
  place-items: center;
  min-height: 30px;
  border-radius: var(--ds-radius-sm);
  font-size: var(--ds-text-xs);
  font-weight: 900;
}

.ds-calendar-weekday {
  color: var(--ds-color-text-muted);
}

.ds-calendar-day {
  color: var(--ds-color-text);
  background: transparent;
}

.ds-calendar-day.is-muted {
  color: var(--ds-color-text-muted);
}

.ds-calendar-day:hover,
.ds-calendar-day.is-selected {
  color: var(--ds-color-primary-contrast);
  background: var(--ds-color-primary);
}

.ds-calendar-action {
  border: 0;
  color: var(--ds-color-primary);
  background: transparent;
  font-size: var(--ds-text-xs);
  font-weight: 900;
}

@media (max-width: 900px) {
  .ds-app {
    width: min(100% - 20px, 760px);
    margin: 20px auto;
  }

  .ds-shell {
    grid-template-columns: 1fr;
  }

  .ds-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--ds-color-border);
  }

  .ds-hero {
    grid-template-columns: 1fr;
  }

  .ds-actions {
    justify-content: flex-start;
  }

  .ds-palette-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ds-card.is-span-4,
  .ds-card.is-span-6,
  .ds-card.is-span-8 {
    grid-column: span 12;
  }
}

@media (max-width: 520px) {
  .ds-palette-picker {
    grid-template-columns: 1fr;
  }
}
