@layer components {
  .admin-body {
    font-family: system-ui, -apple-system, sans-serif;
    background: oklch(14% 0.02 260);
    color: oklch(90% 0 0);
    min-height: 100dvh;
    margin: 0;
    display: flex;
    flex-direction: column;
  }

  .admin-header {
    background: oklch(10% 0.02 260);
    border-bottom: 1px solid oklch(25% 0.02 260);
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .admin-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 36rem;
    width: 100%;
    margin: 0 auto;
    padding: 0.75rem 1rem;
  }

  .admin-nav-title {
    font-size: 0.9rem;
    color: oklch(70% 0 0);
    letter-spacing: 0.05em;
  }

  .admin-logout-btn {
    font-family: inherit;
    font-size: 0.8rem;
    background: none;
    border: 1px solid oklch(35% 0 0);
    color: oklch(60% 0 0);
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    margin-left: 1rem;

    &:hover {
      border-color: oklch(50% 0 0);
      color: oklch(80% 0 0);
    }
  }

  .admin-main {
    max-width: 36rem;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
  }

  /* Cards */
  .admin-card {
    background: oklch(18% 0.02 260);
    border: 1px solid oklch(25% 0.02 260);
    border-radius: 8px;
    padding: 1.5rem;

    & h1 {
      font-size: 1.25rem;
      font-weight: 600;
      margin-bottom: 0.25rem;
    }

    & h2 {
      font-size: 1rem;
      font-weight: 600;
      color: oklch(70% 0 0);
      margin-bottom: 1rem;
    }
  }

  .admin-subtitle {
    font-size: 0.85rem;
    color: oklch(55% 0 0);
    margin-bottom: 1.25rem;
  }

  .admin-back {
    margin-top: 1rem;
    font-size: 0.85rem;

    & a {
      color: oklch(65% 0.12 255);

      &:hover { color: oklch(75% 0.12 255); }
    }
  }

  /* Flash */
  .admin-flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
  }

  .admin-flash--notice {
    background: oklch(25% 0.06 150);
    border: 1px solid oklch(40% 0.08 150);
    color: oklch(80% 0.1 150);
  }

  .admin-flash--alert {
    background: oklch(25% 0.06 25);
    border: 1px solid oklch(40% 0.08 25);
    color: oklch(80% 0.1 25);
  }

  /* Forms */
  .admin-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
  }

  .admin-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;

    & label {
      font-size: 0.8rem;
      font-weight: 600;
      color: oklch(65% 0 0);
      text-transform: uppercase;
      letter-spacing: 0.04em;
    }

    & input[type="email"],
    & input[type="password"],
    & input[type="text"] {
      font-family: inherit;
      font-size: 1rem;
      padding: 0.6rem 0.75rem;
      background: oklch(12% 0.01 260);
      color: oklch(90% 0 0);
      border: 1px solid oklch(30% 0.02 260);
      border-radius: 6px;
      outline: none;

      &:focus {
        border-color: oklch(50% 0.15 255);
        box-shadow: 0 0 0 2px oklch(50% 0.15 255 / 0.2);
      }
    }
  }

  .admin-code-input {
    text-transform: uppercase;
    letter-spacing: 0.25em;
    text-align: center;
    font-size: 1.5rem !important;
    font-weight: 600;
    padding: 0.75rem !important;
  }

  .admin-hint {
    font-size: 0.78rem;
    color: oklch(50% 0 0);
    display: block;
  }

  .admin-btn {
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.65rem 1.5rem;
    background: oklch(50% 0.15 255);
    color: oklch(98% 0 0);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    align-self: flex-start;

    &:hover {
      background: oklch(55% 0.15 255);
    }

    &:active {
      background: oklch(45% 0.15 255);
    }
  }

  /* Settings */
  .admin-setting {
    padding-bottom: 1.25rem;
    border-bottom: 1px solid oklch(22% 0.02 260);

    &:last-of-type {
      border-bottom: none;
      padding-bottom: 0;
    }
  }

  .admin-setting-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.5rem;
  }

  .admin-setting-label {
    font-weight: 600;
    font-size: 0.95rem;
    display: block;
    margin-bottom: 0.2rem;
  }

  /* Toggle switch */
  .admin-toggle {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    cursor: pointer;
  }

  .admin-toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
  }

  .admin-toggle-track {
    display: block;
    width: 44px;
    height: 24px;
    background: oklch(30% 0 0);
    border-radius: 12px;
    transition: background 150ms;
    position: relative;

    &::after {
      content: "";
      position: absolute;
      top: 2px;
      left: 2px;
      width: 20px;
      height: 20px;
      background: oklch(80% 0 0);
      border-radius: 50%;
      transition: transform 150ms;
    }
  }

  .admin-toggle-input:checked + .admin-toggle-track {
    background: oklch(60% 0.18 150);

    &::after {
      transform: translateX(20px);
      background: oklch(98% 0 0);
    }
  }

  .admin-toggle-input:focus-visible + .admin-toggle-track {
    box-shadow: 0 0 0 2px oklch(50% 0.15 255 / 0.4);
  }

  /* Status badge */
  .admin-status-badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
  }

  .admin-status-badge--on {
    background: oklch(30% 0.08 150);
    color: oklch(75% 0.15 150);
  }

  .admin-status-badge--off {
    background: oklch(30% 0.06 25);
    color: oklch(70% 0.12 25);
  }

  /* Stats */
  .admin-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .admin-stat {
    text-align: center;
    padding: 1rem;
    background: oklch(12% 0.01 260);
    border-radius: 6px;
    border: 1px solid oklch(22% 0.02 260);
  }

  .admin-stat-number {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: oklch(85% 0 0);
    line-height: 1;
    margin-bottom: 0.3rem;
  }

  .admin-stat-label {
    font-size: 0.75rem;
    color: oklch(50% 0 0);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
}
