:root {
  --ui-accent: #ff7133;
  --ui-accent-strong: #ef4335;
  --ui-gold: #e5bb70;
  --ui-surface: rgba(24, 24, 27, 0.92);
  --ui-surface-raised: rgba(29, 29, 33, 0.96);
  --ui-border: rgba(255, 255, 255, 0.085);
  --ui-border-active: rgba(255, 113, 51, 0.44);
  --ui-shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.2);
  --ui-shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.34);
  --ui-radius-sm: 12px;
  --ui-radius-md: 18px;
  --ui-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  background:
    radial-gradient(circle at 88% 0%, rgba(239, 67, 53, 0.09), transparent 30rem),
    radial-gradient(circle at 28% 100%, rgba(255, 113, 51, 0.06), transparent 34rem),
    #0a0a0b;
}

body::selection,
body *::selection {
  background: rgba(255, 113, 51, 0.32);
  color: #fff;
}

* {
  scrollbar-color: #55545a #18181b;
  scrollbar-width: thin;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #18181b;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid #18181b;
  border-radius: 999px;
  background: #55545a;
}

*::-webkit-scrollbar-thumb:hover {
  background: #737279;
}

.login-view {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 14%, rgba(255, 113, 51, 0.2), transparent 28rem),
    radial-gradient(circle at 80% 78%, rgba(229, 187, 112, 0.08), transparent 30rem),
    #09090a;
}

.login-view::before,
.login-view::after {
  content: "";
  position: absolute;
  z-index: -1;
  border: 1px solid rgba(255, 113, 51, 0.14);
  border-radius: 50%;
}

.login-view::before {
  width: min(64vw, 820px);
  aspect-ratio: 1;
  left: -24vw;
  top: -36vw;
}

.login-view::after {
  width: min(46vw, 620px);
  aspect-ratio: 1;
  right: -18vw;
  bottom: -28vw;
}

.login-card {
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(28, 28, 32, 0.96), rgba(16, 16, 18, 0.96));
  box-shadow: var(--ui-shadow-lg), inset 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(20px);
  animation: ui-login-enter 0.65s var(--ui-ease) both;
}

.mark {
  position: relative;
  border-color: var(--ui-accent);
  background: radial-gradient(circle at 35% 30%, rgba(255, 113, 51, 0.18), transparent 65%);
  box-shadow: 0 0 0 6px rgba(255, 113, 51, 0.06), 0 0 30px rgba(255, 113, 51, 0.12);
}

.app-view {
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  padding: 24px 18px;
  border-color: var(--ui-border);
  background: linear-gradient(180deg, rgba(17, 17, 19, 0.98), rgba(10, 10, 11, 0.99));
  box-shadow: 18px 0 46px rgba(0, 0, 0, 0.18);
}

.brand {
  padding: 2px 4px 18px;
  border-bottom: 1px solid var(--ui-border);
}

.brand strong {
  letter-spacing: -0.015em;
}

.sidebar nav {
  gap: 4px;
}

.sidebar nav button {
  position: relative;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #b9b9c0;
  box-shadow: none;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s var(--ui-ease);
}

.sidebar nav button::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 50%;
  width: 3px;
  height: 20px;
  border-radius: 0 999px 999px 0;
  background: linear-gradient(var(--ui-accent), var(--ui-accent-strong));
  opacity: 0;
  transform: translateY(-50%) scaleY(0.35);
  transition: opacity 0.2s ease, transform 0.28s var(--ui-ease);
}

.sidebar nav button span {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 113, 51, 0.08);
  color: #ff9667;
  text-align: center;
  font-size: 11px;
}

.sidebar nav button span:empty {
  display: none;
}

.sidebar nav button.active,
.sidebar nav button[aria-current="page"] {
  border-color: rgba(255, 255, 255, 0.065);
  background: linear-gradient(90deg, rgba(255, 113, 51, 0.11), rgba(255, 255, 255, 0.035));
  color: #fff;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025);
}

.sidebar nav button.active::before,
.sidebar nav button[aria-current="page"]::before {
  opacity: 1;
  transform: translateY(-50%) scaleY(1);
}

.logout {
  min-height: 44px;
  border-color: var(--ui-border);
  background: rgba(255, 255, 255, 0.02);
}

.workspace {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), transparent 220px);
}

