:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-soft: #fbfaf7;
  --text: #262522;
  --muted: #72706a;
  --line: #dfddd5;
  --primary: #1f7a5c;
  --primary-strong: #155840;
  --accent: #c06f28;
  --danger: #b23a3a;
  --success-bg: #e7f5ee;
  --success-text: #176347;
  --error-bg: #fbe8e6;
  --error-text: #9a2d2d;
  --shadow: 0 18px 45px rgba(47, 43, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button,
input,
select {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #20231f;
  color: #f7f5ef;
  padding: 24px;
}

.brand,
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 36px;
}

.nav a {
  padding: 11px 12px;
  border-radius: 8px;
  color: #d8d5ca;
}

.nav a.active,
.nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.main {
  min-width: 0;
  padding: 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.25;
}

h2 {
  font-size: 21px;
  line-height: 1.35;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.primary:hover {
  background: var(--primary-strong);
}

.button.ghost {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.button.wide {
  width: 100%;
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
}

.notice.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.notice.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card,
.panel,
.table-wrap,
.login-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 20px;
}

.stat-card span {
  color: var(--muted);
  font-size: 14px;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
  line-height: 1;
}

.panel {
  padding: 24px;
}

.two-column,
.split {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.2fr);
  gap: 26px;
  align-items: start;
}

.info-list {
  display: grid;
  gap: 14px;
  margin: 0;
}

.info-list div {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 12px;
}

.info-list dt {
  color: var(--muted);
}

.info-list dd {
  margin: 0;
  font-weight: 700;
}

.compact {
  margin-top: 18px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.search {
  display: flex;
  width: min(520px, 100%);
  gap: 10px;
}

.search input {
  flex: 1;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 122, 92, 0.14);
}

input[readonly] {
  background: var(--surface-soft);
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.badge.active {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge.disabled {
  background: #ece8df;
  color: #6c675b;
}

.actions {
  text-align: right;
}

td.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.link {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  padding: 0;
  font-weight: 800;
}

.link.danger {
  color: var(--danger);
}

.empty {
  color: var(--muted);
  text-align: center;
}

.form {
  display: grid;
  gap: 16px;
}

.grid-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(31, 122, 92, 0.14), transparent 38%),
    linear-gradient(315deg, rgba(192, 111, 40, 0.16), transparent 40%),
    var(--bg);
}

.login-panel {
  width: min(430px, 100%);
  padding: 30px;
}

.login-brand {
  margin-bottom: 24px;
}

.login-brand h1 {
  font-size: 26px;
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
  }

  .nav {
    display: flex;
    margin-top: 0;
    overflow-x: auto;
  }

  .nav a {
    white-space: nowrap;
  }

  .main {
    padding: 22px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column,
  .split,
  .grid-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .topbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .search {
    flex-direction: column;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .button {
    width: 100%;
  }
}
