/*
 * One Analytics Design System
 *
 * Copy this file into another service and add the class `oa-theme` to the
 * document body or to the application root. All components use the `oa-`
 * prefix, so the stylesheet can coexist with an existing UI framework.
 *
 * Optional fonts:
 * Hind, Wix Madefor Text, Inter, system-ui
 * The system remains usable without remote font files.
 */

:root {
  --oa-bg: #eff2f7;
  --oa-bg-soft: #f7f9fb;
  --oa-surface: rgba(255, 255, 255, 0.96);
  --oa-surface-soft: rgba(255, 255, 255, 0.88);
  --oa-surface-muted: #f4f7f9;
  --oa-border: #e5edf0;
  --oa-border-strong: #d5e0e6;
  --oa-border-soft: rgba(52, 58, 64, 0.07);
  --oa-text: #343a40;
  --oa-text-strong: #202733;
  --oa-muted: #74788d;
  --oa-muted-strong: #505d69;
  --oa-primary: #00b14a;
  --oa-primary-hover: #009a40;
  --oa-primary-soft: #e9f8f0;
  --oa-secondary: #4e7cf4;
  --oa-secondary-soft: #eef3ff;
  --oa-accent-cyan: #23b8c9;
  --oa-accent-purple: #7453ed;
  --oa-accent-pink: #df4fa2;
  --oa-danger: #d9535f;
  --oa-danger-soft: #fff0f1;
  --oa-warning: #bb7b12;
  --oa-warning-soft: #fff8e8;
  --oa-info: #4775c8;
  --oa-info-soft: #eef5ff;
  --oa-radius-sm: 10px;
  --oa-radius-md: 14px;
  --oa-radius-lg: 18px;
  --oa-radius-xl: 24px;
  --oa-shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.05);
  --oa-shadow-md: 0 16px 44px rgba(15, 23, 42, 0.07);
  --oa-shadow-lg: 0 28px 80px rgba(15, 23, 42, 0.1);
  --oa-focus: 0 0 0 3px rgba(78, 124, 244, 0.2);
  --oa-sidebar-width: 272px;
  --oa-content-max: 1440px;
  --oa-font-body: "Hind", "Wix Madefor Text", Inter, system-ui, -apple-system, sans-serif;
  --oa-font-heading: "Wix Madefor Text", "Hind", Inter, system-ui, -apple-system, sans-serif;
}

/* Base document surface. Add `oa-theme` to body or the app root. */
.oa-theme,
body.oa-theme {
  color: var(--oa-text);
  background: var(--oa-bg);
  font-family: var(--oa-font-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.oa-theme {
  min-width: 320px;
  margin: 0;
}

.oa-theme *,
.oa-theme *::before,
.oa-theme *::after {
  box-sizing: border-box;
}

.oa-theme button,
.oa-theme input,
.oa-theme select,
.oa-theme textarea {
  font: inherit;
}

.oa-theme button,
.oa-theme a {
  -webkit-tap-highlight-color: transparent;
}

.oa-theme a {
  color: var(--oa-secondary);
  text-decoration: none;
}

.oa-theme a:hover {
  color: #315ecf;
}

.oa-theme :focus-visible {
  outline: 0;
  box-shadow: var(--oa-focus);
}

/* Application shell */
.oa-app-shell {
  display: grid;
  grid-template-columns: var(--oa-sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  background:
    radial-gradient(1100px 700px at 0% 0%, rgba(56, 198, 108, 0.05), transparent 55%),
    radial-gradient(1000px 640px at 100% 8%, rgba(65, 195, 169, 0.04), transparent 52%),
    var(--oa-bg);
}

.oa-sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: var(--oa-sidebar-width);
  height: 100vh;
  padding: 16px 12px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.82);
  border-right: 1px solid var(--oa-border);
  backdrop-filter: blur(18px);
}

.oa-brand {
  display: flex;
  align-items: center;
  min-height: 64px;
  padding: 12px 14px;
  margin-bottom: 20px;
  color: var(--oa-text-strong);
  background: var(--oa-surface);
  border: 1px solid var(--oa-border);
  border-radius: var(--oa-radius-md);
  box-shadow: var(--oa-shadow-sm);
  font-family: var(--oa-font-heading);
  font-size: 18px;
  font-weight: 600;
}

.oa-brand img,
.oa-brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  margin-right: 10px;
  object-fit: contain;
}

