/* FREAK SHOP Admin — minimal white + light blue (owner-approved demo look) */
:root {
  --blue: #3b9beb;
  --blue-dark: #2b83d6;
  --blue-soft: #e8f3fd;
  --ink: #1f2a37;
  --gray: #6b7a8d;
  --border: #e3edf5;
  --bg: #f7fafc;
  --card: #ffffff;
  --green: #2e9e62;
  --red: #d64545;
  --amber: #b7791f;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px;
}
.hidden { display: none !important; }
.muted { color: var(--gray); }
.small { font-size: 12.5px; }
button { font-family: inherit; cursor: pointer; }
h1 { font-size: 24px; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }

/* ---------- Login ---------- */
.login-screen { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; background: #fff; }
.login-card { max-width: 380px; width: 100%; text-align: center; border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 24px; background: var(--card); }
.login-card .brand { justify-content: center; margin-bottom: 14px; }
.login-card p { margin-bottom: 16px; line-height: 1.5; }
#tg-login-widget { display: flex; justify-content: center; margin: 10px 0 16px; min-height: 40px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100dvh; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 20px; letter-spacing: .4px; }
.brand-bolt { color: var(--blue); font-size: 24px; }
.sidebar {
  width: 230px; flex: 0 0 230px; background: #fff; border-right: 1px solid var(--border);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 18px;
  position: sticky; top: 0; height: 100dvh;
}
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; border-left: 3px solid transparent;
  padding: 11px 12px; border-radius: 8px; font-size: 15px; color: var(--ink);
}
.nav-btn:hover { background: var(--blue-soft); }
.nav-btn.active { background: var(--blue-soft); border-left-color: var(--blue); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.badge {
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 10px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center; margin-left: auto;
}
.main { flex: 1; min-width: 0; padding: 22px 26px 90px; max-width: 1180px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px #e2f4ea; }
.live-dot.off { background: #c4cedb; box-shadow: none; }
.admin-chip { background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; padding: 6px 12px; border-radius: 16px; font-size: 13px; }
.icon-btn { background: none; border: 1px solid var(--border); border-radius: 8px; width: 34px; height: 34px; font-size: 16px; background: #fff; }
.ticker {
  background: var(--blue); color: #fff; border-radius: 10px; padding: 10px 14px;
  margin-bottom: 16px; font-size: 14px; font-weight: 600;
  animation: ticker-in .3s ease;
}
@keyframes ticker-in { from { opacity: 0; transform: translateY(-4px);} to { opacity: 1; } }

/* ---------- Cards / stats ---------- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 14px; box-shadow: 0 1px 2px rgba(31,42,55,.03);
}
.cards .card { margin-bottom: 0; }
.stat-label { color: var(--gray); font-size: 13.5px; margin-bottom: 6px; }
.stat-value { color: var(--blue); font-size: 32px; font-weight: 800; line-height: 1.1; }
.stat-sub { color: var(--gray); font-size: 12.5px; margin-top: 6px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.grid-2 .card { margin-bottom: 14px; }
canvas#rev-chart { width: 100%; }

/* ---------- Feed ---------- */
.live-tag { color: var(--green); font-size: 12.5px; font-weight: 600; }
.feed-list { list-style: none; max-height: 300px; overflow-y: auto; }
.feed-list li { display: flex; gap: 10px; padding: 9px 2px; border-bottom: 1px solid #f0f5fa; }
.feed-list li:last-child { border-bottom: none; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue); margin-top: 6px; flex: 0 0 8px; }
.feed-dot.deposit { background: var(--green); }
.feed-dot.user { background: #9db8d2; }
.feed-text { font-weight: 600; font-size: 14px; }
.feed-time { color: var(--gray); font-size: 12px; }

/* ---------- Tables / rows ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--gray); font-size: 11.5px; letter-spacing: .6px; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 10px; border-bottom: 1px solid #f0f5fa; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; background: var(--blue-soft); color: var(--blue-dark); }
.pill.green { background: #e2f4ea; color: var(--green); }
.pill.red { background: #fdeaea; color: var(--red); }
.pill.amber { background: #fdf3e0; color: var(--amber); }
.pill.gray { background: #eef2f7; color: var(--gray); }
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid #f0f5fa; }
.row-item:last-child { border-bottom: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--gray); font-size: 12.5px; margin-top: 2px; }
.clickable { cursor: pointer; }
.clickable:hover { background: #fafcfe; }

/* ---------- Controls ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: none; background: none; padding: 7px 13px; border-radius: 8px; font-size: 13.5px; color: var(--gray); font-weight: 600; }
.seg button.active { background: var(--blue); color: #fff; }
.period-row { margin-bottom: 14px; }
.search, .select, .date-input, .num-input, .text-input {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; background: #fff; color: var(--ink); outline: none;
}
.search { flex: 1; min-width: 180px; }
.search:focus, .select:focus, .text-input:focus { border-color: var(--blue); }
.num-input { width: 90px; }
.textarea { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 14px; font-family: inherit; resize: vertical; outline: none; }
.textarea:focus { border-color: var(--blue); }
.btn { border: 1px solid var(--border); background: #fff; border-radius: 10px; padding: 9px 16px; font-size: 14px; font-weight: 600; }
.btn:hover { border-color: var(--blue); color: var(--blue-dark); }
.btn-primary { border: none; background: var(--blue); color: #fff; border-radius: 10px; padding: 10px 18px; font-size: 14px; font-weight: 700; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-danger { border: none; background: var(--red); color: #fff; border-radius: 10px; padding: 9px 16px; font-size: 14px; font-weight: 700; }
.btn-small { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.link-btn { background: none; border: none; color: var(--blue); font-weight: 600; font-size: 13.5px; }
.row-gap { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.switch { width: 50px; height: 28px; border-radius: 14px; border: 1px solid var(--border); background: #eef2f7; position: relative; flex: 0 0 50px; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: left .15s; }
.switch.on { background: var(--blue); }
.switch.on::after { left: 25px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid #f0f5fa; }
.setting-row:last-of-type { border-bottom: none; }
.setting-name { font-weight: 600; }
.empty { color: var(--gray); text-align: center; padding: 26px 10px; font-size: 14px; }
.low-text { color: var(--red); font-weight: 700; }
.ok-text { color: var(--green); font-weight: 700; }

/* ---------- Sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(31,42,55,.35); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 18px 18px 28px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-body .kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f0f5fa; font-size: 14px; }
.sheet-body .kv b { font-weight: 600; }
.sheet-section { margin-top: 18px; }
.sheet-section h4 { font-size: 14px; margin-bottom: 10px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; color: var(--gray); margin-bottom: 5px; font-weight: 600; }
.field .text-input, .field .num-input { width: 100%; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; word-break: break-all; background: #f7fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }

/* ---------- Toast / tabbar ---------- */
.toast { position: fixed; left: 50%; bottom: 86px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 80; max-width: 90vw; text-align: center; }
.tabbar { display: none; }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { padding: 16px 14px 96px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .stat-value { font-size: 25px; }
  .grid-2 { grid-template-columns: 1fr; }
  .tabbar {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: #fff; border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tab-btn {
    flex: 1; background: none; border: none; padding: 8px 2px 7px; font-size: 19px;
    color: var(--gray); display: flex; flex-direction: column; align-items: center; gap: 1px;
    position: relative;
  }
  .tab-btn span { font-size: 10.5px; font-weight: 600; }
  .tab-btn.active { color: var(--blue); }
  .tab-btn .badge { position: absolute; top: 3px; right: calc(50% - 22px); margin: 0; }
  table .hide-m { display: none; }
}
@media (min-width: 769px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 16px; }
}
