/* ===== Platform Admin — light, gọn, chuyên nghiệp ===== */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --text: #15181e;
  --text-2: #3d4350;
  --muted: #7a828f;
  --border: #e7e9ec;
  --border-2: #eef0f2;
  --accent: #2f54d4;
  --accent-hover: #2745b3;
  --accent-weak: #eef2fe;
  --green: #137a3b;
  --green-weak: #e8f5ec;
  --red: #c7362f;
  --red-weak: #fcebea;
  --amber: #a35b06;
  --amber-weak: #fbf0df;
  --radius: 10px;
  --radius-sm: 7px;
  --sh-1: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --sh-2: 0 6px 24px rgba(16, 24, 40, 0.10);
  --sb: 240px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card { width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--sh-2); padding: 28px; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 12.5px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sb) 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px 16px; border-bottom: 1px solid var(--border-2); }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.brand b { font-size: 14.5px; letter-spacing: -0.01em; }
.brand small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }
.nav { padding: 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 8px 11px; border: 0; background: transparent; color: var(--text-2);
  border-radius: var(--radius-sm); font: inherit; font-size: 13px; cursor: pointer;
}
.nav button:hover { background: var(--panel-2); color: var(--text); }
.nav button.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.nav .ico { width: 17px; height: 17px; opacity: 0.85; flex-shrink: 0; }
.nav button.active .ico { opacity: 1; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border-2); color: var(--muted); font-size: 11.5px; display: flex; align-items: center; justify-content: space-between; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 58px; background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 5; }
.topbar h2 { font-size: 15.5px; margin: 0; letter-spacing: -0.01em; }
.topbar .sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 22px 24px 40px; max-width: 1180px; width: 100%; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: var(--radius-sm); font: inherit; font-size: 12.5px; font-weight: 500; cursor: pointer; transition: background .12s, border-color .12s; white-space: nowrap; }
.btn:hover { background: var(--panel-2); border-color: #dadde1; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn .ico { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--red); border-color: #f0cfcd; background: #fff; }
.btn-danger:hover { background: var(--red-weak); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ---------- Card / table ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--sh-1); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border-2); }
.card-head h3 { margin: 0; font-size: 13.5px; }
.card-body { padding: 16px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 9px 14px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border-2); vertical-align: middle; }
.tbl tbody tr:hover { background: var(--panel-2); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .col-r { text-align: right; }
.tbl .nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; line-height: 1.6; }
.badge-green { background: var(--green-weak); color: var(--green); }
.badge-red { background: var(--red-weak); color: var(--red); }
.badge-amber { background: var(--amber-weak); color: var(--amber); }
.badge-dim { background: #eef0f2; color: var(--muted); }
.badge-accent { background: var(--accent-weak); color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 13px; color: var(--text); background: #fff; outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
textarea { resize: vertical; min-height: 72px; font-family: var(--mono); font-size: 12.5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.switch input { width: auto; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17, 24, 39, .42); display: grid; place-items: center; padding: 24px; z-index: 50; }
.modal { width: 540px; max-width: 100%; max-height: 88vh; overflow: auto; background: var(--panel); border-radius: var(--radius); box-shadow: var(--sh-2); }
.modal.lg { width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border-2); position: sticky; top: 0; background: var(--panel); }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--border-2); position: sticky; bottom: 0; background: var(--panel); }

/* ---------- Attribute schema builder (kéo-thả) ---------- */
.schema { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.schema-col { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel-2); min-height: 180px; display: flex; flex-direction: column; }
.schema-col h4 { margin: 0; padding: 10px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border-2); text-transform: uppercase; letter-spacing: .03em; }
.schema-list { padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; min-height: 40px; }
.schema-list.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; border-radius: var(--radius-sm); }
.chip { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12.5px; cursor: grab; }
.chip:active { cursor: grabbing; }
.chip .grip { color: #c3c8cf; }
.chip .type { margin-left: auto; font-size: 10.5px; color: var(--muted); background: var(--panel-2); padding: 1px 6px; border-radius: 4px; }
.chip.ghost { opacity: .4; }

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: 13px; }
.spin { display: inline-block; width: 15px; height: 15px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.toast { position: fixed; right: 20px; bottom: 20px; background: #15181e; color: #fff; padding: 11px 15px; border-radius: var(--radius-sm); box-shadow: var(--sh-2); font-size: 13px; z-index: 80; display: flex; align-items: center; gap: 9px; max-width: 420px; }
.toast.err { background: #7b1d19; }
.toast .dot { background: var(--green); }
.toast.err .dot { background: #ff8a84; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.secret-box { display: flex; gap: 8px; align-items: center; background: var(--amber-weak); border: 1px solid #f0dcbb; border-radius: var(--radius-sm); padding: 10px 12px; }
.secret-box code { flex: 1; word-break: break-all; font-size: 12px; }
.search { position: relative; }
.search input { padding-left: 32px; min-width: 240px; }
.search .ico { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 15px; height: 15px; }
.pill-row { display: flex; gap: 6px; flex-wrap: wrap; }
code.inline { background: var(--panel-2); border: 1px solid var(--border-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
