:root {
  --bg: #f4f0ea;
  --bg-elevated: #ffffff;
  --surface: #fafaf7;
  --text: #1a1a1a;
  --text-soft: #555;
  --text-muted: #999;
  --border: #e5e0d6;
  --border-soft: #f0ebe1;
  --primary: #e4183f;
  --primary-soft: #fee;
  --success: #16a34a;
  --warning: #ea580c;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* LOGIN */
.page-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login__card {
  background: var(--bg-elevated);
  padding: 48px 40px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 420px;
}
.login__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login__tag {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: var(--text);
  color: var(--bg);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.login__title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}
.login__lede {
  color: var(--text-soft);
  margin-bottom: 28px;
}
.login__form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.login__foot {
  margin-top: 24px;
  text-align: center;
  font-size: 13px;
}

/* LAYOUT */
body:not(.page-login) {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 240px;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.sidebar__tag {
  font-size: 10px;
  letter-spacing: 1px;
  background: var(--text);
  color: var(--bg);
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
}
.sidebar__nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text-soft);
  border-radius: var(--radius-sm);
  font-weight: 500;
  position: relative;
}
.sidebar__nav a:hover {
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.sidebar__nav a.is-active {
  background: var(--text);
  color: var(--bg);
}
.sidebar__nav .badge {
  position: absolute;
  right: 12px;
  background: var(--primary);
  color: white;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.sidebar__footer {
  padding: 16px;
  border-top: 1px solid var(--border-soft);
}
.sidebar__user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.sidebar__user-name {
  font-weight: 600;
  font-size: 13px;
}
.sidebar__logout {
  font-size: 12px;
  color: var(--text-muted);
}
.main {
  flex: 1;
  padding: 32px;
  max-width: calc(100vw - 240px);
  overflow-x: auto;
}

/* PAGE HEAD */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 16px;
}
.page-head h1 {
  font-size: 26px;
  font-weight: 700;
}
.page-head__lede {
  color: var(--text-soft);
  margin-top: 4px;
}
.page-head__actions {
  display: flex;
  gap: 8px;
}

/* CARDS */
.card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}
.card__head h2 {
  font-size: 18px;
  font-weight: 600;
}

/* STATS */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat {
  background: var(--bg-elevated);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.2s, box-shadow 0.2s;
  color: var(--text);
}
.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.stat__label {
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.stat__value {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  margin: 4px 0;
}
.stat__hint {
  font-size: 12px;
  color: var(--text-soft);
}
.stat--alert .stat__value { color: var(--primary); }

/* TABLES */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.table td {
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.table tr {
  transition: background 0.15s;
}
.table tr:hover {
  background: var(--surface);
}
.table tr.is-new {
  background: var(--primary-soft);
}
.table tr.is-new:hover {
  background: #fdd;
}
.table .actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* FORMS */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 800px;
}
.form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form__actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.form__message {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
}
.form__message.is-error { display: block; background: #fee; color: var(--danger); }
.form__message.is-success { display: block; background: #efe; color: var(--success); }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.field input,
.field textarea,
.field select {
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}
.field .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
}
.checkbox input { width: 16px; height: 16px; }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn--primary {
  background: var(--text);
  color: var(--bg);
}
.btn--primary:hover { background: #000; transform: translateY(-1px); }
.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}
.btn--ghost:hover { background: var(--surface); }
.btn--danger {
  background: var(--danger);
  color: white;
}
.link {
  background: none;
  border: none;
  color: var(--primary);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.link:hover { text-decoration: underline; }
.link--danger { color: var(--danger); }

/* TOGGLES & BADGES */
.toggle {
  background: var(--border);
  color: var(--text-soft);
  border: none;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.toggle:hover { transform: scale(1.05); }
.toggle.is-on {
  background: var(--success);
  color: white;
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot--new { background: var(--primary); }
.dot--read { background: var(--border); }
.status {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.status--new { background: var(--primary); color: white; }
.status--contacted { background: var(--warning); color: white; }
.status--qualified { background: #3b82f6; color: white; }
.status--converted { background: var(--success); color: white; }
.status--closed { background: var(--border); color: var(--text-soft); }

/* CLIENT GRID */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
.client-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.client-card.is-inactive {
  opacity: 0.5;
}
.client-card__logo {
  height: 60px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}
.client-card__logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.client-card__name {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
}
.client-card__actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

/* SUBMISSION VIEW */
.submission-view {
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.submission-view__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.submission-view .label {
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}
.submission-view .value {
  font-size: 15px;
  color: var(--text);
}
.submission-view__goal {
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}
.submission-view__notes textarea {
  width: 100%;
  margin-bottom: 12px;
}

/* ALERTS & EMPTY */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}
.alert--error {
  background: #fee;
  color: var(--danger);
  border-left: 3px solid var(--danger);
}
.alert--success {
  background: #efe;
  color: var(--success);
  border-left: 3px solid var(--success);
}
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  body:not(.page-login) { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar__nav { flex-direction: row; overflow-x: auto; padding: 12px; }
  .sidebar__footer { display: none; }
  .main { padding: 20px 16px; max-width: 100%; }
  .form__row { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
