:root {
  --p: #1dbf85;
  --p-deep: #129a6a;
  --p-soft: #e7f8f0;
  --p-glow: rgba(29, 191, 133, 0.18);
  --ink: #1c2a24;
  --muted: #6b7a73;
  --line: #e4ece7;
  --bg: #eef5f1;
  --panel: #ffffff;
  --danger: #e24545;
  --warn: #e8893a;
  --ok: #1dbf85;
  --shadow: 0 18px 50px rgba(28, 42, 36, 0.08);
  --radius: 18px;
  --font: "Plus Jakarta Sans", "PingFang SC", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  font: 14px/1.5 var(--font);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.grow { flex: 1; }

/* ---------- Login ---------- */
.login-shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
}
.login-hero {
  position: relative;
  overflow: hidden;
  padding: 48px;
  color: #fff;
  background:
    radial-gradient(900px 500px at 15% 20%, rgba(255,255,255,.22), transparent 55%),
    radial-gradient(700px 420px at 80% 80%, rgba(18,154,106,.55), transparent 50%),
    linear-gradient(145deg, #0f8f63 0%, #1dbf85 42%, #67d7ad 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-hero::after {
  content: "";
  position: absolute;
  inset: auto -80px -120px auto;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
}
.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.22);
  display: grid;
  place-items: center;
  backdrop-filter: blur(8px);
}
.brand-mark svg { width: 30px; height: 30px; }
.login-hero h1 {
  margin: 28px 0 12px;
  font-size: clamp(34px, 4vw, 52px);
  line-height: 1.08;
  letter-spacing: -0.03em;
  max-width: 10ch;
}
.login-hero p {
  margin: 0;
  max-width: 34ch;
  font-size: 16px;
  color: rgba(255,255,255,.86);
}
.hero-meta {
  display: flex;
  gap: 28px;
  position: relative;
  z-index: 1;
}
.hero-meta strong {
  display: block;
  font-size: 28px;
  letter-spacing: -0.03em;
}
.hero-meta span { opacity: .78; font-size: 13px; }

