:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #4f46e5;
  --primary-d: #4338ca;
  --primary-l: #eef2ff;
  --green: #16a34a;
  --green-l: #dcfce7;
  --red: #dc2626;
  --red-l: #fee2e2;
  --amber: #d97706;
  --amber-l: #fef3c7;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
[v-cloak] { display: none; }

/* layout */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: #0f172a; color: #cbd5e1; flex-shrink: 0; display: flex; flex-direction: column; }
.brand { padding: 20px 22px; font-size: 18px; font-weight: 700; color: #fff; letter-spacing: .3px; }
.brand small { display:block; font-size: 11px; font-weight: 400; color: #64748b; margin-top: 2px; letter-spacing: 0; }
.nav { padding: 8px 12px; flex: 1; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 8px; color: #cbd5e1; margin-bottom: 2px; cursor: pointer; font-weight: 500; }
.nav a:hover { background: #1e293b; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid #1e293b; font-size: 12px; color: #64748b; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 28px; display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .user { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.content { padding: 28px; flex: 1; }

/* cards / grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 22px; }
.card h2 { font-size: 16px; margin: 0 0 16px; display: flex; justify-content: space-between; align-items: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 18px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.stat .n { font-size: 30px; font-weight: 700; }
.stat .l { color: var(--muted); margin-top: 4px; }

/* table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); background: #f8fafc; }
tbody tr:hover { background: #f8fafc; }
td.wrap { white-space: normal; word-break: break-all; }
.empty { text-align: center; color: var(--muted); padding: 34px; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 15px; border: 1px solid transparent; border-radius: 8px; background: var(--primary); color: #fff; cursor: pointer; font-size: 13px; font-weight: 600; transition: background .15s; }
.btn:hover { background: var(--primary-d); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: #f8fafc; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b91c1c; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 7px; flex-wrap: wrap; }

/* forms */
.field { margin-bottom: 15px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.field .hint { color: var(--muted); font-weight: 400; font-size: 12px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-l); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.green { background: var(--green-l); color: var(--green); }
.badge.red { background: var(--red-l); color: var(--red); }
.badge.gray { background: #f1f5f9; color: var(--muted); }
.badge.indigo { background: var(--primary-l); color: var(--primary-d); }
.toggle { cursor: pointer; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: 560px; max-width: 100%; max-height: 88vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.x { cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; background: none; border: none; }

/* pagination + toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 14px; color: var(--muted); }

/* login */
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); }
.login-card { background: #fff; border-radius: 14px; padding: 36px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 24px; }

/* toast */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 12px 18px; border-radius: 10px; color: #fff; box-shadow: var(--shadow); font-weight: 500; min-width: 220px; animation: slidein .2s ease; }
.toast.ok { background: #16a34a; }
.toast.err { background: #dc2626; }
.toast.info { background: #334155; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* misc */
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.crumbs { display: flex; gap: 8px; align-items: center; color: var(--muted); margin-bottom: 16px; font-size: 13px; }
.crumbs a { cursor: pointer; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: rot .7s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }
.center-load { text-align: center; padding: 40px; color: var(--muted); }