.oa-brand-subtitle {
  display: block;
  margin-top: 2px;
  color: var(--oa-muted);
  font-size: 12px;
  font-weight: 400;
}

.oa-nav-section {
  margin: 18px 8px 8px;
  color: var(--oa-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.oa-nav {
  display: grid;
  gap: 4px;
}

.oa-nav-link {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 10px;
  padding: 9px 12px;
  color: var(--oa-muted-strong);
  border: 1px solid transparent;
  border-radius: var(--oa-radius-sm);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.oa-nav-link:hover {
  color: var(--oa-text-strong);
  background: var(--oa-surface-muted);
  border-color: var(--oa-border);
}

.oa-nav-link.is-active,
.oa-nav-link[aria-current="page"] {
  color: #087c40;
  background: var(--oa-primary-soft);
  border-color: rgba(0, 177, 74, 0.2);
  font-weight: 600;
}

.oa-nav-icon {
  display: inline-grid;
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  place-items: center;
  color: currentColor;
}

.oa-main {
  min-width: 0;
}

.oa-topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  gap: 16px;
  padding: 12px clamp(18px, 3vw, 42px);
  background: rgba(255, 255, 255, 0.78);
  border-bottom: 1px solid var(--oa-border);
  backdrop-filter: blur(18px);
}

.oa-topbar-title {
  min-width: 0;
  color: var(--oa-muted-strong);
  font-size: 15px;
  font-weight: 600;
}

.oa-topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.oa-main-content {
  width: min(100%, var(--oa-content-max));
  padding: clamp(22px, 3.5vw, 48px);
  margin: 0 auto;
}

/* Page headers and surfaces */
.oa-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.oa-page-title,
.oa-theme h1,
.oa-theme h2,
.oa-theme h3,
.oa-theme h4 {
  margin: 0;
  color: var(--oa-text-strong);
  font-family: var(--oa-font-heading);
  letter-spacing: -0.01em;
}

.oa-page-title {
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 600;
  line-height: 1.15;
}

.oa-theme h2 {
  font-size: 24px;
  font-weight: 600;
}

.oa-theme h3 {
  font-size: 19px;
  font-weight: 600;
}

.oa-theme h4 {
  font-size: 16px;
  font-weight: 600;
}

.oa-page-subtitle,
.oa-section-subtitle {
  max-width: 720px;
  margin: 7px 0 0;
  color: var(--oa-muted);
  font-size: 15px;
}

.oa-surface,
.oa-card,
.oa-panel {
  background: linear-gradient(180deg, var(--oa-surface), var(--oa-surface-soft));
  border: 1px solid var(--oa-border);
  border-radius: var(--oa-radius-lg);
  box-shadow: var(--oa-shadow-sm);
}

.oa-surface,
.oa-panel {
  padding: clamp(18px, 2.4vw, 28px);
}

.oa-card {
  min-width: 0;
  padding: 20px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.oa-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--oa-shadow-md);
}

.oa-section {
  margin-top: 28px;
}

.oa-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.oa-divider {
  height: 1px;
  margin: 20px 0;
  background: var(--oa-border);
  border: 0;
}

/* Buttons */
.oa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  gap: 8px;
  padding: 9px 16px;
  color: var(--oa-text-strong);
  background: var(--oa-surface);
  border: 1px solid var(--oa-border-strong);
  border-radius: var(--oa-radius-sm);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
  cursor: pointer;
  font-weight: 600;
  line-height: 1.2;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.oa-btn:hover {
  border-color: #bccbd4;
  box-shadow: var(--oa-shadow-sm);
  transform: translateY(-1px);
}

.oa-btn:active {
  transform: translateY(0);
}

.oa-btn-primary {
  color: #fff;
  background: var(--oa-primary);
  border-color: var(--oa-primary);
  box-shadow: 0 10px 22px rgba(0, 177, 74, 0.18);
}

.oa-btn-primary:hover {
  color: #fff;
  background: var(--oa-primary-hover);
  border-color: var(--oa-primary-hover);
}

.oa-btn-secondary {
  color: #315ecf;
  background: var(--oa-secondary-soft);
  border-color: #cbd9ff;
}

.oa-btn-secondary:hover {
  color: #264db3;
  background: #e3ebff;
  border-color: #aec2fb;
}

.oa-btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.oa-btn-ghost:hover {
  background: var(--oa-surface-muted);
  border-color: var(--oa-border);
  box-shadow: none;
}

.oa-btn-danger {
  color: #b93442;
  background: var(--oa-danger-soft);
  border-color: #f2c4ca;
}

.oa-btn-danger:hover {
  color: #a12836;
  background: #ffe4e7;
}

.oa-btn-sm {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 14px;
}

.oa-btn-icon {
  width: 40px;
  padding: 8px;
}

.oa-btn:disabled,
.oa-btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Forms */
.oa-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

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

.oa-field-full {
  grid-column: 1 / -1;
}

.oa-label {
  color: var(--oa-muted-strong);
  font-size: 14px;
  font-weight: 600;
}

.oa-input,
.oa-select,
.oa-textarea {
  width: 100%;
  color: var(--oa-text);
  background: #fff;
  border: 1px solid var(--oa-border-strong);
  border-radius: var(--oa-radius-sm);
  outline: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.oa-input,
.oa-select {
  min-height: 42px;
  padding: 9px 12px;
}

.oa-textarea {
  min-height: 110px;
  padding: 11px 12px;
  resize: vertical;
}

.oa-input::placeholder,
.oa-textarea::placeholder {
  color: #9ba5b1;
}

.oa-input:hover,
.oa-select:hover,
.oa-textarea:hover {
  border-color: #b8c7d0;
}

.oa-input:focus,
.oa-select:focus,
.oa-textarea:focus {
  border-color: var(--oa-secondary);
  box-shadow: var(--oa-focus);
}

.oa-help-text {
  color: var(--oa-muted);
  font-size: 13px;
}

.oa-error-text {
  color: var(--oa-danger);
  font-size: 13px;
}

/* KPI and dashboard layouts */
.oa-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.oa-kpi {
  min-width: 0;
  padding: 18px;
  background: var(--oa-surface);
  border: 1px solid var(--oa-border);
  border-radius: var(--oa-radius-md);
  box-shadow: var(--oa-shadow-sm);
}

.oa-kpi-label {
  color: var(--oa-muted);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
}

.oa-kpi-value {
  margin-top: 8px;
  color: var(--oa-text-strong);
  font-family: var(--oa-font-heading);
  font-size: clamp(24px, 2.6vw, 34px);
  font-weight: 600;
  line-height: 1.05;
}

.oa-kpi-meta {
  margin-top: 8px;
  color: var(--oa-muted);
  font-size: 14px;
}

.oa-kpi-meta.is-positive {
  color: #0b8c4c;
}

.oa-kpi-meta.is-negative {
  color: var(--oa-danger);
}

.oa-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.oa-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

/* Tables */
.oa-table-wrap {
  overflow-x: auto;
  background: var(--oa-surface);
  border: 1px solid var(--oa-border);
  border-radius: var(--oa-radius-md);
  box-shadow: var(--oa-shadow-sm);
}

.oa-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  color: var(--oa-text);
  font-size: 14px;
}

.oa-table th,
.oa-table td {
  padding: 13px 16px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--oa-border);
}

