:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #dfe3ea;
  --text: #1c2430;
  --muted: #606d80;
  --primary: #1f5eff;
  --primary-hover: #1749cc;
  --warn-bg: #fff6e5;
  --warn-border: #f0b429;
  --err-bg: #fdecec;
  --err-border: #d64545;
  --ok-bg: #e9f9ef;
  --ok-border: #2f9e44;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #111827;
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 18px; margin: 0; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: #38bdf8; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.inline-field { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.inline-field select { padding: 5px 8px; border-radius: 6px; border: 1px solid #374151; background: #1f2937; color: #fff; }

.layout { display: grid; grid-template-columns: 230px 1fr; min-height: calc(100vh - 54px); }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.sidebar nav { display: flex; flex-direction: column; gap: 6px; }
.nav-item {
  text-align: left; padding: 10px 12px; border: none; border-radius: 8px;
  background: transparent; cursor: pointer; font-size: 14px; color: var(--text);
}
.nav-item:hover { background: #eef2ff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.sidebar-card { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }

.content { padding: 20px 24px; max-width: 1320px; }
.view { display: none; }
.view.active { display: block; }
.section-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.section-header h2 { margin: 0; font-size: 20px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.card h4 { margin: 10px 0 8px; font-size: 14px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 960px) { .layout { grid-template-columns: 1fr; } .two-col { grid-template-columns: 1fr; } }

.filters, .inline-actions, .form-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; align-items: end; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
input, select, textarea {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: #fff;
}
.full-input { width: 100%; margin-bottom: 8px; }

.btn { padding: 7px 13px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: #fff; border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: #f3f4f6; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #e5e7eb; color: #374151; }
.badge-mock { background: #fef3c7; color: #92400e; }
.badge-ok { background: var(--ok-bg); color: #1b6e2d; }
.badge-warn { background: var(--warn-bg); color: #92400e; }
.badge-err { background: var(--err-bg); color: #b91c1c; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab { padding: 9px 14px; border: none; background: transparent; cursor: pointer; font-size: 14px; border-bottom: 2px solid transparent; }
.tab.active { border-bottom-color: var(--primary); color: var(--primary); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.item-box { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: #fcfcfd; }
.item-box.stale { border-color: var(--warn-border); background: var(--warn-bg); }
.simple-list { list-style: none; padding: 0; margin: 10px 0 0; }
.simple-list li { padding: 6px 0; border-bottom: 1px solid #eef0f4; font-size: 13px; }

.alert { padding: 10px 12px; border-radius: 8px; border: 1px solid; margin-bottom: 10px; }
.alert-warn { background: var(--warn-bg); border-color: var(--warn-border); color: #7c4a03; }
.code-box { background: #111827; color: #e5e7eb; padding: 10px; border-radius: 8px; overflow: auto; font-size: 12px; max-height: 220px; }

.toast { position: fixed; right: 20px; bottom: 20px; padding: 12px 16px; border-radius: 8px; background: #111827; color: #fff; font-size: 13px; z-index: 99; max-width: 460px; box-shadow: 0 8px 20px rgba(0,0,0,0.2); }
.toast.err { background: #991b1b; }
.hidden { display: none !important; }
.mt { margin-top: 16px; }
.mt-sm { margin-top: 8px; }
.mb-sm { margin-bottom: 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.bold { font-weight: 600; }
.divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.right { justify-content: flex-end; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: #fff; border-radius: 12px; padding: 20px; width: 520px; max-width: 92vw; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
