/* ==========================================================
   Poyacity shared design system — web, PWA and native shells
   This layer centralizes visual tokens and accessibility rules
   without changing page data contracts or application logic.
========================================================== */

:root {
  color-scheme: light;
  --poya-brand-950: #082f49;
  --poya-brand-900: #0b426f;
  --poya-brand-800: #0f5a91;
  --poya-brand-700: #1769aa;
  --poya-brand-600: #1c7ac4;
  --poya-brand-500: #298bd2;
  --poya-brand-100: #e8f3fb;
  --poya-brand-50: #f4f9fd;
  --poya-accent: #00a86b;
  --poya-accent-strong: #087f5b;
  --poya-ink: #142033;
  --poya-muted: #607083;
  --poya-canvas: #f3f7fb;
  --poya-surface: #ffffff;
  --poya-surface-soft: #f8fbfd;
  --poya-border: #dce6ef;
  --poya-border-strong: #c7d5e2;
  --poya-success: #137a50;
  --poya-warning: #9a6700;
  --poya-danger: #b42318;
  --poya-info: #1769aa;
  --poya-radius-sm: 10px;
  --poya-radius-md: 16px;
  --poya-radius-lg: 24px;
  --poya-radius-xl: 32px;
  --poya-shadow-sm: 0 4px 16px rgba(20, 46, 72, .06);
  --poya-shadow-md: 0 12px 36px rgba(20, 46, 72, .09);
  --poya-shadow-lg: 0 24px 70px rgba(20, 46, 72, .14);
  --poya-focus: 0 0 0 3px rgba(23, 105, 170, .24);
  --poya-content: 1200px;
  --poya-motion-fast: 150ms;
  --poya-motion: 240ms;
  --poya-ease: cubic-bezier(.2, .8, .2, 1);

  /* Compatibility aliases for existing stylesheets. */
  --primary: var(--poya-brand-700);
  --secondary: var(--poya-brand-900);
  --text: var(--poya-ink);
  --bg: var(--poya-canvas);
  --border: var(--poya-border);
  --shadow: var(--poya-shadow-md);
  --shadow-hover: var(--poya-shadow-lg);
  --radius: var(--poya-radius-lg);
  --app-bg: var(--poya-canvas);
  --app-surface: var(--poya-surface);
  --app-primary: var(--poya-brand-700);
  --app-primary-2: var(--poya-brand-900);
  --app-text: var(--poya-ink);
  --app-muted: var(--poya-muted);
  --app-border: var(--poya-border);
}

html {
  background: var(--poya-canvas);
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  accent-color: var(--poya-brand-700);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

::selection {
  color: var(--poya-brand-950);
  background: rgba(41, 139, 210, .24);
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--poya-brand-700);
  outline-offset: 3px;
  box-shadow: var(--poya-focus);
}

:where(button, input, select, textarea) {
  font: inherit;
}

:where(button, [type="button"], [type="submit"], [role="button"]) {
  min-block-size: 44px;
  cursor: pointer;
  touch-action: manipulation;
}

:where(button, input, select, textarea):disabled,
:where([aria-disabled="true"]) {
  cursor: not-allowed;
  opacity: .58;
}

:where(input, select, textarea) {
  max-inline-size: 100%;
  border: 1px solid var(--poya-border-strong);
  border-radius: var(--poya-radius-sm);
  background: var(--poya-surface);
  color: var(--poya-ink);
  transition: border-color var(--poya-motion-fast), box-shadow var(--poya-motion-fast), background var(--poya-motion-fast);
}

:where(input, select, textarea):hover:not(:disabled) {
  border-color: #9bb3c7;
}

:where(input, select, textarea):focus {
  border-color: var(--poya-brand-700);
}

:where(input, textarea)::placeholder {
  color: #8392a3;
  opacity: 1;
}

:where(a, button) {
  -webkit-tap-highlight-color: transparent;
}

:where(a) {
  text-underline-offset: .18em;
}

