:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #f97316;
  --accent-dark: #ea580c;
  --ok: #059669;
  --err: #dc2626;
  --sidebar: #111827;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

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

h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 14px; font-weight: 650; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }

/* layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: var(--sidebar);
  color: #e5e7eb;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  padding: 0 10px 22px;
}
.brand small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: #9ca3af;
}
.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, .18);
  flex: 0 0 auto;
}

.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  padding: 9px 12px;
  border-radius: 8px;
  color: #d1d5db;
  font-size: 14px;
}
.sidebar nav a:hover { background: #1f2937; color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; font-weight: 600; }

.logout { margin-top: auto; }
.logout button {
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: 1px solid #374151;
  color: #d1d5db;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.logout button:hover { border-color: #6b7280; color: #fff; }

.main { flex: 1; padding: 30px 34px 60px; max-width: 1280px; }

/* page head */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

/* cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .04);
}
.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat { text-align: left; }
.stat-num { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.stat-label { color: var(--muted); font-size: 12px; margin-top: 2px; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 18px; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: #fafafa; }
.table tbody tr:last-child td { border-bottom: none; }
.table.compact th, .table.compact td { padding: 7px 8px; }

.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.kv td:first-child { color: var(--muted); width: 38%; }
.kv tr:last-child td { border-bottom: none; }

/* tags */
.tag {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #374151;
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
}
.tag.ok { background: #d1fae5; color: #065f46; }
.tag.off { background: #fee2e2; color: #991b1b; }
.tag.paid { background: #ffedd5; color: #9a3412; }

/* buttons */
.btn {
  display: inline-block;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: #d1d5db; background: #f9fafb; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.danger { color: var(--err); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.actions { display: flex; justify-content: flex-end; }

/* forms */
label.field, .field {
  display: block;
  margin-bottom: 14px;
  font-size: 13px;
  color: #374151;
}
input, select, textarea {
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249, 115, 22, .12); }
textarea { resize: vertical; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  font-size: 13px;
  cursor: pointer;
}
.check input { width: auto; margin: 0; accent-color: var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.inline-form label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); min-width: 130px; }
.inline-form input, .inline-form select { margin-top: 4px; }

.search { display: flex; gap: 8px; }
.search input { min-width: 240px; margin: 0; }

/* flashes */
.flash {
  padding: 10px 14px;
  border-radius: 9px;
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid;
}
.flash.ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash.err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 400px at 50% -10%, rgba(249, 115, 22, .12), transparent 60%),
    var(--bg);
}
.login-wrap .flash { width: 100%; max-width: 380px; margin-bottom: 12px; }
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 12px 40px rgba(17, 24, 39, .08);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15px;
  color: var(--accent);
  margin-bottom: 18px;
}
.login-card h1 { font-size: 24px; margin-bottom: 2px; }
.login-card p { margin: 0 0 22px; }
.login-card .btn { width: 100%; margin-top: 4px; }

/* pager */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 6px 0 10px;
}

@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px; }
  .brand { padding: 0 8px 0 0; }
  .brand small { display: none; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .logout { margin: 0 0 0 auto; }
  .logout button { width: auto; }
  .main { padding: 20px 16px 40px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
