:root {
  --krs-900: #0b2f22;
  --krs-700: #167c51;
  --krs-600: #1c8f5e;
  --krs-100: #e6f4ec;
  --ink: #16211c;
  --muted: #66796f;
  --line: #dfe8e3;
  --bg: #f4f7f5;
  --warn: #b4740a;
  --danger: #b3382f;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 47, 34, 0.06), 0 8px 24px rgba(11, 47, 34, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: radial-gradient(1200px 500px at 15% -10%, #e9f5ee 0%, var(--bg) 55%) no-repeat, var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 22px 22px 56px;
}

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--krs-900), #12543a 60%, var(--krs-700));
  color: #eaf6ef;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.brand-mark {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #ffffff;
  color: var(--krs-700);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
}

.brand-text {
  min-width: 0;
}

.brand-name {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: #a9cdba;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f0c16b;
}

.dot[data-state="ok"] {
  background: #58e39b;
}

.dot[data-state="err"] {
  background: #ff8078;
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--krs-900);
}

.mode-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--krs-100);
  color: var(--krs-700);
  border: 1px solid #cfe8db;
}

.counter {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- form ---------- */

.field {
  margin-bottom: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #3c4f45;
  margin-bottom: 5px;
}

label em {
  color: var(--danger);
  font-style: normal;
}

input[type="text"],
input[type="search"],
textarea,
select {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

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

input:focus,
textarea:focus,
select:focus {
  border-color: var(--krs-600);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(28, 143, 94, 0.13);
}

.hint {
  margin: 4px 0 14px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--muted);
  background: #f7faf8;
  border-left: 3px solid #cfe8db;
  border-radius: 0 8px 8px 0;
  padding: 7px 10px;
}

.actions {
  display: flex;
  gap: 10px;
}

.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.06s, background 0.15s, border-color 0.15s, color 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--krs-700);
  color: #fff;
  box-shadow: 0 1px 2px rgba(11, 47, 34, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: #126b46;
}

.btn-ghost {
  background: #fff;
  color: #33453b;
  border-color: var(--line);
}

.btn-ghost:hover:not(:disabled) {
  border-color: #b9d4c7;
  background: #f6fbf8;
  color: var(--krs-700);
}

.btn-mini {
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 7px;
  background: #fff;
  border-color: var(--line);
  color: #33453b;
}

.btn-mini:hover {
  border-color: var(--krs-600);
  color: var(--krs-700);
}

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

.btn-danger:hover {
  border-color: #e3b6b2;
  background: #fdf4f3;
  color: var(--danger);
}

/* ---------- toolbar ---------- */

.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.toolbar input[type="search"] {
  flex: 1 1 auto;
  min-width: 120px;
}

.toolbar select {
  flex: 0 0 132px;
}

.toolbar .btn {
  flex: none;
}

/* ---------- table ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5b7066;
  background: #f6faf8;
  border-bottom: 1px solid var(--line);
  padding: 9px 11px;
  white-space: nowrap;
}

tbody td {
  padding: 11px;
  border-bottom: 1px solid #eef4f0;
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #fafdfb;
}

.row-title {
  margin: 0;
  font-weight: 650;
  color: var(--krs-900);
  overflow-wrap: anywhere;
}

.row-msg {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: #5a6d63;
  overflow-wrap: anywhere;
}

.who-author {
  margin: 0;
  font-weight: 600;
  font-size: 12.5px;
}

.who-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.col-id {
  width: 56px;
  color: var(--krs-700);
  font-weight: 700;
}

.col-cat,
.col-pri,
.col-status {
  width: 92px;
}

.col-who {
  width: 150px;
}

.col-time {
  width: 128px;
  color: var(--muted);
  white-space: nowrap;
}

.col-act {
  width: 132px;
  white-space: nowrap;
}

.col-act .btn + .btn {
  margin-left: 6px;
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-cat {
  background: #f1f5f3;
  color: #4e635a;
  border-color: #e3ebe6;
}

.badge-info {
  background: #eaf2fd;
  color: #2b5b9b;
  border-color: #d3e2f7;
}

.badge-ok {
  background: var(--krs-100);
  color: #14653f;
  border-color: #cbe7d9;
}

.badge-warn {
  background: #fdf3e3;
  color: var(--warn);
  border-color: #f4e2c2;
}

.badge-danger {
  background: #fceceb;
  color: var(--danger);
  border-color: #f2d3d0;
}

.badge-muted {
  background: #f4f5f5;
  color: #6b7a72;
  border-color: #e6eaea;
}

.empty {
  margin: 0;
  padding: 32px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.footnote {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: #8a9a92;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 40;
  max-width: min(560px, calc(100vw - 40px));
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--krs-900);
  box-shadow: 0 10px 30px rgba(11, 47, 34, 0.28);
}

.toast[data-kind="err"] {
  background: #8f2c25;
}

.toast[data-kind="ok"] {
  background: #14653f;
}

/* ---------- responsive ---------- */

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

  .shell {
    padding: 14px 14px 44px;
  }

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

  .session {
    font-size: 11px;
  }
}