:where(main, section, article, aside, nav, header, footer) {
  min-inline-size: 0;
}

/* Shared chrome */
.form-header,
.top-header,
.dashboard-menu,
.dashboard-nav,
.public-dashboard-nav {
  border: 1px solid rgba(220, 230, 239, .9);
  box-shadow: var(--poya-shadow-sm);
  backdrop-filter: saturate(135%) blur(12px);
}

.form-header {
  background: rgba(255, 255, 255, .94);
}

.form-header-logo,
.logo-box {
  color: var(--poya-ink);
}

.logo-small,
.logo-box img,
.app-avatar {
  box-shadow: 0 8px 22px rgba(23, 105, 170, .14);
}

.header-nav-group,
.dashboard-menu {
  align-items: center;
}

.back-link,
.dashboard-menu a,
.dashboard-nav a,
.public-dashboard-nav a {
  border-radius: var(--poya-radius-sm);
  transition: color var(--poya-motion-fast), background var(--poya-motion-fast), transform var(--poya-motion-fast);
}

.back-link:hover,
.dashboard-menu a:hover,
.dashboard-nav a:hover,
.public-dashboard-nav a:hover {
  transform: translateY(-1px);
}

/* Landing and informational pages */
.hero {
  isolation: isolate;
  background:
    radial-gradient(circle at 18% 15%, rgba(255, 255, 255, .20), transparent 28%),
    radial-gradient(circle at 84% 32%, rgba(0, 200, 83, .20), transparent 30%),
    linear-gradient(135deg, var(--poya-brand-950), var(--poya-brand-700) 52%, #6a1b9a);
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  z-index: 0;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(4px);
}

.hero::before {
  inline-size: 280px;
  block-size: 280px;
  inset-inline-start: -110px;
  inset-block-end: -150px;
  background: rgba(255, 214, 0, .13);
}

.hero::after {
  inline-size: 220px;
  block-size: 220px;
  inset-inline-end: -80px;
  inset-block-start: -90px;
  background: rgba(255, 112, 67, .16);
}

.hero .logo {
  border: 1px solid rgba(255, 255, 255, .72);
  box-shadow: 0 18px 52px rgba(3, 24, 44, .28);
}

.hero-text {
  text-wrap: balance;
}

.hero-btn,
.dash-switch-btn,
.filter-reset-btn,
.app-primary-cta,
.native-primary-button,
.native-secondary-button,
button[type="submit"] {
  border: 1px solid transparent;
  transition: transform var(--poya-motion), box-shadow var(--poya-motion), background var(--poya-motion), border-color var(--poya-motion);
}

.hero-btn:hover,
.dash-switch-btn:hover,
.filter-reset-btn:hover,
.app-primary-cta:hover,
.native-primary-button:hover,
.native-secondary-button:hover,
button[type="submit"]:hover {
  transform: translateY(-2px);
}

.section-card,
.card,
.cta-box,
.table-card,
.chart-card,
.map-card,
.filter-card,
.stat-card,
.mini-card,
.dashboard-card,
.auth-card {
  border: 1px solid rgba(220, 230, 239, .88);
  box-shadow: var(--poya-shadow-md);
}

.section-card,
.card,
.cta-box,
.table-card,
.chart-card,
.map-card,
.filter-card,
.dashboard-card,
.auth-card {
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.card,
.mini-card,
.stat-card,
.table-card,
.chart-card,
.map-card,
.filter-card,
.dashboard-card {
  transition: transform var(--poya-motion), box-shadow var(--poya-motion), border-color var(--poya-motion);
}

.card:hover,
.mini-card:hover,
.stat-card:hover,
.table-card:hover,
.chart-card:hover,
.map-card:hover,
.dashboard-card:hover {
  border-color: #c3d6e6;
  box-shadow: var(--poya-shadow-lg);
}

.card-icon {
  display: grid;
  place-items: center;
  inline-size: 64px;
  block-size: 64px;
  margin-inline: auto;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--poya-brand-50), #fff);
  box-shadow: inset 0 0 0 1px var(--poya-border);
}

.benefits li {
  border: 1px solid transparent;
}

.benefits li:hover {
  border-color: var(--poya-border);
  box-shadow: var(--poya-shadow-md);
}

/* Forms */
:where(form) label {
  color: #334155;
  font-weight: 650;
}

:where(form) input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
:where(form) select,
:where(form) textarea {
  min-block-size: 46px;
  padding: 10px 12px;
}

:where(form) textarea {
  min-block-size: 120px;
  resize: vertical;
}

:where(form) button[type="submit"] {
  padding-inline: 22px;
  border-radius: var(--poya-radius-sm);
  background: linear-gradient(135deg, var(--poya-brand-700), var(--poya-brand-900));
  color: #fff;
  box-shadow: 0 10px 24px rgba(23, 105, 170, .20);
}

:where([role="status"], [role="alert"]) {
  border-radius: var(--poya-radius-sm);
}

/* Dashboards and data density */
.dashboard-layout,
.dashboard-container {
  max-inline-size: 1800px;
}

.top-header {
  background: rgba(255, 255, 255, .94);
}

.header-stats,
.stats-grid,
.kpi-grid {
  gap: 12px;
}

.mini-card,
.stat-card {
  background: linear-gradient(180deg, #fff, var(--poya-brand-50));
}

.mini-card strong,
.stat-card strong,
.kpi-value {
  font-variant-numeric: tabular-nums;
}

.dashboard-menu {
  position: sticky;
  inset-block-start: 8px;
  z-index: 40;
  overflow-x: auto;
  background: rgba(255, 255, 255, .92);
  scrollbar-width: thin;
}

.dashboard-menu a {
  white-space: nowrap;
}

:where(table) {
  border-collapse: separate;
  border-spacing: 0;
  inline-size: 100%;
}

:where(th) {
  position: sticky;
  inset-block-start: 0;
  z-index: 2;
  background: #eef5fb;
  color: #24384c;
  font-weight: 750;
}

:where(th, td) {
  border-block-end: 1px solid var(--poya-border);
}

:where(tbody tr) {
  transition: background var(--poya-motion-fast);
}

:where(tbody tr:hover) {
  background: #f3f8fc;
}

:where(canvas, .leaflet-container) {
  border-radius: var(--poya-radius-md);
}

/* Native app shell */
.app-shell {
  background:
    radial-gradient(circle at 20% 0, rgba(41, 139, 210, .07), transparent 28%),
    var(--app-bg);
}

.app-topbar {
  border-block-end: 1px solid rgba(255, 255, 255, .16);
  background:
    radial-gradient(circle at 15% -30%, rgba(255, 255, 255, .24), transparent 44%),
    linear-gradient(135deg, var(--poya-brand-700), var(--poya-brand-950));
  box-shadow: 0 12px 34px rgba(8, 47, 73, .22);
}

.app-icon-btn {
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(255, 255, 255, .10);
  backdrop-filter: blur(8px);
  transition: background var(--poya-motion-fast), transform var(--poya-motion-fast);
}

.app-icon-btn:hover {
  background: rgba(255, 255, 255, .18);
  transform: translateY(-1px);
}

:where(.app-screen, .native-panel, .native-card, .native-settings-card, .native-analysis-card, .management-message-form, .management-message-card, .native-activity-item, .native-personal-grid button) {
  border-color: var(--poya-border);
  box-shadow: var(--poya-shadow-sm);
}

:where(.app-status-card, .native-kpi-card, .native-recent-item, .native-insight-item) {
  transition: transform var(--poya-motion-fast), border-color var(--poya-motion-fast), box-shadow var(--poya-motion-fast);
}

:where(.app-status-card, .native-kpi-card, .native-recent-item, .native-insight-item):hover {
  transform: translateY(-1px);
  border-color: #bfd2e2;
  box-shadow: var(--poya-shadow-sm);
}

.app-primary-cta,
.native-primary-button {
  background: linear-gradient(135deg, var(--poya-brand-700), var(--poya-brand-900));
  box-shadow: 0 12px 26px rgba(23, 105, 170, .20);
}

.app-bottom-nav {
  border-block-start: 1px solid rgba(199, 213, 226, .9);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(140%) blur(18px);
  box-shadow: 0 -10px 34px rgba(20, 46, 72, .08);
}

.app-bottom-nav button,
.drawer-menu button,
.native-civic-tabs button {
  transition: color var(--poya-motion-fast), background var(--poya-motion-fast), transform var(--poya-motion-fast);
}

.app-bottom-nav button:active,
.drawer-menu button:active,
.native-civic-tabs button:active {
  transform: scale(.98);
}

.offline-pill,
.app-badge,
.forum-bank-badge,
.management-status {
  font-variant-numeric: tabular-nums;
}

.native-search-backdrop {
  background: rgba(4, 20, 34, .62);
  backdrop-filter: blur(10px) saturate(120%);
}

.native-search-panel {
  border: 1px solid rgba(255, 255, 255, .4);
  box-shadow: 0 30px 90px rgba(3, 19, 32, .30);
}

/* Dark theme parity for the native shell. */
.theme-dark {
  color-scheme: dark;
  --poya-canvas: #0d1626;
  --poya-surface: #162235;
  --poya-surface-soft: #111d2e;
  --poya-ink: #eff6ff;
  --poya-muted: #a5b4c6;
  --poya-border: #2b3b52;
  --poya-border-strong: #3b4e67;
  --app-bg: var(--poya-canvas);
  --app-surface: var(--poya-surface);
  --app-text: var(--poya-ink);
  --app-muted: var(--poya-muted);
  --app-border: var(--poya-border);
}

.theme-dark :where(.app-screen, .native-panel, .native-card, .native-settings-card, .native-analysis-card, .management-message-form, .management-message-card, .native-activity-item, .native-personal-grid button, .native-search-panel) {
  background: linear-gradient(180deg, #17263a, #132033);
}

.theme-dark .app-bottom-nav {
  background: rgba(17, 29, 46, .94);
  border-color: #2b3b52;
}

.theme-dark :where(input, select, textarea) {
  background: #101b2b;
  color: var(--poya-ink);
  border-color: var(--poya-border-strong);
}

/* Responsive and accessibility refinements */
@media (max-width: 900px) {
  .top-header {
    align-items: flex-start;
  }

  .dashboard-menu {
    margin-inline: -2%;
    padding-inline: 4%;
    border-inline: 0;
    border-radius: 0;
  }
}

@media (max-width: 640px) {
  :root {
    --poya-radius-lg: 19px;
    --poya-radius-xl: 24px;
  }

  .hero {
    padding-inline: 16px;
  }

  .hero h1 {
    font-size: clamp(2rem, 11vw, 2.7rem);
  }

  .hero-stats {
    gap: 14px;
  }

  .hero-stat-number {
    font-size: 24px;
  }

  .hero-btn {
    inline-size: 100%;
    max-inline-size: 330px;
  }

  .section-card,
  .card,
  .cta-box {
    padding-inline: 20px;
  }

  .form-header-inner {
    align-items: stretch;
  }

  .header-nav-group {
    inline-size: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-block-end: 4px;
  }

  .header-nav-group > * {
    flex: 0 0 auto;
  }

  :where(th, td) {
    padding-inline: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

@media (forced-colors: active) {
  :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid CanvasText;
  }

  .hero-btn,
  .dash-switch-btn,
  .app-primary-cta,
  .native-primary-button,
  button[type="submit"] {
    border: 1px solid ButtonText;
  }
}

@media print {
  .form-header,
  .dashboard-menu,
  .app-topbar,
  .app-bottom-nav,
  .hero-buttons,
  button {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  :where(.section-card, .card, .table-card, .chart-card, .map-card) {
    box-shadow: none !important;
    break-inside: avoid;
  }
}