.topbar {
  min-height: 96px;
  padding: 18px 30px;
  border-color: var(--ui-border);
  background: rgba(10, 10, 11, 0.78);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.12);
}

.topbar h1 {
  letter-spacing: -0.035em;
}

.topbar .kicker {
  color: #ff8b58;
}

.connection-pill {
  min-height: 40px;
  padding-inline: 14px;
  border-color: var(--ui-border);
  background: rgba(255, 255, 255, 0.035);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

.connection-pill.is-online .connection-dot {
  animation: ui-online-pulse 2.3s ease-out infinite;
}

.qr-link,
.refresh {
  min-height: 42px;
  border-radius: 12px;
}

.content {
  max-width: 1640px;
  padding: 30px;
}

.notice {
  border-radius: 12px;
  box-shadow: var(--ui-shadow-sm);
}

button,
.quick-action,
.hero-actions a,
.qr-link {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  transition: transform 0.2s var(--ui-ease), border-color 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease, background 0.2s ease;
}

button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 11px;
  background: linear-gradient(135deg, var(--ui-accent), var(--ui-accent-strong));
  box-shadow: 0 8px 20px rgba(218, 60, 40, 0.17), inset 0 1px rgba(255, 255, 255, 0.13);
}

button.secondary,
.refresh,
.hero-actions button {
  border-color: var(--ui-border);
  background: linear-gradient(145deg, #29292e, #202024);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.045);
}

button.danger,
.actions .danger {
  border-color: rgba(255, 104, 94, 0.16);
  background: linear-gradient(145deg, #461f1f, #351818);
  color: #ffb0a9;
}

button:active,
.quick-action:active,
.hero-actions a:active,
.qr-link:active {
  transform: translateY(1px) scale(0.985);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(255, 113, 51, 0.28);
  outline-offset: 2px;
}

button:disabled {
  filter: saturate(0.5);
}

.ui-ripple {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.32);
  transform: scale(0);
  animation: ui-ripple 0.58s ease-out forwards;
}

input,
select,
textarea {
  min-height: 44px;
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  background: rgba(8, 8, 10, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--ui-accent);
  background: rgba(12, 12, 14, 0.92);
  box-shadow: 0 0 0 4px rgba(255, 113, 51, 0.09), inset 0 1px rgba(255, 255, 255, 0.035);
}

.dashboard-hero {
  gap: 18px;
}

.hero-main,
.hero-side,
.stat,
.panel,
.data-card,
.pro-chart,
.pro-card {
  border-color: var(--ui-border);
  background: linear-gradient(145deg, var(--ui-surface-raised), rgba(18, 18, 21, 0.94));
  box-shadow: var(--ui-shadow-sm), inset 0 1px rgba(255, 255, 255, 0.035);
}

.hero-main,
.hero-side,
.panel,
.pro-card,
.pro-chart {
  border-radius: var(--ui-radius-md);
}

.hero-main {
  padding: 28px;
  background:
    radial-gradient(circle at 88% 20%, rgba(255, 113, 51, 0.13), transparent 18rem),
    linear-gradient(145deg, rgba(30, 29, 32, 0.98), rgba(17, 17, 19, 0.96));
}

.hero-main h2 {
  max-width: 720px;
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: -0.04em;
}

.hero-main::after {
  color: rgba(255, 113, 51, 0.08);
  text-shadow: 0 0 50px rgba(255, 113, 51, 0.09);
}

.hero-side {
  padding: 26px;
}

.hero-status {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ui-border);
}

.hero-status:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.stats {
  gap: 16px;
}

.stat {
  min-height: 126px;
  border-radius: 16px;
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 2px;
  background: linear-gradient(transparent, rgba(255, 113, 51, 0.55), transparent);
  opacity: 0.55;
}

.stat strong {
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: -0.045em;
}

.panel {
  overflow: clip;
}

.panel-header {
  min-height: 70px;
  padding: 19px 20px;
  border-color: var(--ui-border);
  background: rgba(255, 255, 255, 0.012);
}

.panel-header h2 {
  letter-spacing: -0.02em;
}

.filters {
  border-color: var(--ui-border);
  background: rgba(9, 9, 11, 0.42);
}

.filters input,
.filters select {
  background: rgba(17, 17, 20, 0.88);
}

.table-wrap {
  background: rgba(8, 8, 10, 0.16);
}

