/* ============================================================
   Design system: "The Ledger"
   Grounded in the actual subject of this tool - operators reselling
   goods priced by weight + a wage/making-charge percentage, dispatched
   to Telegram/Bale channels. The visual language borrows from a
   merchant's weighing ledger: ink-dark pages, brass rules, a wax-seal
   stamp for status, and monospaced figures for anything measured.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  /* Color */
  --ink: #16130f;
  --ink-2: #1e1912;
  --ink-3: #261f16;
  --parchment: #f1e7d2;
  --parchment-dim: #b7a888;
  --parchment-faint: #7d735c;
  --brass: #c69a46;
  --brass-bright: #e3bc71;
  --oxblood: #8c3b32;
  --oxblood-bright: #b54d40;
  --moss: #55765a;
  --moss-bright: #6e9873;
  --hairline: rgba(198, 154, 70, 0.22);
  --hairline-strong: rgba(198, 154, 70, 0.4);

  /* Type */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --radius: 3px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

body {
  background-image:
    linear-gradient(var(--ink) 0%, var(--ink) 100%),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 27px,
      rgba(198, 154, 70, 0.035) 28px
    );
}

a { color: var(--brass-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--parchment);
  margin: 0 0 0.4em;
  letter-spacing: 0.01em;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brass); font-family: var(--font-body); font-weight: 600; }

.mono { font-family: var(--font-mono); }

/* ---------- Shell / nav ---------- */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--hairline);
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 1.3rem;
  color: var(--parchment);
}

.brand .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1.5px solid var(--brass);
  border-radius: 50%;
  color: var(--brass-bright);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.brand small {
  font-family: var(--font-body);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--parchment-faint);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--parchment-dim);
}

.topbar-right form { margin: 0; }

.main {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ---------- Flash messages ---------- */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.9rem;
  border: 1px solid;
}

.alert-success {
  background: rgba(85, 118, 90, 0.14);
  border-color: rgba(110, 152, 115, 0.4);
  color: var(--moss-bright);
}

.alert-error {
  background: rgba(140, 59, 50, 0.14);
  border-color: rgba(181, 77, 64, 0.45);
  color: var(--oxblood-bright);
}

/* ---------- Cards / panels ---------- */

.card {
  background: var(--ink-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--hairline);
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brass);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body { padding: 18px; }

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

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .main { padding: 20px 16px 48px; }
  .topbar { padding: 14px 16px; }
}

/* ---------- Forms ---------- */

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--parchment-dim);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}

.field .hint {
  font-size: 0.76rem;
  color: var(--parchment-faint);
  margin-top: 4px;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--hairline-strong);
  color: var(--parchment);
  padding: 9px 11px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

input::placeholder { color: var(--parchment-faint); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brass-bright);
  box-shadow: 0 0 0 3px rgba(227, 188, 113, 0.18);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--hairline-strong);
  background: transparent;
  color: var(--parchment);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.btn:hover { border-color: var(--brass-bright); background: rgba(198, 154, 70, 0.08); }

.btn:focus-visible {
  outline: 2px solid var(--brass-bright);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--ink);
  font-weight: 600;
}
.btn-primary:hover { background: var(--brass-bright); border-color: var(--brass-bright); }

.btn-danger {
  border-color: rgba(181, 77, 64, 0.5);
  color: var(--oxblood-bright);
}
.btn-danger:hover { background: rgba(140, 59, 50, 0.14); border-color: var(--oxblood-bright); }

.btn-sm { padding: 5px 11px; font-size: 0.78rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Ledger table ---------- */

table.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

table.ledger th {
  text-align: left;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--parchment-faint);
  font-weight: 600;
  padding: 10px 14px;
  border-bottom: 1.5px solid var(--brass);
}

table.ledger td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--hairline);
  color: var(--parchment);
}

table.ledger tr:last-child td { border-bottom: none; }
table.ledger tr:hover td { background: rgba(198, 154, 70, 0.04); }

.figure { font-family: var(--font-mono); }

.total-line {
  border-top: 1.5px double var(--brass);
  padding-top: 6px;
  margin-top: 6px;
}

/* ---------- List rows (users / channels) ---------- */

.row-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--hairline);
}

.row-list li:last-child { border-bottom: none; }

.row-list .empty {
  color: var(--parchment-faint);
  font-style: italic;
  font-size: 0.85rem;
}

/* ---------- Stamp / status badge (signature element) ---------- */

.stamp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.stamp-active { color: var(--brass-bright); }
.stamp-sold { color: var(--moss-bright); }
.stamp-deleted { color: var(--oxblood-bright); text-decoration: line-through; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid;
}

.badge-telegram { color: #7fb8e0; border-color: rgba(127, 184, 224, 0.45); }
.badge-bale { color: var(--brass-bright); border-color: rgba(227, 188, 113, 0.45); }

/* ---------- Login page ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--ink-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 32px 28px;
}

.auth-mark {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--brass);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brass-bright);
  font-family: var(--font-mono);
  margin: 0 auto 18px;
  font-size: 1.1rem;
}

.auth-card h1 {
  text-align: center;
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.auth-subtitle {
  text-align: center;
  color: var(--parchment-faint);
  font-size: 0.82rem;
  margin-bottom: 24px;
}

/* ---------- Misc ---------- */

.text-dim { color: var(--parchment-dim); }
.text-faint { color: var(--parchment-faint); font-size: 0.82rem; }
.mt-0 { margin-top: 0; }
.spacer { flex: 1; }
