/*
 * VierTechSolutions — Unified UI Layer v1
 * Shared visual, responsive and low-overhead refinements.
 * This file intentionally changes presentation only; no application behavior.
 */
:root {
  --ui-accent: var(--primary, #7067f5);
  --ui-radius-sm: 10px;
  --ui-radius-md: 14px;
  --ui-radius-lg: 18px;
  --ui-radius-xl: 22px;
  --ui-shadow-soft: 0 5px 18px rgba(8, 15, 35, .075);
  --ui-shadow-card: 0 12px 32px rgba(8, 15, 35, .09);
  --ui-focus-ring: color-mix(in srgb, var(--ui-accent) 24%, transparent);
  --ui-motion: 160ms cubic-bezier(.2, .7, .2, 1);
}

[data-theme="light"] {
  --ui-shadow-soft: 0 5px 18px rgba(25, 35, 65, .055);
  --ui-shadow-card: 0 12px 30px rgba(25, 35, 65, .075);
}

html {
  width: 100%;
  min-width: 0;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 88px;
}

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

body {
  min-width: 280px;
  max-width: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

:where(main, header, footer, section, article, aside, nav, form, dialog) {
  min-width: 0;
}

:where(img, picture, video, canvas, iframe) {
  max-width: 100%;
}

:where(button, input, select, textarea) {
  max-width: 100%;
  font-family: inherit;
  line-height: 1.4;
}

:where(h1, h2, h3, h4, h5, h6) {
  text-wrap: balance;
  line-height: 1.2;
}

:where(p, li, dd) {
  text-wrap: pretty;
}

:where(pre, code, .terminal, .log-view, .code-block) {
  overflow-wrap: anywhere;
}

:where(pre, .terminal, .log-view, .code-block) {
  max-width: 100%;
  overscroll-behavior: contain;
}

:where(.app-shell, .main-area, .content, .shell-content, .public-main, .public-container, .container, .auth-layout) {
  min-width: 0;
}

/* Consistent content width and resilient grid/flex children. */
.content,
.shell-content {
  width: min(100% - clamp(24px, 4vw, 64px), 1440px);
  max-width: 1440px;
  min-width: 0;
}

.main-area {
  min-width: 0;
  min-height: 100svh;
}

[class*="grid"] {
  min-width: 0;
}

[class*="grid"] > *,
[class*="row"] > *,
[class*="layout"] > * {
  min-width: 0;
}

/* Sharper and more legible application navigation. */
.topbar {
  min-width: 0;
  padding-inline: clamp(14px, 2.2vw, 28px);
}

.top-left,
.top-actions,
.page-title,
.profile-copy,
.sidebar-head,
.sidebar-foot {
  min-width: 0;
}

.page-title span {
  font-size: 14px;
  line-height: 1.25;
  letter-spacing: -.015em;
}

.page-title small,
.profile-copy small,
.mini-profile small {
  font-size: 10.5px;
  line-height: 1.4;
}

.profile-copy strong,
.mini-profile strong {
  font-size: 12px;
  line-height: 1.3;
}

.side-nav .nav-item {
  min-height: 42px;
  font-size: 12px;
  line-height: 1.35;
  border-radius: 11px;
}

.side-nav .nav-label,
.sidebar .nav-label {
  font-size: 9.5px;
  letter-spacing: .12em;
}

.eyebrow,
.panel-kicker,
.card-kicker,
.kicker,
.vs-kicker-admin {
  line-height: 1.4;
}

.page-section-head,
.welcome-row,
.section-heading,
.panel-head,
.card-head {
  min-width: 0;
}

.page-section-head p,
.welcome-row p,
.section-heading p,
.panel-head p {
  line-height: 1.65;
}

/* Unified surfaces without replacing page-specific colors or content. */
:is(
  .panel,
  .card,
  .metric-card,
  .settings-card,
  .message-card,
  .command-card,
  .pricing-card,
  .dashboard-connect,
  .vb-connect-panel,
  .table-card,
  .catalog-panel,
  .ticket-admin-list-card,
  .ticket-thread-card,
  .vb5-card,
  .vb5-panel,
  .vf-card,
  .auth-card,
  .vs-admin-card,
  .vs8-panel,
  .config-card
) {
  min-width: 0;
  border-color: var(--border, rgba(128, 140, 165, .18));
  border-radius: var(--ui-radius-lg);
}

:is(.panel, .card, .metric-card, .settings-card, .message-card, .command-card, .pricing-card, .table-card, .catalog-panel, .ticket-admin-list-card, .ticket-thread-card, .config-card) {
  box-shadow: var(--ui-shadow-soft);
}

/* Consistent touch targets and keyboard focus. */
:is(
  .btn,
  .primary-btn,
  .ghost-btn,
  .control-btn,
  .vb-btn,
  .catalog-btn,
  .gw-btn,
  .vf-button,
  .vb5-btn,
  .auth-btn,
  .da-button,
  .vps-login,
  .vps-cta,
  .icon-btn,
  .vps-icon,
  .menu-btn,
  .nav-icon
) {
  min-height: 40px;
  touch-action: manipulation;
}

:where(button, a, input, select, textarea, [role="button"], [tabindex]):focus-visible {
  outline: 2px solid var(--ui-accent);
  outline-offset: 3px;
}

:where(button, .nav-item, [role="button"]) {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Form fields: predictable sizing, readable input text and clear focus state. */
:where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]),
  select,
  textarea
) {
  min-width: 0;
  max-width: 100%;
  min-height: 42px;
  border-radius: 11px;
  font-size: 14px !important;
  transition: border-color var(--ui-motion), box-shadow var(--ui-motion);
}

