:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.sm { font-size: 12px; }
.error { color: var(--danger); font-size: 13px; }

/* Buttons */
.btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  padding: 9px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: 0.15s;
}
.btn:hover { border-color: var(--brand); }
.btn.primary {
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
  color: #fff;
  border: none;
}
.btn.primary:hover { opacity: 0.9; }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 12px; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.icon-btn { border: none; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }

/* Login */
.login { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 50px -25px rgba(79,70,229,.4);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; }
.brand .muted { font-weight: 500; font-size: 13px; }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px; color: #fff; font-weight: 900;
  background: linear-gradient(120deg, var(--brand), var(--brand-2));
}
label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
input, textarea, select {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
textarea { resize: vertical; min-height: 70px; }

/* App layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--card); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 6px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; flex: 1; }
.nav-item {
  text-align: left; border: none; background: none; padding: 10px 12px;
  border-radius: 9px; font-weight: 600; cursor: pointer; color: var(--muted); font-size: 13px;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: #eef2ff; color: var(--brand); }

.content { flex: 1; padding: 28px 32px; max-width: 1100px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; margin: 0; }

/* Table / cards */
.list { display: flex; flex-direction: column; gap: 10px; }
.row-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; gap: 14px;
}
.row-card .cover {
  width: 46px; height: 46px; border-radius: 9px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800;
}
.row-card .main { flex: 1; min-width: 0; }
.row-card .title { font-weight: 700; }
.row-card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row-card .actions { display: flex; gap: 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: #eef2ff; color: var(--brand); }
.tag { font-size: 11px; color: var(--muted); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; z-index: 50; }
.modal-box { background: var(--card); border-radius: 16px; width: 100%; max-width: 640px; display: flex; flex-direction: column; max-height: calc(100vh - 60px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px 22px; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-body .full { grid-column: 1 / -1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }

/* Repeatable rows (values/stats) */
.rep { display: flex; flex-direction: column; gap: 8px; }
.rep-item { display: flex; gap: 8px; align-items: flex-start; }
.rep-item input, .rep-item textarea { flex: 1; }

.toast { position: fixed; top: 18px; right: 22px; padding: 11px 16px; border-radius: 10px; color: #fff; font-weight: 600; z-index: 100; box-shadow: 0 10px 30px -10px rgba(0,0,0,.3); }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

@media (max-width: 720px) {
  .sidebar { width: 64px; }
  .sidebar .brand span:not(.logo), .nav-item { font-size: 0; }
  .nav-item { text-align: center; }
  .content { padding: 18px; }
  .modal-body { grid-template-columns: 1fr; }
}
