:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e5e7eb;
  --line-2: #eef2f7;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eff6ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.05);
  --radius: 16px;

  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

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

h1 {
  margin-bottom: 4px;
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: -0.035em;
  font-weight: 800;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.3;
  letter-spacing: -0.015em;
  font-weight: 750;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.hidden {
  display: none !important;
}

.shell {
  width: min(1220px, calc(100% - 40px));
  margin: 0 auto;
  padding: 32px 0;
}

/* AUTH */

.auth-card {
  width: min(440px, 100%);
  margin: 8vh auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--text);
  color: #ffffff;
  font-weight: 850;
  letter-spacing: -0.04em;
}

.brand p {
  margin-bottom: 0;
  font-size: 0.94rem;
}

/* TABS */

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 20px;
}

.tab {
  border: 0;
  color: var(--muted);
  background: transparent;
  padding: 10px 12px;
  border-radius: 9px;
  font-weight: 700;
}

.tab.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

/* FORMS */

.form,
.row-form {
  display: grid;
  gap: 14px;
}

.row-form {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
}

.compact-form {
  grid-template-columns: minmax(220px, 340px) auto;
  justify-content: start;
}

label {
  display: grid;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 650;
  gap: 7px;
}

input,
select {
  width: 100%;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  outline: none;
}

input::placeholder {
  color: var(--muted-2);
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 13px) calc(50% - 3px);
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

/* BUTTONS */

.primary,
.ghost,
.small-btn {
  border-radius: 11px;
  font-weight: 750;
  border: 1px solid transparent;
  white-space: nowrap;
}

.primary {
  padding: 11px 16px;
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.ghost {
  padding: 10px 14px;
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

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

.small-btn {
  padding: 7px 10px;
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
  font-size: 0.84rem;
}

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

.small-btn.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #fecaca;
}

.ok-btn {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: #bbf7d0;
}

/* MESSAGES */

.msg {
  margin: 14px 0 0;
  min-height: 22px;
  color: var(--muted);
  font-size: 0.92rem;
}

.msg.error {
  color: var(--danger);
}

.msg.ok {
  color: var(--ok);
}

/* APP HEADER */

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.topbar p {
  margin-bottom: 0;
  font-size: 0.94rem;
}

/* CARDS */

.grid {
  display: grid;
  gap: 18px;
}

.cards {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 18px;
  align-items: stretch;
}

.card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card {
  min-width: 0;
  min-height: 120px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card span {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
  font-size: 0.88rem;
  font-weight: 650;
}

.card strong {
  display: block;
  color: var(--text);
  font-size: 1.75rem;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.pending-card {
  border-color: #fed7aa;
  background: linear-gradient(180deg, #ffffff 0%, #fffbeb 100%);
}

.card-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid #fed7aa;
  border-top-color: var(--warning);
  border-radius: 999px;
  animation: spin 0.9s linear infinite;
}

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

/* PANELS */

.panel {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  padding: 18px;
  margin-top: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.panel-head p {
  margin-bottom: 0;
  font-size: 0.9rem;
}

/* TABLES */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  padding: 13px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
  white-space: normal;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
  font-weight: 800;
}

td {
  color: var(--text);
  font-size: 0.92rem;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #fafafa;
}

/* UTILS */

.code {
  max-width: 360px;
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    Monaco,
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 0.82rem;
  color: #1d4ed8;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--ok-soft);
  color: var(--ok);
  border: 1px solid #bbf7d0;
  font-size: 0.78rem;
  font-weight: 800;
}

.status-pending {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: #fde68a;
}

.status-approved,
.status-paid {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #bbf7d0;
}

.status-rejected,
.status-duplicate {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecaca;
}

.invite-result,
.withdraw-action {
  margin: 14px 0;
  padding: 13px;
  border-radius: 13px;
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
}

.invite-result strong {
  display: block;
  margin-bottom: 8px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* RESPONSIVE */

@media (max-width: 900px) {
  .shell {
    width: min(100% - 24px, 1180px);
    padding: 22px 0;
  }

  .row-form,
  .compact-form {
    grid-template-columns: 1fr;
  }

  .panel-head,
  .topbar {
    flex-direction: column;
  }

  .topbar {
    align-items: stretch;
  }

  .ghost {
    width: fit-content;
  }
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1220px);
    padding: 18px 0;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .card {
    min-height: auto;
  }

  .row-form .primary,
  .ghost {
    width: 100%;
  }

  .panel {
    padding: 14px;
  }

  .table-wrap {
    border-radius: 12px;
  }

  table {
    min-width: 900px;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 14px;
  }

  .auth-card {
    margin: 5vh auto;
    padding: 20px;
    border-radius: 18px;
  }

  .brand {
    gap: 12px;
  }

  .logo {
    width: 46px;
    height: 46px;
    border-radius: 12px;
  }

  .card,
  .panel {
    border-radius: 14px;
  }

  th,
  td {
    padding: 11px 10px;
  }
}