:root {
  --ink: #17221f;
  --muted: #66736f;
  --line: #dbe3df;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --green: #0d6b57;
  --green-dark: #095242;
  --gold: #c88a27;
  --danger: #b53b32;
  --warning: #9a650d;
  --radius: 6px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e9efec; }
.login-panel { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); padding: 36px; box-shadow: 0 18px 50px rgba(23,34,31,.08); }
.brand-mark { width: 48px; height: 48px; display: grid; place-items: center; background: var(--green); color: #fff; font-weight: 800; font-size: 22px; border-radius: 6px; }
.brand-mark.small { width: 36px; height: 36px; font-size: 17px; }
.eyebrow { margin: 18px 0 4px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: 0; }
h1, h2, h3, p { margin-top: 0; }
.login-panel h1 { margin-bottom: 8px; font-size: 28px; }
.muted { color: var(--muted); }
label { display: grid; gap: 7px; color: #3f4b47; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid #cbd6d1; border-radius: 5px; background: #fff; color: var(--ink); padding: 9px 11px; outline: none; }
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(13,107,87,.1); }
.primary-btn, .secondary-btn, .danger-btn, .text-btn { min-height: 38px; border-radius: 5px; padding: 0 14px; font-weight: 700; }
.primary-btn { border: 1px solid var(--green); background: var(--green); color: #fff; }
.primary-btn:hover { background: var(--green-dark); }
.secondary-btn { border: 1px solid #c7d2cd; background: #fff; color: var(--ink); }
.danger-btn { border: 1px solid #e3c0bd; background: #fff5f4; color: var(--danger); }
.text-btn { border: 0; background: transparent; color: var(--green); padding: 0; }
.login-panel .primary-btn { width: 100%; margin-top: 20px; min-height: 44px; }
.form-error { min-height: 20px; margin: 12px 0 0; color: var(--danger); font-size: 13px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: #15231f; color: #fff; padding: 22px 14px; }
.brand-row { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-row strong, .brand-row span { display: block; }
.brand-row span { margin-top: 3px; color: #9db0a9; font-size: 12px; }
.sidebar nav { display: grid; gap: 4px; margin-top: 18px; }
.nav-item { min-height: 42px; border: 0; border-radius: 5px; background: transparent; color: #b9c7c2; text-align: left; padding: 0 12px; font-weight: 700; }
.nav-item:hover, .nav-item.active { background: #243c35; color: #fff; }
.sidebar-foot { margin-top: auto; display: grid; gap: 10px; padding: 16px 8px 0; border-top: 1px solid rgba(255,255,255,.1); color: #8fa39c; font-size: 11px; }
.sidebar-foot .text-btn { color: #c2d0cb; text-align: left; }
.workspace { min-width: 0; }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 20px 28px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar .eyebrow { margin: 0 0 3px; }
.topbar h1 { margin: 0; font-size: 23px; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.api-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.api-status i { width: 8px; height: 8px; border-radius: 50%; background: #a9b4b0; }
.api-status.online i { background: #23946d; }
.api-status.offline i { background: var(--danger); }
.content { padding: 24px 28px 40px; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); border: 1px solid var(--line); background: #fff; }
.metric { min-height: 112px; padding: 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 12px; font-size: 30px; }
.panel { margin-top: 18px; border: 1px solid var(--line); background: #fff; }
.panel-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-actions { display: flex; align-items: center; gap: 8px; }
.panel-actions input, .panel-actions select { width: auto; min-width: 150px; min-height: 36px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { background: #f8faf9; color: #52605b; text-align: left; font-size: 11px; font-weight: 800; }
th, td { padding: 12px 14px; border-bottom: 1px solid #e7ece9; vertical-align: middle; }
tbody tr:hover { background: #fafcfb; }
tbody tr:last-child td { border-bottom: 0; }
.cell-main { display: block; font-weight: 700; }
.cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 999px; background: #edf3f0; color: #49615a; font-size: 11px; font-weight: 800; }
.badge.good { background: #e4f4ed; color: #176c51; }
.badge.warn { background: #fff1d8; color: #8a5c0d; }
.badge.danger { background: #fbe6e3; color: #9e342d; }
.row-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.row-actions button { min-height: 30px; border: 1px solid #cbd6d1; border-radius: 4px; background: #fff; color: #26332f; padding: 0 9px; font-size: 12px; font-weight: 700; }
.row-actions button.primary { border-color: var(--green); background: var(--green); color: #fff; }
.row-actions button.danger { border-color: #e1bbb7; color: var(--danger); }
.empty, .loading, .error-state { padding: 56px 20px; text-align: center; color: var(--muted); }
.error-state { color: var(--danger); }

dialog { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 40px); border: 0; padding: 0; background: transparent; }
dialog::backdrop { background: rgba(15,27,23,.55); }
.modal-panel { position: relative; max-height: calc(100vh - 40px); overflow: auto; background: #fff; border-radius: 7px; padding: 26px; }
.close-btn { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #eef3f1; color: #53615c; font-size: 22px; }
.modal-panel h2 { padding-right: 40px; font-size: 21px; }
.detail-grid, .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.detail-item { padding: 12px; background: #f6f9f7; border: 1px solid #e2e9e5; }
.detail-item span { display: block; color: var(--muted); font-size: 11px; }
.detail-item strong { display: block; margin-top: 5px; overflow-wrap: anywhere; }
.form-grid .full { grid-column: 1 / -1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.timeline { display: grid; gap: 0; margin-top: 18px; }
.timeline-step { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; min-height: 62px; }
.timeline-step .dot { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #e5ece8; color: #61706b; font-size: 11px; font-weight: 800; }
.timeline-step.done .dot { background: var(--green); color: #fff; }
.timeline-step p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 380px; padding: 12px 15px; border-radius: 5px; background: #17221f; color: #fff; box-shadow: 0 12px 30px rgba(0,0,0,.18); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; font-size: 13px; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric { border-bottom: 1px solid var(--line); }
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .brand-row div:last-child, .nav-item { font-size: 0; }
  .nav-item::first-letter { font-size: 14px; }
  .sidebar { padding-inline: 8px; }
  .brand-row { justify-content: center; padding-inline: 0; }
}

@media (max-width: 720px) {
  .app-shell { display: block; padding-bottom: 66px; }
  .sidebar { position: fixed; z-index: 20; top: auto; bottom: 0; left: 0; right: 0; height: 64px; display: block; padding: 6px; }
  .brand-row, .sidebar-foot { display: none; }
  .sidebar nav { height: 100%; grid-template-columns: repeat(6, 1fr); margin: 0; gap: 2px; }
  .nav-item { min-height: 52px; padding: 4px; text-align: center; font-size: 10px; }
  .nav-item::first-letter { font-size: 10px; }
  .topbar { min-height: 80px; padding: 16px; align-items: flex-start; }
  .top-actions { align-items: flex-end; flex-direction: column-reverse; gap: 6px; }
  .content { padding: 16px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .metric { min-height: 94px; padding: 15px; }
  .metric strong { font-size: 24px; }
  .panel-head { align-items: flex-start; flex-direction: column; }
  .panel-actions { width: 100%; flex-wrap: wrap; }
  .panel-actions input, .panel-actions select { flex: 1; min-width: 120px; }
  .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .modal-panel { padding: 22px 18px; }
}
