:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --primary: #2f6fed;
  --primary-dark: #1e4fb8;
  --text: #1c2430;
  --muted: #6b7785;
  --border: #e3e7ee;
  --green: #2ecc71;
  --yellow: #f5a623;
  --red: #e74c3c;
  --grey: #95a5a6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: var(--card);
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  width: 320px;
}

.login-box h1 {
  font-size: 20px;
  margin-bottom: 20px;
  text-align: center;
}

.login-box input {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}

.login-box button, .btn {
  width: 100%;
  padding: 10px 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.login-box button:hover, .btn:hover { background: var(--primary-dark); }

#login-error { color: var(--red); font-size: 13px; margin-bottom: 8px; min-height: 16px; }

.app { display: none; min-height: 100vh; }
.app.visible { display: flex; }

.sidebar {
  width: 220px;
  background: #17213b;
  color: #fff;
  padding: 20px 0;
  flex-shrink: 0;
}

.sidebar h2 { padding: 0 20px; font-size: 16px; margin-bottom: 24px; }

.nav-item {
  padding: 12px 20px;
  cursor: pointer;
  color: #c7d0e0;
  font-size: 14px;
}

.nav-item.active, .nav-item:hover { background: #23305a; color: #fff; }

.logout { margin-top: 40px; }

.main { flex: 1; padding: 24px 32px; overflow-y: auto; }

.tab { display: none; }
.tab.active { display: block; }

h1.page-title { font-size: 22px; margin-bottom: 20px; }

.cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.stat-card .value { font-size: 26px; font-weight: 700; }
.stat-card .label { font-size: 13px; color: var(--muted); margin-top: 4px; }

.charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.chart-card h3 { margin-top: 0; font-size: 15px; }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

th { background: #fafbfd; color: var(--muted); font-weight: 600; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters select, .filters input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  color: #fff;
}
.badge.new { background: var(--grey); }
.badge.in_progress { background: var(--yellow); }
.badge.closed { background: var(--green); }
.badge.cancelled { background: var(--red); }

.action-link {
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  margin-right: 8px;
}

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.toolbar .btn { width: auto; padding: 8px 16px; }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.visible { display: flex; }
.modal {
  background: #fff; border-radius: 12px; padding: 24px; width: 360px;
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal label { display: block; font-size: 13px; margin: 10px 0 4px; color: var(--muted); }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.modal textarea { resize: vertical; min-height: 60px; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn.secondary { background: #eef1f6; color: var(--text); }
.rating-stars { font-size: 22px; cursor: pointer; }
.rating-stars span { opacity: 0.3; }
.rating-stars span.active { opacity: 1; }
