/* ============================================================
   TG Manager — Design tokens
   Palette: near-black void, maroon signal accent, warm greys
   Type: Fraunces (display) / Inter (body) / JetBrains Mono (data)
   ============================================================ */

:root {
  --void: #0a0908;
  --panel: #15100f;
  --panel-2: #1c1615;
  --panel-hover: #221a19;
  --line: #2e2422;
  --line-soft: #221c1a;

  --maroon-deep: #4a121c;
  --maroon: #7d2130;
  --maroon-bright: #b8324a;
  --maroon-glow: rgba(184, 50, 74, 0.35);

  --text: #efe7e2;
  --text-dim: #9c9290;
  --text-faint: #675e5b;

  --danger: #c73f4c;
  --success: #7fae7a;
  --warn: #c9a24a;
  --info: #8a9bb0;

  --radius: 10px;
  --radius-sm: 6px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, rgba(125, 33, 48, 0.16), transparent 45%),
    radial-gradient(circle at 100% 0%, rgba(125, 33, 48, 0.08), transparent 40%),
    var(--void);
  color: var(--text);
  font-family: 'Inter', -apple-system, Segoe UI, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--maroon); color: #fff; }

h1, h2, h3, .display {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0;
}

.mono {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
}

a { color: inherit; text-decoration: none; }

/* ---------- layout shell ---------- */

.shell { max-width: 1080px; margin: 0 auto; padding: 0 24px 80px; }

.topbar {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(21,16,15,0.92), rgba(21,16,15,0.75));
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.brand-mark {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--maroon-bright);
  box-shadow: 0 0 0 3px var(--maroon-glow);
  animation: breathe 2.6s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 3px var(--maroon-glow); }
  50% { box-shadow: 0 0 0 6px rgba(184, 50, 74, 0.12); }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.88rem;
}

.nav-links .who {
  color: var(--text-faint);
  font-size: 0.8rem;
  margin-right: 10px;
  padding-right: 14px;
  border-right: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.nav-links a {
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: color .2s var(--ease), background .2s var(--ease);
}

.nav-links a:hover { color: var(--text); background: var(--panel-2); }
.nav-links a.danger:hover { color: var(--danger); }

/* ---------- signature: signal divider ---------- */

.signal {
  height: 2px;
  margin: 14px 0 28px;
  background: linear-gradient(90deg, transparent, var(--maroon-bright) 25%, var(--maroon-deep) 45%, transparent 60%);
  background-size: 220% 100%;
  animation: sweep 4.5s linear infinite;
  border-radius: 2px;
  opacity: 0.85;
}

@keyframes sweep {
  from { background-position: 220% 0; }
  to { background-position: -20% 0; }
}

.page-head { padding-top: 36px; }
.page-head .eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--maroon-bright);
  font-weight: 600;
}
.page-head h1 { font-size: 1.9rem; margin-top: 6px; }
.page-head p.sub { color: var(--text-dim); margin-top: 8px; font-size: 0.95rem; }

/* ---------- flash messages ---------- */

.flashes { margin-top: 20px; display: flex; flex-direction: column; gap: 8px; }

.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  animation: slidein .35s var(--ease);
}

.flash.success { border-color: rgba(127,174,122,0.4); color: var(--success); }
.flash.danger  { border-color: rgba(199,63,76,0.45); color: var(--danger); }
.flash.info    { border-color: rgba(138,155,176,0.4); color: var(--info); }
.flash.warning { border-color: rgba(201,162,74,0.4); color: var(--warn); }

.flash button {
  background: none; border: none; color: inherit; opacity: 0.6; cursor: pointer; font-size: 1rem; line-height: 1;
}
.flash button:hover { opacity: 1; }

@keyframes slidein {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- cards / reveal ---------- */

.reveal { opacity: 0; transform: translateY(14px); transition: opacity .55s var(--ease), transform .55s var(--ease); }
.reveal.is-visible { opacity: 1; transform: translateY(0); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; margin-top: 24px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  transition: transform .25s var(--ease), border-color .25s var(--ease), box-shadow .25s var(--ease);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--maroon-bright), transparent);
  opacity: 0; transition: opacity .25s var(--ease);
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--maroon);
  box-shadow: 0 12px 30px -14px var(--maroon-glow);
}
.card:hover::before { opacity: 1; }

.card h3 { font-size: 1.15rem; margin-bottom: 10px; }

.card .phone { font-family: 'JetBrains Mono', monospace; color: var(--text); font-size: 1.05rem; letter-spacing: 0.02em; }

.card .meta { color: var(--text-dim); font-size: 0.85rem; margin: 6px 0; }
.card .meta strong { color: var(--text-faint); font-weight: 500; }

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

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s var(--ease), box-shadow .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease);
  font-family: inherit;
}

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

.btn-primary {
  background: linear-gradient(160deg, var(--maroon-bright), var(--maroon-deep));
  color: #fff;
  box-shadow: 0 6px 20px -8px var(--maroon-glow);
}
.btn-primary:hover { box-shadow: 0 8px 26px -8px var(--maroon-glow); filter: brightness(1.08); }

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
}
.btn-ghost:hover { border-color: var(--maroon); color: var(--text); background: var(--panel-2); }

.btn-danger-ghost {
  background: transparent;
  border-color: rgba(199,63,76,0.35);
  color: var(--danger);
}
.btn-danger-ghost:hover { background: rgba(199,63,76,0.1); border-color: var(--danger); }

.btn-sm { padding: 7px 13px; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- forms ---------- */

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 8px;
  font-weight: 600;
}

.field input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

.field input:focus {
  outline: none;
  border-color: var(--maroon-bright);
  box-shadow: 0 0 0 3px var(--maroon-glow);
}

.field .hint { color: var(--text-faint); font-size: 0.78rem; margin-top: 6px; }

.auth-wrap {
  min-height: calc(100vh - 90px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,0.6);
  animation: rise .5s var(--ease);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-card .eyebrow {
  text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.7rem; color: var(--maroon-bright); font-weight: 700;
}
.auth-card h1 { font-size: 1.6rem; margin: 8px 0 22px; }

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

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-top: 16px; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

thead th {
  text-align: left;
  padding: 12px 16px;
  background: var(--panel-2);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text-dim);
}

tbody tr { transition: background .2s var(--ease); }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pill-owner { background: rgba(184,50,74,0.16); color: var(--maroon-bright); border: 1px solid rgba(184,50,74,0.3); }
.pill-user { background: rgba(138,155,176,0.12); color: var(--info); border: 1px solid rgba(138,155,176,0.25); }

/* ---------- empty state ---------- */

.empty {
  margin-top: 40px;
  padding: 60px 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text-faint);
}
.empty .glyph {
  width: 44px; height: 44px; margin: 0 auto 16px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  color: var(--maroon-bright);
  font-size: 1.2rem;
}

/* ---------- otp list ---------- */

.otp-list { list-style: none; margin: 16px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.otp-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.otp-code { font-family: 'JetBrains Mono', monospace; font-size: 1.15rem; letter-spacing: 0.12em; color: var(--maroon-bright); }
.otp-time { color: var(--text-faint); font-size: 0.78rem; }

/* ---------- section spacing ---------- */

.section { margin-top: 44px; }
.section-title { font-size: 1.1rem; display: flex; align-items: center; gap: 10px; }

/* ---------- misc ---------- */

.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 200px; margin-bottom: 0; }

@media (max-width: 640px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; gap: 10px; }
  .nav-links { flex-wrap: wrap; }
}

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