:root {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #191c22;
  --surface-2: #22262e;
  --border: #2b2f38;
  --text: #f4f5f7;
  --text-dim: #a6acb8;
  --accent: #f5b301;
  --accent-text: #1a1300;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 16px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  justify-content: center;
}

.page {
  width: 100%;
  max-width: 560px;
  padding: 32px 20px 48px;
}

.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  margin-bottom: 28px;
}

.avatar {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), #d38f00);
  color: var(--accent-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 800;
  margin-bottom: 10px;
  box-shadow: 0 6px 24px rgba(245, 179, 1, 0.25);
}

.profile h1 {
  font-size: 22px;
  margin: 4px 0 0;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.profile p {
  margin: 0;
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.5;
  max-width: 420px;
}

.links {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.link-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-height: 56px;
  text-decoration: none;
  color: var(--text);
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.link-card:active {
  transform: scale(0.98);
}

@media (hover: hover) {
  .link-card:hover {
    background: var(--surface-2);
    border-color: #3a3f4a;
  }
}

.icon-badge {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.icon-badge svg {
  width: 22px;
  height: 22px;
}

.link-name {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  flex: none;
  color: var(--text-dim);
  width: 20px;
  height: 20px;
}

.salesmen-section {
  margin-top: 32px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 12px;
  text-align: center;
}

.salesmen {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.salesman-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: 56px;
}

.salesman-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.salesman-name {
  font-size: 15.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.salesman-phone {
  font-size: 13px;
  color: var(--text-dim);
}

.call-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--success);
  color: #06210f;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  text-decoration: none;
  min-height: 44px;
  transition: filter 150ms ease, transform 150ms ease;
}

.call-btn:active {
  transform: scale(0.97);
}

@media (hover: hover) {
  .call-btn:hover {
    filter: brightness(1.08);
  }
}

.empty,
.error-state {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 12px;
  font-size: 15px;
}

footer.site-footer {
  text-align: center;
  margin-top: 36px;
  color: var(--text-dim);
  font-size: 12.5px;
}

footer.site-footer a {
  color: var(--text-dim);
  text-decoration: none;
}

footer.site-footer a:hover {
  color: var(--text);
}

/* Admin */
.admin-page {
  max-width: 640px;
}

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 12px;
}

.admin-header h1 {
  font-size: 20px;
  margin: 0;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 150ms ease, border-color 150ms ease, opacity 150ms ease;
}

.btn:hover {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-icon {
  padding: 8px;
  min-width: 44px;
}

.login-card,
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin: 0 auto;
}

.login-card {
  max-width: 340px;
  margin-top: 20vh;
  text-align: center;
}

.login-card h1 {
  font-size: 18px;
  margin-top: 0;
}

.field {
  margin-bottom: 16px;
  text-align: left;
}

.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-dim);
}

.field input,
.field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
  min-height: 44px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.field .hint {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 6px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.checkbox-row input {
  width: 20px;
  height: 20px;
}

.error-banner {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  text-align: left;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  z-index: 50;
  max-width: 90vw;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
}

.admin-row.hidden-row {
  opacity: 0.55;
}

.admin-row .info {
  flex: 1;
  min-width: 0;
}

.admin-row .name {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row .url {
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row .actions {
  display: flex;
  gap: 6px;
  flex: none;
}

.order-btns {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-btns button {
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 12px;
  line-height: 1;
}

.order-btns button:hover {
  color: var(--text);
}

.badge-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 40;
}

@media (min-width: 560px) {
  .modal-backdrop {
    align-items: center;
  }
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
}

@media (min-width: 560px) {
  .modal {
    border-radius: 18px;
  }
}

.modal h2 {
  margin-top: 0;
  font-size: 17px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.analytics-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.stat-tile {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.analytics-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.analytics-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(80px, 2fr) 64px;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}

.analytics-label {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.analytics-name {
  font-size: 14.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-tag {
  font-size: 11.5px;
  color: var(--text-dim);
}

.analytics-bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.analytics-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.analytics-counts {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.analytics-total {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.analytics-7d {
  font-size: 11px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 460px) {
  .analytics-row {
    grid-template-columns: minmax(0, 1fr) 56px;
    grid-template-areas: "label counts" "bar bar";
    row-gap: 8px;
  }
  .analytics-label {
    grid-area: label;
  }
  .analytics-counts {
    grid-area: counts;
  }
  .analytics-bar-track {
    grid-area: bar;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