.login-panel {
  display: grid;
  place-items: center;
  padding: 40px 28px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.7), rgba(238,245,241,.9)),
    var(--bg);
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid rgba(228,236,231,.9);
  border-radius: 28px;
  padding: 34px 32px 30px;
  box-shadow: var(--shadow);
}
.login-card h2 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: -0.03em;
}
.login-card .lead {
  margin: 0 0 26px;
  color: var(--muted);
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input, .field select {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: #fbfdfc;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 4px var(--p-glow);
  background: #fff;
}
.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  height: 46px;
  padding: 0 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, background .15s, box-shadow .15s, opacity .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, #2ad190, var(--p-deep));
  color: #fff;
  box-shadow: 0 10px 24px rgba(18,154,106,.28);
}
.btn-ghost {
  background: #f1f6f3;
  color: var(--ink);
}
.btn-soft {
  background: var(--p-soft);
  color: var(--p-deep);
}
.btn-warn { background: #fff1e5; color: #b86418; }
.btn-danger { background: #ffe9e9; color: #b42323; }
.btn-block { width: 100%; margin-top: 8px; }
#loginMsg {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}
#loginMsg.is-error { color: var(--danger); }
#loginMsg.is-ok { color: var(--p-deep); }

/* ---------- App shell ---------- */
.app-shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: 248px 1fr;
}
.sidebar {
  background: linear-gradient(180deg, #10261d 0%, #163528 100%);
  color: #dff5ea;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.side-brand .logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(29,191,133,.22);
  display: grid;
  place-items: center;
}
.side-brand strong { display: block; font-size: 15px; }
.side-brand span { font-size: 12px; color: rgba(223,245,234,.65); }
.nav-list { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 12px;
  color: rgba(223,245,234,.78);
  text-decoration: none;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.nav-item.active, .nav-item:hover {
  background: rgba(29,191,133,.18);
  color: #fff;
}
.nav-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: .55;
}
.nav-item.active .dot { background: var(--p); opacity: 1; box-shadow: 0 0 0 4px rgba(29,191,133,.2); }
.side-foot {
  margin-top: auto;
  padding: 14px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.05);
  font-size: 12px;
  color: rgba(223,245,234,.7);
}

.main {
  padding: 22px 24px 36px;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.topbar h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.03em;
}
.topbar p { margin: 4px 0 0; color: var(--muted); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--panel);
  border: 1px solid rgba(228,236,231,.9);
  border-radius: 18px;
  padding: 16px 18px;
  box-shadow: 0 10px 30px rgba(28,42,36,.04);
}
.stat .label { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.stat .value { margin-top: 8px; font-size: 28px; font-weight: 800; letter-spacing: -0.04em; }
.stat.open .value { color: #b86418; }
.stat.review .value { color: #2b6cb0; }
.stat.done .value { color: var(--p-deep); }
.stat.all .value { color: var(--ink); }

.card {
  background: var(--panel);
  border: 1px solid rgba(228,236,231,.9);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}
th, td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  font-size: 12px;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f8fbf9;
  position: sticky;
  top: 0;
}
tbody tr:hover { background: #f7fbf9; }
.user-cell strong { display: block; font-size: 14px; }
.user-cell span { color: var(--muted); font-size: 12px; }
.reason { font-weight: 700; }
.reason small { display: block; margin-top: 4px; font-weight: 500; color: var(--muted); }
.pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.pill.open { background: #fff1e5; color: #b86418; }
.pill.reviewing { background: #e8f1ff; color: #2b6cb0; }
.pill.resolved { background: var(--p-soft); color: var(--p-deep); }
.pill.dismissed { background: #eef1ef; color: #66736d; }
.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
}
.empty strong { display: block; color: var(--ink); font-size: 16px; margin-bottom: 6px; }

select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
}

dialog {
  border: 0;
  border-radius: 24px;
  padding: 0;
  width: min(760px, calc(100% - 28px));
  box-shadow: 0 30px 100px rgba(0,0,0,.28);
}
dialog::backdrop { background: rgba(16, 30, 24, .48); backdrop-filter: blur(4px); }
.dialog-body { padding: 24px; }
.dialog-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.dialog-head h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}
.msg-list {
  max-height: 240px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 18px;
}
.msg {
  background: #f5f8f6;
  border-radius: 12px;
  padding: 10px 12px;
}
.msg small { color: var(--muted); margin-left: 8px; }
textarea {
  width: 100%;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  resize: vertical;
  outline: none;
}
textarea:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 4px var(--p-glow);
}
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.management-box {
  margin: 14px 0 20px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfdfc;
}
.management-box h3:first-child { margin-top: 0; }
.compact-input, .reason-input {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
}
.compact-input { width: 90px; }
.reason-input { min-width: 220px; flex: 1; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 12px;
}
.form-span { grid-column: 1 / -1; }

.toolbar-inline {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.search {
  height: 42px;
  min-width: 240px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 14px;
  background: #fff;
  outline: none;
}
.search:focus {
  border-color: var(--p);
  box-shadow: 0 0 0 4px var(--p-glow);
}
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 0;
}
.card-head h3 { margin: 0; font-size: 16px; }
.card.pad { padding: 18px; }
.list { padding: 10px 12px 16px; max-height: 620px; overflow: auto; }
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  cursor: pointer;
}
.list-item:hover { background: #f5faf7; }
.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--p-soft);
}
.online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34,197,94,.15);
  display: inline-block;
  margin-right: 6px;
}
.offline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  display: inline-block;
  margin-right: 6px;
}
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 16px;
}
.tab {
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
}
.tab.active {
  background: var(--p-soft);
  border-color: transparent;
  color: var(--p-deep);
}
.panel-block { display: none; }
.panel-block.active { display: block; }
.audit-notice {
  margin-bottom: 14px;
  padding: 13px 16px;
  border: 1px solid #f1d58e;
  border-radius: 14px;
  background: #fff9e8;
  color: #70591f;
  font-size: 13px;
  line-height: 1.6;
}
.audit-notice strong {
  display: block;
  color: #513e0f;
  margin-bottom: 2px;
}
.note-item, .bubble, .json-box {
  background: #f5f8f6;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}
.bubble.mine { background: #e7f8f0; }
.json-box {
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  max-height: 320px;
  overflow: auto;
}
.dialog-body.wide { max-width: none; }
dialog:has(.wide) { width: min(980px, calc(100% - 28px)); }
.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 18px;
}
.meta-grid div {
  background: #f7faf8;
  border-radius: 12px;
  padding: 10px 12px;
}
.meta-grid label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}
@media (max-width: 980px) {
  .login-shell, .app-shell { grid-template-columns: 1fr; }
  .login-hero { min-height: 280px; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; }
  .side-foot, .side-brand span { display: none; }
  .nav-list { flex-direction: row; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { flex-direction: column; align-items: stretch; }
  .split { grid-template-columns: 1fr; }
  .meta-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