table {
  font-variant-numeric: tabular-nums;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  border-color: var(--ui-border);
  background: rgba(20, 20, 23, 0.96);
  color: #a8a8b0;
  backdrop-filter: blur(12px);
}

td {
  border-color: rgba(255, 255, 255, 0.055);
}

tbody tr {
  transition: background 0.16s ease, box-shadow 0.16s ease;
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.012);
}

.actions button {
  min-height: 34px;
  border-radius: 9px;
}

.badge,
.charge-result,
.pro-audit-action {
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.045);
}

.cards {
  gap: 16px;
  padding: 18px;
}

.data-card {
  border-radius: 16px;
  transition: transform 0.22s var(--ui-ease), border-color 0.2s ease, box-shadow 0.2s ease;
}

.quick-actions {
  gap: 12px;
}

.quick-action {
  min-height: 84px;
  border-color: var(--ui-border);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(31, 31, 35, 0.9), rgba(22, 22, 25, 0.96));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

.mini-row {
  border-color: var(--ui-border);
  transition: background 0.18s ease;
}

.billing-tabs {
  border-color: var(--ui-border);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(26, 26, 30, 0.94), rgba(18, 18, 20, 0.94));
  box-shadow: var(--ui-shadow-sm), inset 0 1px rgba(255, 255, 255, 0.035);
}

.billing-tab-actions button.active {
  box-shadow: 0 10px 24px rgba(218, 60, 40, 0.2), inset 0 1px rgba(255, 255, 255, 0.12);
}

.gallery-admin-card {
  border-color: var(--ui-border);
  background: linear-gradient(145deg, rgba(26, 26, 29, 0.95), rgba(16, 16, 18, 0.98));
  box-shadow: var(--ui-shadow-sm);
  transition: transform 0.22s var(--ui-ease), border-color 0.2s ease, box-shadow 0.2s ease;
}

.gallery-admin-image img {
  transition: transform 0.55s var(--ui-ease), filter 0.3s ease;
}

.gallery-drop {
  border-color: rgba(229, 187, 112, 0.28);
  background: radial-gradient(circle at 50% 0%, rgba(229, 187, 112, 0.08), transparent 70%), #111113;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s var(--ui-ease);
}

dialog {
  border-color: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background: linear-gradient(145deg, #1b1b1f, #121214);
  box-shadow: 0 35px 100px rgba(0, 0, 0, 0.62), inset 0 1px rgba(255, 255, 255, 0.045);
}

dialog[open] {
  animation: ui-dialog-enter 0.28s var(--ui-ease) both;
}

dialog[open]::backdrop {
  animation: ui-backdrop-enter 0.25s ease both;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
}

dialog form > header,
dialog form > footer,
.charge-simulation-modal > header,
.charge-simulation-modal > footer {
  border-color: var(--ui-border);
  background: rgba(25, 25, 28, 0.93);
  backdrop-filter: blur(16px);
}

.toast {
  border-color: rgba(81, 211, 136, 0.34);
  border-radius: 14px;
  background: rgba(17, 50, 30, 0.96);
  box-shadow: var(--ui-shadow-lg);
  animation: ui-toast-enter 0.38s var(--ui-ease) both;
}

.empty {
  min-height: 110px;
  display: grid;
  place-items: center;
  padding: 32px;
}

.loading-card::after {
  content: "";
  width: 76px;
  height: 3px;
  margin-left: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--ui-accent), transparent);
  background-size: 200% 100%;
  animation: ui-loading 1.2s linear infinite;
}

.ui-enhanced .content.ui-view-enter > * {
  animation: ui-view-enter 0.42s var(--ui-ease) both;
}

.ui-enhanced .content.ui-view-enter > *:nth-child(2) {
  animation-delay: 0.045s;
}

.ui-enhanced .content.ui-view-enter > *:nth-child(3) {
  animation-delay: 0.08s;
}

.ui-enhanced .content.ui-view-enter > *:nth-child(4) {
  animation-delay: 0.11s;
}

.ui-enhanced .content.ui-view-enter .stat,
.ui-enhanced .content.ui-view-enter .data-card,
.ui-enhanced .content.ui-view-enter .gallery-admin-card {
  animation: ui-card-enter 0.48s var(--ui-ease) both;
}