.oa-table th {
  color: var(--oa-muted);
  background: var(--oa-bg-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.oa-table tbody tr {
  transition: background 140ms ease;
}

.oa-table tbody tr:hover {
  background: #fbfcfd;
}

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

/* Status badges */
.oa-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  gap: 6px;
  padding: 4px 9px;
  color: var(--oa-muted-strong);
  background: var(--oa-surface-muted);
  border: 1px solid var(--oa-border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.oa-badge.is-success {
  color: #087c40;
  background: var(--oa-primary-soft);
  border-color: #bfead0;
}

.oa-badge.is-warning {
  color: #98630c;
  background: var(--oa-warning-soft);
  border-color: #f0d89c;
}

.oa-badge.is-danger {
  color: #b93442;
  background: var(--oa-danger-soft);
  border-color: #f2c4ca;
}

.oa-badge.is-info {
  color: #315ecf;
  background: var(--oa-info-soft);
  border-color: #c9d9fa;
}

/* Tabs and filters */
.oa-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.oa-toolbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.oa-tabs {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 3px;
  padding: 4px;
  overflow-x: auto;
  background: var(--oa-surface-muted);
  border: 1px solid var(--oa-border);
  border-radius: var(--oa-radius-sm);
}

.oa-tab {
  min-height: 34px;
  padding: 7px 12px;
  color: var(--oa-muted-strong);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.oa-tab:hover {
  color: var(--oa-text-strong);
  background: rgba(255, 255, 255, 0.7);
}

.oa-tab.is-active,
.oa-tab[aria-selected="true"] {
  color: var(--oa-text-strong);
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.07);
}

/* Modal, drawer and feedback states */
.oa-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(21, 29, 42, 0.36);
  backdrop-filter: blur(5px);
}

.oa-modal {
  width: min(100%, 620px);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  background: #fff;
  border: 1px solid var(--oa-border);
  border-radius: var(--oa-radius-lg);
  box-shadow: var(--oa-shadow-lg);
}

.oa-modal-header,
.oa-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
}

.oa-modal-header {
  border-bottom: 1px solid var(--oa-border);
}

.oa-modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--oa-border);
}

