@layer reset, base, components, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { -webkit-text-size-adjust: 100%; }
  body, h1, h2, h3, h4, p, ul, ol, figure { margin: 0; padding: 0; }
  img, svg { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; }
  [hidden], .dropdown-menu, [data-dropdown-menu] { display: none; }
  .mobile-bottom-bar { display: none; }
}
@layer base {
  :root {
    color-scheme: light;
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --surface-3: #e2e8f0;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --line-subtle: #edf2f7;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;
    --highlight: #dbeafe;
    --positive: #059669;
    --positive-bg: #ecfdf5;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 12px -2px rgb(15 23 42 / 0.08), 0 2px 6px -2px rgb(15 23 42 / 0.04);
    --shadow-lg: 0 12px 24px -4px rgb(15 23 42 / 0.12), 0 4px 8px -2px rgb(15 23 42 / 0.06);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
  }
  html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0b1120;
    --surface: #151f32;
    --surface-2: #1e293b;
    --surface-3: #273549;
    --ink: #f8fafc;
    --muted: #94a3b8;
    --line: #243247;
    --line-subtle: #1c2738;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #172554;
    --highlight: #1e3a5f;
    --positive: #34d399;
    --positive-bg: #064e3b;
    --warning: #fbbf24;
    --warning-bg: #451a03;
    --danger: #f87171;
    --danger-bg: #450a0a;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
    --shadow: 0 4px 12px -2px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 14px 28px -4px rgb(0 0 0 / 0.55);
  }
  body {
    min-width: 280px;
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  a { color: inherit; text-decoration: none; }
  a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
  }
}
@layer components {
  .icon-button {
    background: var(--surface);
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--ink);
    transition: background 0.15s, border-color 0.15s;
  }
  .icon-button:hover {
    background: var(--surface-2);
    border-color: var(--line);
  }

  .eyebrow {
    color: var(--primary);
    font-weight: 700;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  h1 {
    margin-top: 14px;
    letter-spacing: -0.04em;
    line-height: 1.18;
    font-size: clamp(2rem, 3.8vw, 3.4rem);
    font-weight: 800;
    text-wrap: balance;
  }
  .lead {
    margin-top: 18px;
    color: var(--muted);
    font-size: 1rem;
    max-width: 54ch;
    line-height: 1.65;
  }
  .lead strong {
    color: var(--ink);
    font-weight: 600;
  }
  .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    font-size: 0.84rem;
    font-weight: 600;
    padding: 9px 16px;
    min-height: 38px;
    cursor: pointer;
    background: var(--surface);
    color: var(--ink);
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    line-height: 1.25;
  }
  .button:hover {
    background: var(--surface-2);
  }
  .button-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
  }
  .button-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
  }
  .button-small {
    min-height: 32px;
    padding: 5px 12px;
    font-size: 0.78rem;
  }
  .status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    padding: 4px 9px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
  }

  .auth-page-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    color: var(--ink);
  }

  /* Auth / Login Dedicated Page */
  .auth-page-frame {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: radial-gradient(ellipse 90% 60% at 50% 0%, rgba(37, 99, 235, 0.12), transparent 70%), var(--bg);
    position: relative;
    overflow-x: hidden;
  }
  .auth-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
  }
  .auth-page-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    transition: all 0.15s ease;
  }
  .auth-page-back:hover {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--line);
  }
  .auth-page-back .ui-icon {
    width: 15px;
    height: 15px;
    transition: transform 0.15s;
  }
  .auth-page-back:hover .ui-icon {
    transform: translateX(-3px);
  }
  .auth-page-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px 16px 40px;
    box-sizing: border-box;
  }
  .auth-page-footer {
    text-align: center;
    padding: 18px 16px 26px;
    font-size: 0.74rem;
    color: var(--muted);
    opacity: 0.8;
  }

  /* Modern Auth Card */
  .auth-card-modern {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.28), 0 0 1px 1px rgba(255, 255, 255, 0.05);
    padding: 38px 34px 30px;
    box-sizing: border-box;
    animation: authFadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  }
  @keyframes authFadeUp {
    from {
      opacity: 0;
      transform: translateY(12px) scale(0.98);
    }
    to {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
  }
  .auth-header-block {
    text-align: center;
    margin-bottom: 24px;
  }
  .auth-logo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.18), rgba(37, 99, 235, 0.05));
    border: 1px solid rgba(37, 99, 235, 0.3);
    box-shadow: 0 8px 20px -6px rgba(37, 99, 235, 0.25);
    margin-bottom: 14px;
  }
  .auth-brand-overline {
    display: block;
    font-size: 0.69rem;
    letter-spacing: 0.12em;
    font-weight: 750;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 6px;
  }
  .auth-header-block h1 {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--ink);
    margin: 0 0 6px;
  }
  .auth-subtitle {
    font-size: 0.81rem;
    color: var(--muted);
    line-height: 1.45;
    margin: 0;
  }
  .auth-alert {
    margin-bottom: 18px;
    border-radius: 10px;
    font-size: 0.8rem;
    padding: 10px 14px;
  }
  .auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  .auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .auth-field label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.77rem;
    font-weight: 650;
    color: var(--ink);
    letter-spacing: -0.01em;
  }
  .auth-field label .ui-icon {
    width: 14px;
    height: 14px;
    color: var(--muted);
  }
  .auth-input-wrap {
    position: relative;
  }
  .auth-input-wrap input {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--ink);
    font-size: 0.87rem;
    box-sizing: border-box;
    outline: none;
    transition: all 0.18s ease;
  }
  .auth-input-wrap input:hover {
    border-color: var(--muted);
  }
  .auth-input-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  }
  .button-auth {
    width: 100%;
    height: 42px;
    margin-top: 6px;
    font-size: 0.86rem;
    font-weight: 700;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.35);
    transition: all 0.18s ease;
  }
  .button-auth:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.45);
  }
  .button-auth:active {
    transform: translateY(0);
  }
  .button-auth .ui-icon {
    width: 16px;
    height: 16px;
    stroke: #fff;
  }
  .auth-card-footer {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.73rem;
    color: var(--muted);
    text-align: center;
  }
  .auth-card-footer .ui-icon {
    width: 14px;
    height: 14px;
    color: var(--muted);
    flex-shrink: 0;
  }

  /* Backward compatibility classes */
  .auth-wrap {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
    padding: 40px 16px;
  }
  .auth-card {
    max-width: 420px;
    width: 100%;
  }
    color: var(--muted);
    text-align: center;
    line-height: 1.45;
  }
  .notice-error {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.2);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 0.79rem;
    margin-bottom: 16px;
  }
  .error-screen {
    margin: 70px auto 90px;
    max-width: 520px;
    text-align: center;
    padding-inline: 16px;
  }
  .error-screen .eyebrow { justify-content: center; }
  .error-number {
    color: var(--primary);
    font-weight: 850;
    font-size: 4.5rem;
    line-height: 1;
    margin-bottom: 12px;
    letter-spacing: -0.04em;
  }
  .error-screen h1 { font-size: clamp(1.8rem, 3.5vw, 2.5rem); }
  .error-screen .lead { margin: 16px auto 22px; }
  .error-screen .button { margin-top: 12px; }
  .error-reference { font-size: 0.74rem; color: var(--muted); margin-top: 16px; }
}
@layer responsive {
  @media(max-width: 600px) {
    h1 { font-size: clamp(1.85rem, 8vw, 2.4rem); }
    .lead { font-size: 0.92rem; }
  }
}
