:root {
  --yellow: #FFD200;
  --yellow-deep: #E6BD00;
  --ink: #141414;
  --ink-soft: #4a4a4a;
  --muted: #8a8a8a;
  --bg: #f4f4f1;
  --card: #ffffff;
  --line: #e7e7e2;
  --green: #1f9d55;
  --red: #d64545;
  --blue: #2f6feb;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.05);
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1,h2,h3 { margin: 0; font-weight: 800; letter-spacing: -.02em; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--ink); color: #fff;
  display: flex; flex-direction: column;
  padding: 24px 18px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 36px; }
.brand-mark {
  background: var(--yellow); color: #000;
  font-weight: 900; font-size: 20px; letter-spacing: -.04em;
  width: 44px; height: 44px; border-radius: 11px;
  display: grid; place-items: center;
}
.brand-text { font-weight: 800; font-size: 18px; line-height: 1; }
.brand-text small { display: block; font-size: 11px; font-weight: 600;
  letter-spacing: .22em; color: var(--yellow); margin-top: 4px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  padding: 11px 14px; border-radius: 10px; font-weight: 600; color: #cfcfcf;
  transition: background .12s, color .12s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar nav a.active { background: var(--yellow); color: #000; }
.sidebar-foot { margin-top: auto; }
.logout { color: var(--muted); font-weight: 600; font-size: 13px; }
.logout:hover { color: #fff; }

.content { flex: 1; padding: 28px 36px 60px; max-width: 1180px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 26px; gap: 16px; }
.topbar h2 { font-size: 26px; }
.sub { color: var(--muted); margin: 4px 0 0; font-size: 13px; font-weight: 600; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 700; font-size: 14px;
  cursor: pointer; transition: transform .05s, box-shadow .12s, background .12s;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--yellow); border-color: var(--yellow-deep); color: #000; }
.btn-primary:hover { background: var(--yellow-deep); }
.btn-ghost { background: transparent; }
.btn-danger { background: #fff; border-color: #f0caca; color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
.btn-block { width: 100%; justify-content: center; padding: 12px; }

/* ---------- KPI cards ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 26px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 16px; box-shadow: var(--shadow);
}
.kpi-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); }
.kpi-value { display: block; font-size: 30px; font-weight: 900; margin-top: 8px; letter-spacing: -.03em; }
.kpi-accent { background: var(--ink); color: #fff; border-color: var(--ink); }
.kpi-accent .kpi-label { color: var(--yellow); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .kpis { grid-template-columns: repeat(2, 1fr); } }

/* ---------- cards / grid ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card h3 { font-size: 15px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-soft); margin-bottom: 14px; }
.card h3 + h3 { margin-top: 22px; }
.link { display: inline-block; margin-top: 12px; font-weight: 700; font-size: 13px; color: var(--blue); }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
.mini td { padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
.mini tr:last-child td { border-bottom: none; }
.data thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--line);
}
.data tbody td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.data tbody tr { cursor: pointer; transition: background .1s; }
.data tbody tr:hover { background: #faf8ee; }
.table-wrap { padding: 8px 10px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.strong { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; padding: 28px; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overdue td:first-child { color: var(--red); font-weight: 800; }
.bar-cell { width: 55%; }
.bar { display: inline-block; height: 9px; border-radius: 5px; background: var(--yellow); min-width: 4px; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 700; letter-spacing: .01em; }
.badge-lead { background: #eef2ff; color: #3b4cca; }
.badge-scheduled { background: #fff3d6; color: #9a6b00; }
.badge-active { background: #e3f6ec; color: #137a43; }
.badge-paused { background: #f0f0f0; color: #666; }
.badge-stopped { background: #fbe4e4; color: #b23030; }
.badge-lost { background: #ededed; color: #999; }

/* ---------- detail / kv ---------- */
.detail-actions { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; }
.inline-right { margin-left: auto; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; font-size: 13px; }
.kv dd { margin: 0; font-weight: 600; }
.notes { white-space: pre-wrap; line-height: 1.5; }

/* ---------- forms ---------- */
.filters { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.filters input[type=search] { flex: 1; min-width: 220px; }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--yellow); border-color: var(--yellow-deep); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.form-grid label input, .form-grid label select, .form-grid label textarea { font-weight: 500; text-transform: none; letter-spacing: 0; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 12px; margin-top: 22px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- login ---------- */
.login-body { background: var(--ink); display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { background: var(--card); border-radius: 20px; padding: 38px 34px; width: 100%; max-width: 380px;
  box-shadow: 0 24px 70px rgba(0,0,0,.4); }
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-brand h1 { font-size: 20px; }
.login-brand p { margin: 4px 0 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.login-card label { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-soft); margin-bottom: 8px; }
.login-card input { margin-bottom: 18px; }
.login-error { background: #fbe4e4; color: #b23030; padding: 11px 14px; border-radius: 10px;
  font-weight: 600; font-size: 13px; margin-bottom: 18px; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 20px 0 0; }

/* ---------- user info in sidebar ---------- */
.who { margin-bottom: 10px; }
.who-name { display: block; color: #fff; font-weight: 700; font-size: 14px; }
.who-role { display: block; color: var(--yellow); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; }

/* ---------- avatars ---------- */
.avatar { display: inline-block; object-fit: cover; border-radius: 50%; vertical-align: middle; background: #eee; }
.avatar-sm { width: 30px; height: 30px; margin-right: 10px; }
.avatar-lg { width: 64px; height: 64px; }
.avatar-empty { display: inline-grid; place-items: center; background: var(--ink); color: var(--yellow);
  font-weight: 900; }
.avatar-sm.avatar-empty { font-size: 13px; }
.avatar-lg.avatar-empty { font-size: 26px; }
.name-cell { display: flex; align-items: center; }
.detail-head { display: flex; align-items: center; gap: 16px; }

/* ---------- photo gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.photo { margin: 0; position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fafafa; }
.photo.is-avatar { border-color: var(--yellow-deep); box-shadow: 0 0 0 2px var(--yellow); }
.photo img { width: 100%; height: 150px; object-fit: cover; display: block; }
.photo figcaption { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; gap: 6px; }
.avatar-tag { position: absolute; top: 8px; left: 8px; background: var(--yellow); color: #000;
  font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 8px; border-radius: 999px; }
.upload-form { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--line); }
.upload-form input[type=file] { width: auto; flex: 1; min-width: 200px; }

/* ---------- user mgmt ---------- */
.user-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.user-form input, .user-form select { width: auto; flex: 1; min-width: 140px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.inline { display: inline; }
.inline-menu { position: relative; }
.inline-menu summary { list-style: none; cursor: pointer; }
.inline-menu summary::-webkit-details-marker { display: none; }
.popform { position: absolute; right: 0; z-index: 10; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px; box-shadow: var(--shadow); display: flex; gap: 6px; width: 240px; margin-top: 4px; }
.inactive-row { opacity: .55; }
.pre { white-space: pre-wrap; }
