@layer base, components, utilities;

@layer base {
  :root {
    --ap22-font-sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --ap22-ink: #16213A;
    --ap22-text-secondary: #4B5B73;
    --ap22-text-muted: #7A8799;
    --ap22-bg: #F7FAFD;
    --ap22-surface: #FFFFFF;
    --ap22-panel: #F1F5FA;
    --ap22-border: #D7E0EC;
    --ap22-border-subtle: #E8EEF6;
    --ap22-brand: #C8102E;
    --ap22-info: #2563EB;
    --ap22-success: #0F9F8A;
    --ap22-warning: #C87500;
    --ap22-danger: #C8102E;
    --ap22-space-1: 4px;
    --ap22-space-2: 6px;
    --ap22-space-3: 8px;
    --ap22-space-4: 12px;
    --ap22-space-5: 16px;
    --ap22-space-6: 20px;
    --ap22-space-7: 24px;
    --ap22-space-8: 32px;
    --ap22-radius-1: 4px;
    --ap22-radius-2: 6px;
    --ap22-radius-3: 8px;
    --ap22-radius-4: 8px;
    --ap22-radius-5: 8px;
  }
}

@layer components {
  .ap22-dashboard {
    color: var(--ap22-ink);
    font-family: var(--ap22-font-sans);
  }

  .ap22-page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ap22-space-5);
    margin-bottom: var(--ap22-space-5);
  }

  .ap22-page-title {
    margin: 0;
    color: var(--ap22-ink);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.2;
  }

  .ap22-page-subtitle {
    margin-top: var(--ap22-space-1);
    color: var(--ap22-text-secondary);
    font-size: 13px;
  }

  .ap22-date-chip {
    border: 1px solid var(--ap22-border);
    background: var(--ap22-surface);
    border-radius: var(--ap22-radius-2);
    padding: 5px 10px;
    color: var(--ap22-text-secondary);
    font-size: 12px;
    white-space: nowrap;
  }

  .ap22-grid {
    display: grid;
    gap: 12px;
  }

  .ap22-metrics {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    margin-bottom: var(--ap22-space-5);
  }

  .ap22-two-col {
    grid-template-columns: minmax(0, 1.18fr) minmax(320px, .82fr);
    align-items: start;
  }

  .ap22-card {
    background: var(--ap22-surface);
    border: 1px solid var(--ap22-border);
    border-radius: var(--ap22-radius-2);
    overflow: visible;
  }

  .ap22-card-pad {
    padding: 14px 16px;
  }

  .ap22-metric-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 78px;
  }

  .ap22-card-click {
    cursor: pointer;
    transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
  }

  .ap22-card-click:hover {
    border-color: #B9C7D9;
    box-shadow: 0 2px 8px rgba(22, 33, 58, .06);
    transform: translateY(-1px);
  }

  .ap22-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--ap22-space-4);
    padding: 11px 14px;
    border-bottom: 1px solid var(--ap22-border-subtle);
    line-height: 1.2;
    min-height: 42px;
  }

  .ap22-card-title {
    margin: 0;
    color: var(--ap22-ink);
    font-size: 14px;
    font-weight: 700;
  }

  .ap22-link-btn {
    border: 0;
    background: transparent;
    color: var(--ap22-info);
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    padding: 0;
  }

  .ap22-metric-label {
    color: var(--ap22-text-secondary);
    font-size: 11px;
    font-weight: 650;
    line-height: 1.25;
    margin-bottom: var(--ap22-space-2);
  }

  .ap22-metric-value {
    color: var(--ap22-ink);
    font-size: 30px;
    font-weight: 740;
    letter-spacing: 0;
    line-height: 1.05;
  }

  .ap22-metric-hint {
    margin-top: var(--ap22-space-3);
    color: var(--ap22-text-muted);
    font-size: 11px;
    line-height: 1.25;
  }

  .ap22-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: var(--ap22-panel);
    color: var(--ap22-text-secondary);
    font-size: 12px;
    font-weight: 700;
    padding: 2px 7px;
    white-space: nowrap;
  }

  .ap22-badge-good {
    background: #E8FAF6;
    color: var(--ap22-success);
  }

  .ap22-badge-warn {
    background: #FFF6E6;
    color: var(--ap22-warning);
  }

  .ap22-badge-info {
    background: #EFF4FF;
    color: var(--ap22-info);
  }

  .ap22-row {
    display: grid;
    grid-template-columns: 30px 1fr auto;
    gap: 10px;
    align-items: center;
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--ap22-border-subtle);
    background: transparent;
    color: inherit;
    cursor: pointer;
    min-height: 50px;
    padding: 9px 14px;
    text-align: left;
    transition: background .12s ease;
  }

  .ap22-row:hover {
    background: #FAFCFE;
  }

  .ap22-row:last-child {
    border-bottom: 0;
  }

  .ap22-avatar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--ap22-radius-2);
    background: #EAF0F8;
    color: var(--ap22-ink);
    font-size: 12px;
    font-weight: 800;
  }

  .ap22-avatar-success {
    background: #E8FAF6;
    color: var(--ap22-success);
  }

  .ap22-row-title {
    color: var(--ap22-ink);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
  }

  .ap22-row-meta {
    margin-top: 2px;
    color: var(--ap22-text-secondary);
    font-size: 12px;
    line-height: 1.35;
  }

  .ap22-score {
    color: var(--ap22-success);
    font-size: 17px;
    font-weight: 760;
  }

  .ap22-panel-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--ap22-space-2);
  }

  .ap22-mini-tile {
    background: var(--ap22-panel);
    border-radius: var(--ap22-radius-2);
    padding: 9px;
    text-align: center;
  }

  .ap22-mini-tile strong {
    display: block;
    color: var(--ap22-ink);
    font-size: 18px;
    line-height: 1;
  }

  .ap22-mini-tile span {
    display: block;
    margin-top: var(--ap22-space-2);
    color: var(--ap22-text-secondary);
    font-size: 11px;
    font-weight: 650;
  }

  .ap22-empty {
    padding: 20px 16px;
    color: var(--ap22-text-secondary);
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
  }
}

@layer utilities {
  .ap22-mb {
    margin-bottom: var(--ap22-space-6);
  }

  @media (max-width: 900px) {
    .ap22-page-head {
      align-items: flex-start;
      flex-direction: column;
    }

    .ap22-two-col {
      grid-template-columns: 1fr;
    }

    .ap22-panel-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }
}
