:root {
  --bg: #f5f8ff;
  --surface: #ffffff;
  --surface-2: #f0f6ff;
  --surface-3: #e2efff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #dbe7f5;
  --accent: #2563eb;
  --accent-2: #0ea5e9;
  --danger: #dc2626;
  --warning: #b45309;
  --ok: #15803d;
  --shadow: 0 12px 28px rgba(37, 99, 235, 0.09);
  color-scheme: light;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(92px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 12px;
  background: rgba(245, 248, 255, 0.9);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 3px;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 12px;
  font-size: 19px;
}

h3 {
  margin-bottom: 6px;
  font-size: 16px;
}

.screen {
  display: grid;
  gap: 14px;
  animation: fade-in 160ms ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

.hero {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-map {
  position: relative;
  overflow: hidden;
  height: 116px;
  background:
    linear-gradient(90deg, rgba(37, 99, 235, 0.07) 1px, transparent 1px),
    linear-gradient(rgba(37, 99, 235, 0.07) 1px, transparent 1px),
    linear-gradient(135deg, #ffffff, #eaf3ff);
  background-size:
    28px 28px,
    28px 28px,
    auto;
}

.hero-map::before,
.hero-map::after {
  position: absolute;
  top: 34px;
  left: -16%;
  width: 132%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(37, 99, 235, 0.6), transparent);
  content: "";
  transform: rotate(-8deg);
  animation: line-drift-a 1.87s ease-in-out infinite alternate;
}

.hero-map::after {
  top: 82px;
  left: -12%;
  width: 126%;
  background: linear-gradient(90deg, transparent, rgba(14, 165, 233, 0.6), transparent);
  transform: rotate(15deg);
  animation: line-drift-b 2.13s ease-in-out infinite alternate;
}

@keyframes line-drift-a {
  from {
    transform: translateX(-26px) translateY(2px) rotate(-8deg);
  }

  to {
    transform: translateX(28px) translateY(-8px) rotate(-8deg);
  }
}

@keyframes line-drift-b {
  from {
    transform: translateX(28px) translateY(-5px) rotate(15deg);
  }

  to {
    transform: translateX(-30px) translateY(7px) rotate(15deg);
  }
}

.hero-body {
  padding: 16px;
}

.hero-body p {
  margin-bottom: 14px;
  color: var(--muted);
  line-height: 1.45;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat,
.panel,
.item,
.ticket,
.order,
.config-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.panel h2,
.item h3,
.ticket h3,
.order h3 {
  color: #0f172a;
}

.stat {
  min-width: 0;
  padding: 10px;
}

.stat strong {
  display: block;
  font-size: 18px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.panel {
  padding: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quick-button,
.primary-button,
.secondary-button,
.ghost-button,
.chip,
.segmented button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.quick-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.chip:hover {
  border-color: #93c5fd;
  background: #eaf3ff;
}

.quick-button {
  display: grid;
  gap: 8px;
  justify-items: start;
  padding: 12px;
  text-align: left;
}

.quick-button:active,
.primary-button:active,
.secondary-button:active,
.ghost-button:active,
.chip:active {
  transform: scale(0.98);
}

.quick-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #e0edff;
  color: #2563eb;
}

.primary-button {
  width: 100%;
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.primary-button:hover {
  border-color: #1d4ed8;
  background: #1d4ed8;
}

.primary-button:disabled,
.secondary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  width: 100%;
  border-color: #bfdbfe;
  background: var(--surface-2);
  color: #1d4ed8;
  font-weight: 700;
}

.ghost-button {
  background: transparent;
  color: #2563eb;
}

.item,
.ticket,
.order {
  display: grid;
  gap: 10px;
  padding: 13px;
}

.item.selected {
  border-color: #93c5fd;
  background: linear-gradient(180deg, #ffffff, #f3f8ff);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.09);
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.ok {
  background: #dcfce7;
  color: var(--ok);
}

.badge.warn {
  background: #fef3c7;
  color: var(--warning);
}

.badge.danger {
  background: #fee2e2;
  color: var(--danger);
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #edf5ff;
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.segmented button.active {
  background: var(--surface);
  color: #1d4ed8;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.1);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 38px;
  padding: 8px 11px;
  color: var(--muted);
}

.chip.active {
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
}

.config-box {
  position: relative;
  padding: 12px;
  background: #f8fbff;
  color: #1e3a8a;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.form {
  display: grid;
  gap: 10px;
}

.messages {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.message {
  display: grid;
  gap: 6px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.message.user {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.message.support {
  border-color: #bae6fd;
  background: #f0f9ff;
}

.message p {
  margin-bottom: 0;
  line-height: 1.4;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  padding: 11px;
}

.field input:focus,
.field textarea:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.18);
}

.field textarea {
  min-height: 104px;
  resize: vertical;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.nav-item {
  display: grid;
  min-width: 0;
  min-height: 52px;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}

.nav-item.active {
  background: #dbeafe;
  color: var(--accent);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    transform 120ms ease;
}

.icon-button:hover {
  border-color: #93c5fd;
  background: var(--surface-2);
}

.icon-button:active {
  transform: scale(0.96);
}

.settings-button {
  color: var(--accent);
}

span[class^="icon-"],
span[class*=" icon-"] {
  display: inline-block;
  width: 19px;
  height: 19px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.icon-home { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 10.5 12 3l9 7.5V21h-6v-6H9v6H3z'/%3E%3C/svg%3E"); }
.icon-lock { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M17 9V7A5 5 0 0 0 7 7v2H5v12h14V9zm-8 0V7a3 3 0 1 1 6 0v2z'/%3E%3C/svg%3E"); }
.icon-card { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5h18v14H3zm2 4h14V7H5zm0 4v4h6v-4z'/%3E%3C/svg%3E"); }
.icon-list { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 5h16v3H4zm0 5h16v3H4zm0 5h16v3H4z'/%3E%3C/svg%3E"); }
.icon-help { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18h2v-2h-2zm1-16a10 10 0 1 0 0 20 10 10 0 0 0 0-20m0 4a3.2 3.2 0 0 1 3.4 3.1c0 1.2-.7 2-1.8 2.7-.8.5-1 .9-1 1.7v.5h-2v-.7c0-1.3.5-2.1 1.6-2.8.9-.6 1.2-.9 1.2-1.5 0-.7-.6-1.2-1.5-1.2s-1.5.5-1.7 1.4l-1.9-.5C8.7 7.1 10.1 6 12 6'/%3E%3C/svg%3E"); }
.icon-gear { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M19.4 13.5c.1-.5.1-1 .1-1.5s0-1-.1-1.5l2-1.5-2-3.5-2.4 1a8 8 0 0 0-2.6-1.5L14 2h-4l-.4 3a8 8 0 0 0-2.6 1.5l-2.4-1-2 3.5 2 1.5a8.6 8.6 0 0 0 0 3l-2 1.5 2 3.5 2.4-1a8 8 0 0 0 2.6 1.5l.4 3h4l.4-3a8 8 0 0 0 2.6-1.5l2.4 1 2-3.5zM12 15.5A3.5 3.5 0 1 1 12 8a3.5 3.5 0 0 1 0 7.5'/%3E%3C/svg%3E"); }
.icon-users { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M9 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8m0 2c-3.3 0-6 2-6 4.5V20h12v-2.5C15 15 12.3 13 9 13m7.5-2a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7m0 2c-.7 0-1.4.1-2 .3 1.5 1 2.5 2.4 2.5 4.2V20h4v-2.5c0-2.5-2-4.5-4.5-4.5'/%3E%3C/svg%3E"); }
.icon-book { --icon: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 4.5A2.5 2.5 0 0 1 7.5 2H20v17H7.5A2.5 2.5 0 0 0 5 21.5zM7.5 4A.5.5 0 0 0 7 4.5v12.6c.2-.1.3-.1.5-.1H18V4zM8 7h8v2H8zm0 4h7v2H8z'/%3E%3C/svg%3E"); }

.toast {
  position: fixed;
  right: 16px;
  bottom: 92px;
  left: 16px;
  z-index: 20;
  max-width: 488px;
  margin: 0 auto;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 380px) {
  .app-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .grid-2,
  .stats {
    grid-template-columns: 1fr;
  }

  .nav-item {
    font-size: 10px;
  }
}

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