.ui-enhanced .content.ui-view-enter .stat:nth-child(2),
.ui-enhanced .content.ui-view-enter .data-card:nth-child(2),
.ui-enhanced .content.ui-view-enter .gallery-admin-card:nth-child(2) {
  animation-delay: 0.04s;
}

.ui-enhanced .content.ui-view-enter .stat:nth-child(3),
.ui-enhanced .content.ui-view-enter .data-card:nth-child(3),
.ui-enhanced .content.ui-view-enter .gallery-admin-card:nth-child(3) {
  animation-delay: 0.075s;
}

.ui-enhanced .content.ui-view-enter .stat:nth-child(4),
.ui-enhanced .content.ui-view-enter .data-card:nth-child(4),
.ui-enhanced .content.ui-view-enter .gallery-admin-card:nth-child(4) {
  animation-delay: 0.105s;
}

@media (hover: hover) {
  button:not(:disabled):hover,
  .hero-actions a:hover,
  .qr-link:hover {
    transform: translateY(-2px);
    filter: brightness(1.06);
    box-shadow: 0 12px 28px rgba(218, 60, 40, 0.22), inset 0 1px rgba(255, 255, 255, 0.13);
  }

  button.secondary:hover,
  .refresh:hover,
  .hero-actions button:hover {
    border-color: rgba(255, 113, 51, 0.26);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22), inset 0 1px rgba(255, 255, 255, 0.06);
  }

  .sidebar nav button:hover {
    transform: translateX(3px);
  }

  .stat:hover,
  .data-card:hover,
  .gallery-admin-card:hover {
    transform: translateY(-3px);
    border-color: var(--ui-border-active);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28), inset 0 1px rgba(255, 255, 255, 0.045);
  }

  tbody tr:hover,
  .mini-row:hover {
    background: rgba(255, 113, 51, 0.045);
  }

  .gallery-admin-card:hover .gallery-admin-image img {
    transform: scale(1.035);
    filter: saturate(1.05) contrast(1.02);
  }

  .gallery-drop:hover {
    border-color: rgba(229, 187, 112, 0.52);
    transform: translateY(-2px);
  }
}

@keyframes ui-login-enter {
  from { opacity: 0; transform: translateY(20px) scale(0.975); }
  to { opacity: 1; transform: none; }
}

@keyframes ui-view-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes ui-card-enter {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

@keyframes ui-dialog-enter {
  from { opacity: 0; transform: translateY(14px) scale(0.975); }
  to { opacity: 1; transform: none; }
}

@keyframes ui-backdrop-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ui-toast-enter {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes ui-ripple {
  to { opacity: 0; transform: scale(2.1); }
}

@keyframes ui-online-pulse {
  0%, 55%, 100% { box-shadow: 0 0 0 4px rgba(43, 199, 111, 0.13); }
  72% { box-shadow: 0 0 0 9px rgba(43, 199, 111, 0); }
}

@keyframes ui-loading {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@media (max-width: 1050px) {
  .content {
    padding: 24px;
  }
}

@media (max-width: 760px) {
  .app-view {
    display: block;
  }

  .sidebar {
    width: min(86vw, 306px);
    box-shadow: 22px 0 70px rgba(0, 0, 0, 0.48);
    transition: transform 0.3s var(--ui-ease);
  }

  .topbar {
    min-height: 82px;
    padding: 14px 16px;
    gap: 12px;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .content {
    padding: 16px;
  }

  .hero-main,
  .hero-side {
    padding: 20px;
  }

  .hero-main h2 {
    font-size: 27px;
  }

  .panel-header {
    padding: 17px;
  }

  .panel-header .header-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .panel-header .header-actions button,
  .filter-actions button {
    width: 100%;
  }

  th,
  td {
    padding: 12px 14px;
  }

  dialog {
    width: calc(100% - 18px);
    max-height: calc(100dvh - 18px);
    border-radius: 17px;
  }

  .toast {
    bottom: max(14px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  .topbar-actions .refresh,
  .topbar-actions .qr-link {
    min-width: 0;
  }

  .hero-actions {
    display: grid;
  }

  .hero-actions button,
  .hero-actions a {
    width: 100%;
  }

  .stats {
    gap: 11px;
  }

  .stat {
    min-height: 108px;
    padding: 18px;
  }

  .quick-actions {
    padding: 14px;
  }

  .billing-tab-actions {
    gap: 6px;
  }
}

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

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

  .ui-ripple {
    display: none !important;
  }
}
