/* The seller dashboard.
 *
 * Colours come from Telegram's theme, so light and dark both work; the fallbacks are the light
 * palette, for a plain browser. Only neutral theme colours are used (background, text, hint,
 * secondary background, separator), never the theme's accent or button colour, so no theme can
 * bring a warm hue in. "Needs you" stands out by contrast, ink on paper, not by colour.
 * The page's security policy refuses inline styles: everything visual is a class in this file.
 */
:root {
  --paper: var(--tg-theme-bg-color, #ffffff);
  --ink: var(--tg-theme-text-color, #0f172a);
  --muted: var(--tg-theme-hint-color, #64748b);
  --surface: var(--tg-theme-secondary-bg-color, #f1f5f9);
  --line: var(--tg-theme-section-separator-color, #e2e8f0);
  --paid-ink: #166534;
  --paid-paper: #dcfce7;
  --radius: 12px;
}

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

html,
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button {
  -webkit-appearance: none;
  appearance: none;
  font: inherit;
  color: inherit;
}

a,
button {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
}

p {
  margin: 0;
}

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

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

.small {
  font-size: 13px;
}

/* Header: title, and the round buttons for Back and Refresh. */
.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.bar-title {
  flex: 1;
  min-width: 0;
}

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:active {
  background: var(--surface);
}

/* The three counters. */
.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-needs {
  border-color: var(--ink);
  background: var(--surface);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-money {
  display: flex;
  flex-direction: column;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.stat-money small {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

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

/* Segmented control: Payments | Bookings. */
.tabs {
  display: flex;
  margin: 16px 0 12px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface);
}

.tab {
  flex: 1;
  padding: 7px 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.tab-on {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

/* Lists of orders and bookings. */
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: inherit;
  text-decoration: none;
}

a.row:active {
  background: var(--surface);
}

.row-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row-main > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
  white-space: nowrap;
}

/* Badges. Needs you: solid ink. Awaiting: grey. Paid: green. Cancelled: grey outline. */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-ink {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.badge-grey {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.badge-green {
  background: var(--paid-paper);
  border-color: var(--paid-paper);
  color: var(--paid-ink);
}

.badge-outline {
  background: transparent;
  border-color: var(--muted);
  color: var(--muted);
}

/* The order screen. */
.card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.amount {
  margin-bottom: 8px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.kv {
  margin: 14px 0 0;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.kv-row:last-child {
  border-bottom: 0;
}

.kv dt {
  flex: none;
  color: var(--muted);
}

.kv dd {
  margin: 0;
  min-width: 0;
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.words {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.words-text {
  margin-top: 4px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.decide {
  margin-top: 16px;
}

.notice {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--ink);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
}

.decide .notice {
  margin: 0 0 8px;
}

.hint {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* Buttons. */
.btn {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}

.btn-solid {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}

.btn-outline {
  background: transparent;
  border-color: var(--muted);
  color: var(--ink);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Loading, error, empty and signed-out states. */
.state {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}

.state .btn {
  max-width: 280px;
  margin: 16px auto 0;
}

.spinner {
  width: 24px;
  height: 24px;
  margin: 0 auto 12px;
  border: 3px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
}
