/*
 * Account Vault — V17 Premium Visual System
 * Additive presentation-only stylesheet. Loaded AFTER V5-V16 CSS.
 * No external fonts, URLs, telemetry, secrets, or animation dependencies.
 * Priority: stable layout, legible contrast, performance and accessibility.
 */
:root {
  --av17-accent: #6357e8;
  --av17-accent-hover: #5143d7;
  --av17-accent-rgb: 99, 87, 232;
  --av17-ink-soft: #53627d;
  --av17-divider: #e2e7f1;
  --av17-elev-1: 0 1px 2px rgba(25, 39, 70, .035), 0 9px 28px rgba(25, 39, 70, .045);
  --av17-elev-2: 0 10px 36px rgba(25, 39, 70, .085);
  --av17-elev-pop: 0 24px 75px rgba(11, 21, 46, .20);
  --av17-curve: cubic-bezier(.22, 1, .36, 1);
  --av17-quick: 125ms;
  --av17-normal: 190ms;
  --av17-panel: 240ms;
  --av17-outline: #6758e9;
  --av17-radius-sm: 11px;
  --av17-radius-md: 16px;
  --av17-radius-lg: 20px;
}
:root[data-theme="dark"] {
  --av17-accent: #ab9fff;
  --av17-accent-hover: #c3baff;
  --av17-accent-rgb: 171, 159, 255;
  --av17-ink-soft: #acb9d2;
  --av17-divider: #344158;
  --av17-elev-1: 0 2px 15px rgba(0,0,0,.15);
  --av17-elev-2: 0 12px 34px rgba(0,0,0,.20);
  --av17-elev-pop: 0 26px 75px rgba(0,0,0,.46);
  --av17-outline: #b0a5ff;
}

/* Structure: do not replace existing grid layouts or responsive breakpoints. */
html { text-rendering: optimizeLegibility; }
body { -webkit-font-smoothing: antialiased; }
:is(.shell, .workspace, .content, .panel, .table-panel, .modal, .drawer) { min-width: 0; }
:is(.content, .panel, .modal-body, .drawer) { overflow-wrap: break-word; }
:is(.page-head h1, .auth-card h2, .center-card h2, .panel-head h2) {
  letter-spacing: -.025em;
  text-wrap: balance;
}
:is(.panel, .stat-card, .service-card, .center-card, .auth-card, .table-panel, .modal) {
  -webkit-font-smoothing: antialiased;
}

/* Palette and surface polish: scoped to known Account Vault components. */
:is(.panel, .stat-card, .service-card, .center-card, .table-panel) {
  border-radius: var(--av17-radius-md);
  box-shadow: var(--av17-elev-1);
  transition: border-color var(--av17-normal) ease, box-shadow var(--av17-normal) ease;
}
:is(.panel, .stat-card, .service-card):hover {
  box-shadow: var(--av17-elev-2);
}
:is(.panel, .stat-card, .service-card, .table-panel):focus-within {
  border-color: color-mix(in srgb, var(--border) 65%, var(--av17-accent) 35%);
}
:is(.service-card, .stat-card) { isolation: isolate; }
:is(.stat-value, .page-head h1) { font-variant-numeric: tabular-nums; }
:is(.muted, .hint, .stat-sub) { line-height: 1.55; }

/* Navigation: no width transitions; avoids layout reflow or sidebar jitter. */
:is(.sidebar) { scrollbar-width: thin; }
:is(.sidebar .nav-link, .sidebar .service-nav-link) {
  transition: background-color var(--av17-normal) ease,
              color var(--av17-normal) ease,
              box-shadow var(--av17-normal) ease;
}
:is(.sidebar .nav-link:hover, .sidebar .service-nav-link:hover) {
  background: rgba(177, 169, 255, .11);
}
:is(.sidebar .nav-link.active, .sidebar .service-nav-link.active) {
  box-shadow: inset 3px 0 0 #aba2ff;
}
:is(.topbar) { border-bottom-color: var(--border); }

