/* ============================================================================
   CRM Offstage — tema dark + verde d0ff3c
   ============================================================================ */

:root {
  --bg: #0c0d0c;
  --bg-elevated: #141514;
  --card: #171816;
  --card-hover: #1d1f1c;
  --border: #2a2c28;
  --border-soft: #212320;
  --text: #f2f4ef;
  --text-muted: #9a9d95;
  --text-dim: #6c6f68;
  --accent: #d0ff3c;
  --accent-dark: #a8d12c;
  --accent-text: #0c0d0c;
  --danger: #e05a4d;
  --danger-bg: rgba(224, 90, 77, 0.12);
  --warn: #e0b34d;
  --ok: #4dc98b;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body {
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }

h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

p { margin: 0 0 8px; color: var(--text-muted); }

::selection { background: var(--accent); color: var(--accent-text); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

/* ---------- Layout ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-soft);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 20px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(208, 255, 60, 0.5);
}

.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-name small { display: block; color: var(--text-dim); font-weight: 400; font-size: 11px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 500;
  border: 1px solid transparent;
  user-select: none;
}
.nav-item:hover { background: var(--card-hover); color: var(--text); }
.nav-item.active { background: var(--card); color: var(--accent); border-color: var(--border); }

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

.main {
  padding: 22px 28px 60px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
  flex-wrap: wrap;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}
.user-chip .u-name { font-weight: 600; font-size: 13px; }
.user-chip .u-role { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 14px; }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) {
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}

.card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px;
}

.stat-card { display: flex; flex-direction: column; gap: 6px; }
.stat-card .stat-label { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat-card .stat-value.accent { color: var(--accent); }
.stat-card .stat-sub { font-size: 12px; color: var(--text-muted); }

.section { margin-bottom: 26px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .05s ease;
}
.btn:hover { background: var(--card-hover); border-color: #3a3d36; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--card-hover); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }
input, select, textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(208,255,60,0.15); }
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.hint { font-size: 11px; color: var(--text-dim); margin-top: 4px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border-soft); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-elevated);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background .1s; }
tbody tr:hover { background: var(--card-hover); }
.empty-row td { text-align: center; color: var(--text-dim); padding: 30px; cursor: default; }
.empty-row:hover { background: transparent; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-dot { width: 7px; height: 7px; border-radius: 50%; }

/* ---------- Filters bar ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  background: var(--card);
  border: 1px solid var(--border-soft);
  padding: 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.filters .field { margin-bottom: 0; min-width: 150px; }
.filters .field.grow { flex: 1; min-width: 200px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border-soft);
}
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border-soft); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { cursor: pointer; color: var(--text-dim); font-size: 20px; line-height: 1; background: none; border: none; }
.modal-close:hover { color: var(--text); }

/* ---------- Stage timeline ---------- */
.timeline { display: flex; flex-direction: column; gap: 0; margin-top: 6px; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.timeline-content { flex: 1; }
.timeline-title { font-weight: 600; font-size: 13px; }
.timeline-meta { font-size: 11px; color: var(--text-dim); }

/* ---------- Login page ---------- */
.login-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 0%, #1a1d15 0%, #0c0d0c 60%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 34px 30px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 26px; }
.login-brand .brand-dot { width: 18px; height: 18px; border-radius: 5px; }
.login-brand h1 { font-size: 19px; }
.login-brand span { color: var(--text-dim); font-size: 12px; }
.error-box {
  background: var(--danger-bg); border: 1px solid rgba(224,90,77,0.4); color: #ff9d92;
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 14px; display: none;
}
.error-box.show { display: block; }

/* ---------- Tabs (mobile nav fallback) ---------- */
.tag-muted { color: var(--text-dim); font-size: 12px; }

/* ---------- Misc ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.divider { height: 1px; background: var(--border-soft); margin: 16px 0; border: none; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 20; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 14px; }
  .brand { border: none; padding: 0 14px 0 0; margin: 0; }
  .sidebar-footer { margin: 0 0 0 auto; padding: 0; border: none; }
  .nav-item { white-space: nowrap; }
  .main { padding: 16px; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
}
