:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --nav: #1e3a8a;          /* тёмно-синее верхнее меню */
  --nav2: #2547a8;
  --blue: #2563eb;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
  --orange: #f97316;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

/* ---- верхнее меню ---- */
.navbar { background: linear-gradient(90deg, var(--nav), var(--nav2)); color: #fff; }
.nav-inner {
  display: flex; align-items: center; gap: 18px;
  max-width: 1320px; margin: 0 auto; padding: 0 22px; height: 56px;
}
.nav-brand { font-weight: 800; font-size: 17px; color: #fff; text-decoration: none; letter-spacing: .02em; }
.nav-menu { list-style: none; display: flex; gap: 4px; margin: 0; padding: 0; flex: 1; overflow-x: auto; }
.nav-menu a {
  color: #c7d2fe; text-decoration: none; font-size: 13.5px; font-weight: 500;
  padding: 8px 12px; border-radius: 8px; white-space: nowrap; display: inline-block;
}
.nav-menu a:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-menu a.active { background: rgba(255,255,255,.18); color: #fff; }
.nav-exit { color: #c7d2fe; text-decoration: none; font-size: 13.5px; padding: 8px 12px; }
.nav-exit:hover { color: #fff; }

main { max-width: 1320px; margin: 0 auto; padding: 24px 22px 48px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.btn-orange {
  background: var(--orange); color: #fff; border: none; padding: 10px 16px;
  border-radius: 9px; cursor: pointer; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow);
}
.btn-orange:hover { filter: brightness(1.05); }

.error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  padding: 14px 16px; border-radius: 10px; margin-bottom: 18px; }
.hidden { display: none; }

/* ---- карточки ---- */
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-label { color: var(--muted); font-size: 13px; }
.card-value { font-size: 30px; font-weight: 800; margin-top: 6px; }
.card-icon {
  width: 46px; height: 46px; border-radius: 11px; display: grid; place-items: center;
  font-size: 20px; flex-shrink: 0;
}
.card-icon.gray   { background: #eef2f7; }
.card-icon.green  { background: #d1fae5; }
.card-icon.amber  { background: #fef3c7; }
.card-icon.red    { background: #fee2e2; }
.card-icon.purple { background: #ede9fe; }
.card-icon.blue   { background: #dbeafe; }

/* ---- панель с таблицей ---- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; }
.panel h2 { margin: 0; font-size: 16px; }
.table-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#search { background: #fff; border: 1px solid var(--line); color: var(--ink);
  padding: 8px 12px; border-radius: 9px; font-size: 13px; min-width: 190px; }
.filters { display: flex; gap: 6px; }
.filters button { background: #fff; border: 1px solid var(--line); color: var(--muted);
  padding: 7px 12px; border-radius: 9px; cursor: pointer; font-size: 12px; }
.filters button.active { color: #fff; border-color: var(--blue); background: var(--blue); }

.table-scroll { overflow: auto; max-height: 560px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { position: sticky; top: 0; background: #f8fafc; color: var(--muted);
  text-align: left; font-weight: 600; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody td { padding: 12px; border-bottom: 1px solid #f1f3f7; }
tbody tr:hover { background: #f8fafc; }
.email { font-weight: 600; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; display: inline-block; }
.badge.sub      { background: #d1fae5; color: #047857; }
.badge.trial    { background: #fef3c7; color: #b45309; }
.badge.active   { background: #dbeafe; color: #1d4ed8; }
.badge.expired  { background: #fee2e2; color: #b91c1c; }
.badge.disabled { background: #eef2f7; color: #6b7280; }
.badge.pending  { background: #ede9fe; color: #6d28d9; }

.online-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); margin-right: 7px; vertical-align: middle;
  box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.soon { color: var(--amber); font-weight: 700; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 30px; }

@media (max-width: 1000px) { .cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .cards { grid-template-columns: 1fr; } }

.user-summary { grid-template-columns: repeat(4,1fr); }
.small { font-size: 11.5px; margin-top: 3px; }
#userSearch, #statusFilter { background:#fff; border:1px solid var(--line); color:var(--ink); padding:9px 11px; border-radius:9px; font-size:13px; }
#userSearch { min-width:260px; }
.users-scroll { max-height:calc(100vh - 285px); min-height:400px; }
.users-table td { vertical-align:top; white-space:nowrap; }
.btn-detail { border:1px solid #bfdbfe; background:#eff6ff; color:#1d4ed8; border-radius:8px; padding:7px 10px; cursor:pointer; }
.modal { position:fixed; inset:0; z-index:30; background:rgba(15,23,42,.52); display:grid; place-items:center; padding:20px; }
.modal.hidden { display:none; }
.modal-card { background:#fff; border-radius:16px; width:min(880px,100%); max-height:90vh; overflow:auto; padding:24px; position:relative; box-shadow:0 20px 60px rgba(0,0,0,.2); }
.modal-card h2 { margin:0; }
.modal-close { position:absolute; top:12px; right:14px; border:0; background:#eef2f7; width:34px; height:34px; border-radius:50%; font-size:22px; cursor:pointer; }
.detail-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; margin-top:20px; }
.detail-item { border:1px solid var(--line); background:#f8fafc; border-radius:10px; padding:11px 12px; min-width:0; }
.detail-item span:first-child { display:block; color:var(--muted); font-size:11.5px; margin-bottom:5px; }
.detail-item b { font-size:13.5px; overflow-wrap:anywhere; }
@media(max-width:1000px){.user-summary{grid-template-columns:repeat(2,1fr)}}
@media(max-width:600px){.user-summary,.detail-grid{grid-template-columns:1fr}#userSearch{min-width:100%;width:100%}.users-scroll{max-height:none}.modal{padding:8px}.modal-card{padding:20px 14px}}

/* ---- раздел «Доход» (финансы) ---- */
.fin-panel { margin-bottom: 20px; }
.btn-add { background: #eef2f7; border: 1px solid var(--line); color: var(--blue);
  padding: 7px 13px; border-radius: 9px; cursor: pointer; font-size: 12.5px; font-weight: 600; }
.btn-add:hover { background: #e0e7ff; }
.fin-table td { padding: 8px 10px; vertical-align: middle; border-bottom: 1px solid #f1f3f7; }
.fin-table input.fin-in { width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 13.5px; background: #fff; color: var(--ink); }
.fin-table input.fin-in:focus { outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.fin-table input.price, .fin-table input.count, .fin-table input.xamount { max-width: 140px; }
.fin-table td.rev { font-weight: 700; white-space: nowrap; }
.fin-table tfoot td { font-weight: 800; border-top: 2px solid var(--line);
  border-bottom: none; background: #f8fafc; padding: 12px 10px; }
.fin-table th:last-child, .fin-table td:last-child { width: 40px; text-align: center; }
.row-x { background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 5px 7px; border-radius: 6px; }
.row-x:hover { background: #fee2e2; color: var(--red); }
.fin-save-note { margin-top: 14px; font-size: 13px; font-weight: 600; }
