:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #16222e;
  --muted: #6b7a8c;
  --line: #dfe6ee;
  --brand: #0f5c66;
  --brand-2: #12808d;
  --accent: #c2611e;
  --ok: #177245;
  --warn: #a8570f;
  --danger: #a52834;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #0b2a33, #123f4a);
  color: #eaf4f6;
  padding: 12px 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand {
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: .2px;
  white-space: nowrap;
}
.brand span { font-weight: 400; opacity: .65; font-size: 13px; }
.brand:hover { text-decoration: none; }

.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  color: #cfe2e6;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 14px;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.topbar nav a.active { background: rgba(255,255,255,.16); color: #fff; }

.quick-search { margin-left: auto; }
.quick-search input {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  color: #fff;
  padding: 7px 12px;
  border-radius: 9px;
  width: 240px;
}
.quick-search input::placeholder { color: #a9c3c9; }
.quick-search input:focus { outline: 2px solid rgba(255,255,255,.35); }

/* ---------- layout ---------- */
.wrap { max-width: 1280px; margin: 0 auto; padding: 22px 22px 60px; }
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 14px; }
.muted { color: var(--muted); font-size: 13px; }
.count {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: #e8eef3;
  border-radius: 20px;
  padding: 1px 9px;
  vertical-align: middle;
}

/* ---------- cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(16,34,46,.04);
}
.card-label { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .6px; }
.card-value { font-size: 30px; font-weight: 700; margin: 6px 0 2px; }
.card-note { color: var(--muted); font-size: 12.5px; }
.card.accent { border-left: 4px solid var(--accent); }
.card.accent .card-value { color: var(--accent); }

/* ---------- panels ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(16,34,46,.04);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- charts ---------- */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 900px) { .charts { grid-template-columns: 1fr; } }
.chart-title { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.bars {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 130px;
  padding-top: 6px;
  border-bottom: 1px solid var(--line);
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  position: relative;
}
.bar {
  width: 100%;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  transition: height .2s ease;
}
.bar.users { background: linear-gradient(180deg, var(--brand-2), var(--brand)); }
.bar.orders { background: linear-gradient(180deg, #e08a4b, var(--accent)); }
.bar-label {
  position: absolute;
  bottom: -20px;
  font-size: 10px;
  color: var(--muted);
  transform: rotate(-45deg);
  white-space: nowrap;
}
.chart { padding-bottom: 24px; }

/* ---------- tables ---------- */
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(16,34,46,.04);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  background: #f7f9fb;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
td { padding: 9px 12px; border-bottom: 1px solid #edf1f5; vertical-align: top; }
tbody tr:hover { background: #f8fbfc; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.chosen { background: #f0f8f3; }
tr.chosen td:first-child { border-left: 3px solid var(--ok); }

table.mini { font-size: 13.5px; }
table.mini td { padding: 7px 6px; border-bottom: 1px solid #eef2f6; }
table.mini tr:last-child td { border-bottom: none; }
.empty { color: var(--muted); text-align: center; padding: 18px; }

/* ---------- filters ---------- */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filters input[type="search"] { min-width: 280px; flex: 1; max-width: 420px; }
input, select {
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 11px;
}
input:focus, select:focus { outline: 2px solid rgba(18,128,141,.28); border-color: var(--brand-2); }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  font: inherit;
  font-size: 13.5px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 9px;
  padding: 8px 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f2f6f8; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ghost { background: transparent; }
.btn.warn { background: #fff7ed; border-color: #f3cfa8; color: var(--warn); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #8d1f2a; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { display: inline; }

/* ---------- info grid ---------- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 22px;
}
.info-grid > div { display: flex; flex-direction: column; gap: 2px; }
.info-grid .wide { grid-column: 1 / -1; }
.info-grid span { color: var(--muted); font-size: 12px; }
.info-grid b { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }

/* ---------- edit form ---------- */
.edit-form .form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.edit-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.edit-form label small { font-size: 11px; color: #93a1b1; }

/* ---------- badges / flash ---------- */
.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 20px;
  padding: 2px 9px;
  margin-left: 6px;
}
.badge.ok { background: #e3f5ea; color: var(--ok); }
.badge.wait { background: #fff2df; color: var(--warn); }

.flash {
  background: #e8f6ee;
  border: 1px solid #bfe4cd;
  color: #145c38;
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 16px;
}

/* ---------- pager ---------- */
.pager {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 24px;
}

/* ---------- danger zone ---------- */
.danger-zone { border-color: #f0c9cd; background: #fffafa; }

/* ---------- footer ---------- */
.foot {
  text-align: center;
  color: #93a1b1;
  font-size: 12px;
  padding: 20px;
}

/* ---------- login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, #164a55, #0b2028 65%);
}
.login-card {
  width: 360px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border-radius: 18px;
  padding: 30px 28px 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-logo { font-size: 24px; font-weight: 700; color: var(--brand); }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.login-card label { font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; }
.login-card .btn { margin-top: 6px; padding: 10px; font-size: 15px; }
.login-error { color: var(--danger); font-size: 13px; }
.login-note { color: #93a1b1; font-size: 11.5px; line-height: 1.4; margin-top: 8px; }

@media (max-width: 700px) {
  .wrap { padding: 16px 12px 50px; }
  .quick-search { order: 5; width: 100%; margin-left: 0; }
  .quick-search input { width: 100%; }
  h1 { font-size: 20px; }
  .card-value { font-size: 24px; }
}
