:root {
  --bg: #f3f5f4;
  --panel: #ffffff;
  --ink: #18201d;
  --muted: #66736e;
  --line: #dce4e0;
  --green: #28684f;
  --green-2: #1f513e;
  --teal: #1f7a8c;
  --blue: #345f9f;
  --red: #b54a4a;
  --amber: #a36b1f;
  --shadow: 0 20px 50px rgba(25, 36, 31, .12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  cursor: pointer;
  padding: 0 14px;
}

button:hover {
  background: var(--green-2);
}

button.secondary,
.icon-button,
.nav-item,
.operator-card button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

button.secondary:hover,
.icon-button:hover {
  border-color: var(--green);
  color: var(--green);
  background: #fff;
}

input,
select,
textarea {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  min-width: 0;
}

textarea {
  padding: 10px 12px;
  min-height: 92px;
  resize: vertical;
}

.large-textarea {
  min-height: 300px;
  font-family: Consolas, "Courier New", monospace;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr);
  background: #e9eee8;
}

.login-visual {
  background: linear-gradient(135deg, #173629, #245c47);
  color: #fff;
  padding: 8vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.seal {
  width: 74px;
  height: 74px;
  border: 2px solid rgba(255,255,255,.75);
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 800;
  margin-bottom: 28px;
}

.login-visual h1 {
  margin: 0;
  max-width: 660px;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.12;
}

.login-visual p {
  margin: 18px 0 0;
  font-size: 22px;
  color: #dbe9e2;
}

.login-points {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 42px;
}

.login-points span {
  border: 1px solid rgba(255,255,255,.32);
  border-radius: 999px;
  padding: 9px 14px;
  color: #edf8f2;
}

.login-card {
  width: min(440px, calc(100vw - 32px));
  align-self: center;
  justify-self: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 30px;
  display: grid;
  gap: 18px;
}

.login-card h2 {
  margin: 0 0 6px;
  font-size: 26px;
}

.login-card label,
.form-grid label,
.form-row label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.login-card input {
  width: 100%;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #15221d;
  color: #edf5f0;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #d7eadf;
  color: #17392c;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: #a9bab1;
  font-size: 12px;
  margin-top: 4px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  width: 100%;
  text-align: left;
  background: transparent;
  color: #dfe9e3;
  border-color: transparent;
  justify-content: flex-start;
}

.nav-item.active,
.nav-item:hover {
  background: #244438;
  border-color: #3b6a58;
  color: #fff;
}

.operator-card {
  margin-top: auto;
  border: 1px solid #2f4a40;
  border-radius: 8px;
  padding: 14px;
  background: #1b2c25;
  display: grid;
  gap: 9px;
}

.operator-card span {
  color: #a9bab1;
  font-size: 13px;
}

.main {
  padding: 26px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
}

h2 {
  margin-bottom: 0;
  font-size: 17px;
}

.top-actions,
.toolbar,
.modal-actions,
.panel-head,
.inline-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.top-actions,
.panel-head {
  justify-content: space-between;
}

.alert {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 12px 14px;
}

.alert.error {
  border-color: #e6b8b8;
  color: var(--red);
}

.view {
  display: none;
  gap: 18px;
}

.view.active {
  display: grid;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.panel,
.toolbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 30px;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel-head {
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.toolbar {
  padding: 14px;
}

.toolbar input,
.toolbar select {
  width: min(220px, 100%);
}

.compact-toolbar {
  border-width: 0 0 1px;
  border-radius: 0;
  padding: 12px 16px;
}

.compact-toolbar input,
.compact-toolbar select {
  width: min(170px, 100%);
}

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

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

th,
td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #fbfcfb;
  font-weight: 600;
}

td.actions {
  white-space: nowrap;
}

td.actions button {
  margin: 0 5px 6px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e8eee9;
  color: var(--muted);
  font-size: 12px;
}

.badge.ok {
  background: #dff0e7;
  color: var(--green);
}

.badge.warn {
  background: #f4ead8;
  color: var(--amber);
}

.badge.danger {
  background: #f4dddd;
  color: var(--red);
}

.hint {
  color: var(--muted);
  font-size: 13px;
}

.bar-list,
.role-list,
.permission-list {
  padding: 16px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) 52px;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.bar-track {
  height: 10px;
  background: #edf1ee;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--teal);
}

.role-list {
  display: grid;
  gap: 10px;
}

.role-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  display: grid;
  gap: 6px;
  cursor: pointer;
}

.role-card.active,
.role-card:hover {
  border-color: var(--green);
  background: #f6faf7;
}

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

.role-permissions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.role-card .inline-actions {
  margin-top: 10px;
}

.permission-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #e3f0eb;
  color: var(--green);
  font-size: 12px;
}

.permission-chip.muted {
  background: #eef1ef;
  color: var(--muted);
}

.permission-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.check-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.check-item input {
  min-height: auto;
  margin-top: 3px;
}

.check-item small {
  display: block;
  color: var(--muted);
  margin-top: 4px;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  width: min(920px, calc(100vw - 32px));
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(15, 22, 19, .45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.modal-body {
  padding: 16px;
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding: 14px 16px;
}

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

.form-grid .wide {
  grid-column: 1 / -1;
}

pre {
  margin: 0;
  padding: 16px;
  max-height: 65vh;
  overflow: auto;
  white-space: pre-wrap;
  font-family: Consolas, monospace;
  font-size: 13px;
}

@media (max-width: 980px) {
  .login-screen,
  .app-shell,
  .metrics-grid,
  .split,
  .permission-list,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
