:root {
  --bg: #f5f1ea;
  --panel: #fffdf9;
  --panel-soft: #f0e9df;
  --text: #18222d;
  --muted: #68707a;
  --primary: #123b5d;
  --primary-soft: #dbe8f2;
  --success: #2f7d57;
  --warn: #b7791f;
  --danger: #b34a3c;
  --border: #ddd3c4;
  --shadow: 0 16px 40px rgba(24, 34, 45, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "PingFang SC", "Noto Sans SC", sans-serif;
  background: linear-gradient(180deg, #f7f3ec 0%, #efe6d9 100%);
  color: var(--text);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  padding: 28px 20px;
  background: rgba(18, 59, 93, 0.96);
  color: #f4f7fa;
}
.brand { font-size: 22px; font-weight: 700; line-height: 1.3; margin-bottom: 28px; }
.nav-list { display: flex; flex-direction: column; gap: 10px; }
.nav-list a, .nav-muted {
  padding: 12px 14px;
  border-radius: 12px;
  color: rgba(244, 247, 250, 0.92);
}
.nav-list a:hover { background: rgba(255, 255, 255, 0.08); }
.nav-muted { opacity: 0.45; }
.main-shell { display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 28px; border-bottom: 1px solid rgba(221, 211, 196, 0.9);
  background: rgba(255, 253, 249, 0.9); backdrop-filter: blur(10px);
}
.topbar-meta { display: flex; align-items: center; gap: 12px; }
.topbar-user { color: var(--muted); }
.content { padding: 28px; }
.page-header h1 { margin: 0 0 8px; font-size: 32px; }
.page-header p { margin: 0 0 24px; color: var(--muted); }
.card, .login-card {
  background: var(--panel); border: 1px solid rgba(221, 211, 196, 0.8);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card { padding: 22px; }
.card h2 { margin-top: 0; }
.card-grid { display: grid; gap: 18px; }
.metrics-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 20px; }
.groups-setup-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-bottom: 20px; }
.account-control-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-top: 20px; }
.account-management-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(320px, 0.95fr);
  gap: 20px;
  margin-top: 24px;
}
.metric-card { min-height: 130px; display: flex; flex-direction: column; justify-content: space-between; }
.metric-label { color: var(--muted); }
.metric-value { font-size: 34px; }
.split-card {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px;
}
.two-column-layout { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: 20px; }
.stack-form { display: grid; gap: 14px; }
.stack-form label { display: grid; gap: 8px; }
.stack-form span { font-size: 14px; color: var(--muted); }
.checkbox-line { display: flex !important; align-items: center; gap: 10px; }
.checkbox-line input[type="checkbox"] { width: auto; margin: 0; }
.checkbox-line span { color: var(--text); font-size: 15px; }
.form-inline-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.inline-form select { min-width: 180px; width: auto; }
input, select, textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
}
textarea { resize: vertical; }
.multi-select { min-height: 180px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 16px; border-radius: 12px; border: none; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--panel-soft); color: var(--text); }
.badge {
  display: inline-flex; align-items: center; padding: 7px 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600;
}
.badge-success { background: rgba(47, 125, 87, 0.14); color: var(--success); }
.badge-warn { background: rgba(183, 121, 31, 0.14); color: var(--warn); }
.table-shell { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; min-width: 720px;
}
.data-table th, .data-table td {
  padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table th { color: var(--muted); font-weight: 600; }
.table-note { color: var(--muted); font-size: 13px; line-height: 1.55; }
.flash-list { display: grid; gap: 10px; margin-bottom: 20px; }
.flash-item { padding: 12px 14px; border-radius: 12px; }
.flash-success { background: rgba(47, 125, 87, 0.12); color: var(--success); }
.flash-error { background: rgba(179, 74, 60, 0.12); color: var(--danger); }
.item-list { display: grid; gap: 14px; }
.list-item {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
  padding: 16px; border-radius: 14px; background: #fff; border: 1px solid var(--border);
}
.group-list-item { align-items: stretch; }
.account-section { margin-top: 22px; }
.account-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.account-control-panel {
  padding: 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(240, 233, 223, 0.38);
}
.account-control-panel h3,
.account-group-list h3 {
  margin-top: 0;
}
.account-group-list {
  margin-top: 24px;
}
.account-rule-panel {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}
.account-rule-list-panel .item-list {
  margin-top: 14px;
}
.section-heading h3,
.section-heading h4,
.account-control-panel h4 {
  margin-top: 0;
  margin-bottom: 8px;
}
.section-heading p {
  margin: 0;
}
.inline-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.group-list-content { flex: 1; min-width: 0; }
.group-settings-form { margin-top: 14px; }
.group-actions { min-width: 120px; }
.list-item-actions { display: grid; gap: 10px; min-width: 120px; }
.list-item p { margin: 6px 0 0; }
.detail-list { display: grid; gap: 10px; margin-bottom: 18px; }
.detail-list p { margin: 0; }
.auth-panel { margin-top: 18px; }
.status-panel {
  margin-top: 18px; padding: 14px 16px; border-radius: 14px;
  background: var(--panel-soft); color: var(--text);
}
.status-success { background: rgba(47, 125, 87, 0.12); color: var(--success); }
.log-block {
  margin: 0; padding: 16px; border-radius: 14px; background: #18222d;
  color: #f4f7fa; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.muted, .empty-state, .subtitle, .eyebrow { color: var(--muted); }
.login-body { min-height: 100vh; display: grid; place-items: center; }
.login-shell { width: 100%; max-width: 520px; padding: 24px; }
.login-card { padding: 32px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; }
.compact { margin-top: 18px; }
.is-hidden { display: none; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { padding-bottom: 12px; }
  .two-column-layout { grid-template-columns: 1fr; }
  .account-management-grid { grid-template-columns: 1fr; }
  .split-card, .topbar { flex-direction: column; align-items: flex-start; }
  .account-section-header { flex-direction: column; }
  .list-item { flex-direction: column; }
  .list-item-actions { width: 100%; }
}