.oa-modal-body {
  padding: 22px;
}

.oa-empty,
.oa-loading,
.oa-error-state {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 28px;
  color: var(--oa-muted);
  text-align: center;
  background: var(--oa-surface-soft);
  border: 1px dashed var(--oa-border-strong);
  border-radius: var(--oa-radius-md);
}

.oa-error-state {
  color: #b93442;
  background: var(--oa-danger-soft);
  border-color: #f2c4ca;
}

.oa-skeleton {
  position: relative;
  overflow: hidden;
  min-height: 16px;
  background: #e9eef2;
  border-radius: 6px;
}

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

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

/* Compact mobile layout */
@media (max-width: 980px) {
  .oa-app-shell {
    grid-template-columns: 1fr;
  }

  .oa-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-102%);
    transition: transform 180ms ease;
  }

  .oa-sidebar.is-open {
    transform: translateX(0);
    box-shadow: var(--oa-shadow-lg);
  }

  .oa-main-content {
    padding: 24px;
  }

  .oa-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .oa-topbar {
    min-height: 60px;
    padding: 10px 16px;
  }

  .oa-topbar-title {
    font-size: 14px;
  }

  .oa-topbar-actions .oa-btn:not(.oa-btn-icon) {
    min-height: 36px;
    padding: 7px 10px;
    font-size: 13px;
  }

  .oa-main-content {
    padding: 18px 14px 28px;
  }

  .oa-page-header,
  .oa-section-header {
    display: block;
  }

  .oa-page-title {
    font-size: 28px;
  }

  .oa-page-header .oa-toolbar-actions,
  .oa-section-header .oa-toolbar-actions {
    margin-top: 14px;
  }

  .oa-grid-2,
  .oa-grid-3,
  .oa-form-grid {
    grid-template-columns: 1fr;
  }

  .oa-field-full {
    grid-column: auto;
  }

  .oa-kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .oa-kpi {
    padding: 14px;
  }

  .oa-kpi-label {
    font-size: 11px;
  }

  .oa-kpi-value {
    font-size: 25px;
  }

  .oa-card,
  .oa-surface,
  .oa-panel {
    border-radius: var(--oa-radius-md);
  }

  .oa-modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .oa-modal {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--oa-radius-lg) var(--oa-radius-lg) 0 0;
  }

  .oa-modal-header,
  .oa-modal-body,
  .oa-modal-footer {
    padding: 16px;
  }
}

@media (max-width: 420px) {
  .oa-kpi-grid {
    grid-template-columns: 1fr;
  }

  .oa-toolbar-actions,
  .oa-toolbar-actions .oa-btn,
  .oa-toolbar-actions .oa-input,
  .oa-toolbar-actions .oa-select {
    width: 100%;
  }

  .oa-btn {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .oa-theme *,
  .oa-theme *::before,
  .oa-theme *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