:where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]),
  select,
  textarea
):focus {
  border-color: color-mix(in srgb, var(--ui-accent) 62%, var(--border, #cbd5e1));
  box-shadow: 0 0 0 3px var(--ui-focus-ring);
  outline: none;
}

:where(input[type="checkbox"], input[type="radio"]) {
  accent-color: var(--ui-accent);
}

:where(textarea) {
  max-width: 100%;
  resize: vertical;
}

/* Data-heavy screens stay inside their viewport on touch devices. */
:is(.tablewrap, .table-wrap, .table-responsive, .table-scroll, .table-container, .data-table-wrap, .table-card) {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

table {
  max-width: 100%;
}

/* Better spacing for the most common small dashboard labels. */
.metric-head,
.metric-card small,
.quick-grid small,
.account-meta,
.faq-panel details p,
.toast span {
  line-height: 1.55;
}

.metric-head { font-size: 11px; }
.metric-card small { font-size: 10px; }
.quick-grid span { font-size: 11px; }
.quick-grid small { font-size: 10px; }
.toast span { font-size: 12px; }

/* Responsive public navigation and page content. */
.public-container {
  width: min(100% - 40px, 1200px);
  margin-inline: auto;
}

.vps-nav,
.auth-nav {
  min-width: 0;
}

.vps-links,
.vps-actions,
.nav-actions,
.auth-header .nav-actions {
  min-width: 0;
}

.vps-footer-grid > *,
.vps-footer-bottom > * {
  min-width: 0;
}

/* Reduce expensive compositing on narrow devices while keeping the visual style. */
@media (max-width: 820px) {
  .content,
  .shell-content {
    width: calc(100% - 28px);
  }

  .topbar {
    padding-inline: 14px;
  }

  .site-header,
  .vps-header,
  .auth-header,
  .topbar,
  .sidebar,
  .sidebar-overlay,
  .vps-overlay,
  dialog::backdrop {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  .bg-orb,
  .orb-1,
  .orb-2 {
    filter: none !important;
    opacity: .08;
  }

  .public-container {
    width: calc(100% - 32px);
  }
}

@media (max-width: 620px) {
  .content,
  .shell-content {
    width: calc(100% - 24px);
  }

  .topbar {
    padding-inline: 12px;
  }

  .top-actions {
    gap: 6px;
  }

  .page-title span {
    font-size: 13px;
  }

  .page-section-head {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    margin-block: 18px 14px;
  }

  .panel-head,
  .card-head {
    gap: 10px;
  }

  .public-container {
    width: calc(100% - 24px);
  }

  .vps-footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px 16px;
  }

  .vps-footer-grid > :first-child {
    grid-column: 1 / -1;
  }

  .vps-footer-bottom {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  :where(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]),
    select,
    textarea
  ) {
    min-height: 44px;
    font-size: 16px !important;
  }

  .auth-input {
    min-height: 46px;
    font-size: 16px !important;
  }

  :where(.btn, .primary-btn, .ghost-btn, .control-btn, .vb-btn, .catalog-btn, .gw-btn, .vf-button, .vb5-btn, .auth-btn, .da-button) {
    min-height: 42px;
  }
}

@media (max-width: 380px) {
  .content,
  .shell-content {
    width: calc(100% - 20px);
  }

  .topbar {
    padding-inline: 10px;
  }

  .top-actions {
    gap: 4px;
  }

  .public-container {
    width: calc(100% - 20px);
  }
}

@media (min-width: 1600px) {
  .content,
  .shell-content {
    width: min(100% - 80px, 1500px);
    max-width: 1500px;
  }
}

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