/* Buttons: optically crisp, respect disabled status. */
:is(.btn, .icon-button, .mini-btn, .link-button, .text-link) {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform var(--av17-quick) var(--av17-curve),
              color var(--av17-normal) ease,
              background-color var(--av17-normal) ease,
              border-color var(--av17-normal) ease,
              box-shadow var(--av17-normal) ease;
}
:is(.btn, .icon-button, .mini-btn):not(:disabled):active { transform: scale(.965); }
:is(.btn):not(:disabled):hover { transform: translateY(-1px); }
:is(.btn-primary) {
  background: linear-gradient(145deg, #7566f2 0%, #5e4edc 100%);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 7px 20px rgba(99, 85, 232, .19);
}
:is(.btn-primary):not(:disabled):hover {
  background: linear-gradient(145deg, #8275fa 0%, #5545d4 100%);
  box-shadow: 0 9px 22px rgba(99, 85, 232, .26);
}
:is(button, a, input, textarea, select, [role="button"]):focus-visible {
  outline: 3px solid var(--av17-outline);
  outline-offset: 3px;
}
:is(.btn, .icon-button):disabled { transform: none !important; }

/* Form response: no transition on layout properties. */
:is(input:not([type="checkbox"]), textarea, select) {
  transition: border-color var(--av17-normal) ease,
              box-shadow var(--av17-normal) ease,
              background-color var(--av17-normal) ease;
}
:is(input:not([type="checkbox"]), textarea, select):focus-visible {
  border-color: var(--av17-accent);
  box-shadow: 0 0 0 3px rgba(var(--av17-accent-rgb), .13);
}
:is(input, select, textarea)::placeholder { opacity: .77; }

/* Table: no transforms on rows and no animation on search re-renders. */
:is(.table-panel) { overflow: hidden; }
:is(.table-wrap) { overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; }
:is(.data-table thead th) { letter-spacing: .015em; }
:is(.data-table tbody td) {
  transition: background-color var(--av17-quick) ease;
}
:is(.data-table tbody tr:hover td) {
  background-color: var(--surface-alt);
}
:is(.data-table tbody tr:focus-within td) {
  background-color: var(--primary-soft);
}
:is(.table-toolbar .search-input):focus-within {
  box-shadow: 0 0 0 3px rgba(var(--av17-accent-rgb), .10);
}
:is(.table-toolbar .search-input) { transition: box-shadow var(--av17-normal) ease; }

/* Modals, drawer, feedback: animations run on entry only. */
:is(.modal-backdrop, .drawer-backdrop) { animation: av17-overlay-enter 180ms ease-out both; }
:is(.modal) { box-shadow: var(--av17-elev-pop); animation: av17-modal-enter var(--av17-panel) var(--av17-curve) both; }
:is(.drawer) { box-shadow: var(--av17-elev-pop); animation: av17-drawer-enter var(--av17-panel) var(--av17-curve) both; }
:is(.toast) { box-shadow: var(--av17-elev-2); animation: av17-toast-enter 220ms var(--av17-curve) both; }
:is(.modal, .drawer) { transform-origin: center top; }
:is(.modal-backdrop, .drawer-backdrop) { overscroll-behavior: contain; }

@keyframes av17-overlay-enter { from { opacity: 0; } to { opacity: 1; } }
@keyframes av17-modal-enter {
  from { opacity: .55; transform: translateY(11px) scale(.983); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes av17-drawer-enter {
  from { opacity: .6; transform: translateX(18px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes av17-toast-enter {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Login experience, without changing form width or the existing two-column layout. */
:is(.auth-visual) {
  background: radial-gradient(ellipse at 66% 31%, #5550a7 0%, #292a68 39%, #0e1934 84%);
}
:is(.auth-card, .center-card) { animation: av17-auth-enter 340ms var(--av17-curve) both; }
@keyframes av17-auth-enter {
  from { opacity: .75; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}
:is(.logo-mark, .hero-shield) { background: linear-gradient(140deg, #a195ff 5%, #6250e5 94%); }

/* Premium V16 page — selectors scoped so no effect on main app layout. */
body:has(> .container) {
  background: radial-gradient(ellipse at 20% 0%, #f1efff, transparent 45%), #f4f6fb;
  color: #1c2942;
}
body:has(> .container) .container { max-width: 1120px; }
body:has(> .container) .card,
body:has(> .container) .entry {
  background: #fff;
  border-color: #e3e8f3;
  box-shadow: var(--av17-elev-1);
  border-radius: var(--av17-radius-md);
  transition: border-color var(--av17-normal) ease, box-shadow var(--av17-normal) ease;
}
body:has(> .container) .card:hover { box-shadow: var(--av17-elev-2); }
body:has(> .container) button:not(.danger):not(.av17-motion-trigger) {
  transition: transform var(--av17-quick) var(--av17-curve), background-color var(--av17-normal) ease, border-color var(--av17-normal) ease;
}
body:has(> .container) button:not(:disabled):active { transform: scale(.97); }
body:has(> .container) button.primary { background: #6357e8; border-color: #6357e8; color: #fff; }
body:has(> .container) :is(input, textarea, select):focus-visible { box-shadow: 0 0 0 3px rgba(99,87,232,.15); }
body:has(> .container) #tabs { gap: 9px; }
body:has(> .container) #tabs button { border-radius: 12px; }

@media (prefers-color-scheme: dark) {
  body:has(> .container) { background: #111a2c; color: #edf2ff; }
  body:has(> .container) .card,
  body:has(> .container) .entry { background: #1b2942; border-color: #35445f; }
}

/* Motion preference control: hidden on auth page; placed inside existing header. */
.av17-motion-trigger {
  border: 1px solid var(--border, #dce2ef);
  border-radius: 11px;
  background: var(--surface, #fff);
  color: var(--text, #1f2c45);
  min-height: 36px;
  padding: 6px 11px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 650 12px/1.3 system-ui, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--av17-normal) ease, border-color var(--av17-normal) ease;
}
.av17-motion-trigger:hover { background: var(--surface-alt, #f4f5fa); border-color: var(--av17-accent); }
.av17-motion-trigger:focus-visible { outline: 3px solid var(--av17-outline); outline-offset: 2px; }
.av17-motion-trigger svg { width: 15px; height: 15px; }
.av17-motion-dialog {
  box-sizing: border-box;
  width: min(420px, calc(100vw - 30px));
  max-width: none;
  padding: 24px;
  border: 1px solid var(--border, #e5e8f3);
  border-radius: 20px;
  background: var(--surface, #fff);
  color: var(--text, #1e2940);
  box-shadow: var(--av17-elev-pop);
  margin: auto;
}
.av17-motion-dialog::backdrop { background: rgba(9, 16, 35, .55); }
.av17-motion-dialog h2 { margin: 0 0 8px; font-size: 19px; line-height: 1.25; }
.av17-motion-dialog p { margin: 0 0 17px; color: var(--subtle, #66718a); font-size: 13px; }
.av17-motion-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.av17-motion-options button {
  min-height: 42px; padding: 8px;
  border: 1px solid var(--border, #dce2ef);
  color: var(--text, #1e2940);
  background: var(--surface-alt, #f8f9fc);
  border-radius: 11px; font: 650 12px system-ui, sans-serif; cursor: pointer;
}
.av17-motion-options button[aria-pressed="true"] {
  background: var(--primary-soft, #efedff); color: var(--primary, #6456e8);
  border-color: var(--av17-accent);
}
.av17-motion-options button:focus-visible { outline: 3px solid var(--av17-outline); outline-offset: 2px; }
.av17-motion-close { display: block; margin: 17px 0 0 auto; border: 0; background: transparent; color: inherit; padding: 8px 2px; cursor: pointer; }

/* Compact phones: keep existing component layout from V5-V15, only tune new styles. */
@media (max-width: 720px) {
  .av17-motion-trigger { min-height: 34px; padding-inline: 8px; font-size: 11px; }
  :is(.panel, .service-card, .stat-card) { box-shadow: 0 2px 12px rgba(28,42,74,.035); }
  :is(.modal) { animation: av17-mobile-modal-enter 180ms var(--av17-curve) both; }
  @keyframes av17-mobile-modal-enter {
    from { opacity: .75; transform: translateY(13px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* Reduced / Off: OS accessibility preference always takes priority over Full. */
:root[data-av-motion="reduced"] :is(.modal, .drawer, .toast, .modal-backdrop, .drawer-backdrop, .auth-card, .center-card),
:root[data-av-motion="off"] :is(.modal, .drawer, .toast, .modal-backdrop, .drawer-backdrop, .auth-card, .center-card) {
  animation: none !important;
}
:root[data-av-motion="reduced"] :is(.btn, .icon-button, .mini-btn, .nav-link, .service-nav-link, .panel, .stat-card, .service-card),
:root[data-av-motion="off"] :is(.btn, .icon-button, .mini-btn, .nav-link, .service-nav-link, .panel, .stat-card, .service-card) {
  transition-duration: .01ms !important;
  transform: none !important;
}
:root[data-av-motion="off"] *, :root[data-av-motion="off"] *::before, :root[data-av-motion="off"] *::after {
  animation-duration: .01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .01ms !important;
  scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  :is(.btn, .icon-button, .mini-btn):hover,
  :is(.btn, .icon-button, .mini-btn):active { transform: none !important; }
}
