:root {
  --brand: #db4a2b;
  --brand-dark: #b63b22;
  --bg: #f5f5f7;
  --card-bg: #ffffff;
  --text-main: #111111;
  --text-muted: #777777;
  --border-soft: #e2e2e7;
  --danger: #e53935;
  --radius-lg: 12px;
  --radius-xl: 18px;
  --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.07);
  --sidebar-width: 230px;
  --transition-fast: 0.18s ease-out;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
}

.app-root {
  min-height: 100vh;
}

/* VIEWS */

.view {
  display: none;
}

.view.active {
  display: block;
}

/* LOGIN */

.login-background {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top left, #ffb199 0, #db4a2b 35%, #4a0000 100%);
  padding: 24px;
}

.login-card-wrapper {
  width: 100%;
  max-width: 420px;
}

.login-logo-large {
  text-align: center;
  margin-bottom: 16px;
}

.login-logo-large img {
  width: 120px;
  height: 120px;
  border-radius: 24px;
  object-fit: cover;
}

.auth-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 24px 24px 20px;
  box-shadow: var(--shadow-soft);
}

.auth-card-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}

.auth-card-logo img {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  margin-right: 10px;
}

.auth-card-title h1 {
  font-size: 1.25rem;
  margin: 0;
}

.auth-card-title p {
  margin: 4px 0 0;
}

.form {
  margin-top: 8px;
}

.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  font-size: 0.9rem;
  outline: none;
  transition: border var(--transition-fast), box-shadow var(--transition-fast);
  background: #fdfdfd;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(219, 74, 43, 0.12);
}

textarea {
  resize: vertical;
}

/* Password field */

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field input {
  padding-right: 40px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}

.password-toggle.visible {
  opacity: 0.9;
}

.password-toggle:hover {
  opacity: 0.9;
}

/* Text helpers */

.muted {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.tiny-text {
  font-size: 0.75rem;
}

.error-text {
  color: var(--danger);
  font-size: 0.8rem;
  min-height: 16px;
}

.login-footer-text {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 10px;
}

/* BUTTONS */

.btn {
  border-radius: 999px;
  border: none;
  padding: 8px 18px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background var(--transition-fast), color var(--transition-fast),
    box-shadow var(--transition-fast), transform 0.08s ease-out;
}

.btn.primary-btn {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(219, 74, 43, 0.35);
}

.btn.primary-btn:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
}

.btn.ghost-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.7);
  color: #ffffff;
}

.btn.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn.danger-btn {
  background: #ffffff;
  color: var(--danger);
  border: 1px solid rgba(229, 57, 53, 0.4);
}

.btn.danger-btn:hover {
  background: rgba(229, 57, 53, 0.06);
}

.btn.small-btn {
  padding: 5px 12px;
  font-size: 0.78rem;
}

.btn.full-width {
  width: 100%;
}

/* PORTAL LAYOUT */

.topbar {
  height: 64px;
  background: var(--brand);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
}

.topbar-app-text {
  display: flex;
  flex-direction: column;
}

.app-title {
  font-size: 0.95rem;
  font-weight: 700;
}

.app-subtitle {
  font-size: 0.75rem;
  opacity: 0.85;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.user-email {
  font-size: 0.78rem;
  opacity: 0.9;
}

.main-layout {
  display: flex;
  min-height: calc(100vh - 64px);
}

/* SIDEBAR */

.sidebar {
  width: var(--sidebar-width);
  background: #ffffff;
  border-right: 1px solid var(--border-soft);
  padding: 16px 12px;
}

.sidebar-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.tab-button {
  width: 100%;
  border-radius: 10px;
  border: none;
  padding: 8px 10px;
  text-align: left;
  margin-bottom: 6px;
  background: transparent;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #444;
  transition: background var(--transition-fast), color var(--transition-fast),
    transform 0.08s ease-out;
}

.tab-button:hover {
  background: rgba(219, 74, 43, 0.06);
}

.tab-button.active {
  background: rgba(219, 74, 43, 0.13);
  color: var(--brand-dark);
  font-weight: 600;
}

/* CONTENT AREA */

.content-area {
  flex: 1;
  padding: 18px 20px 24px;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-header h2 {
  margin: 0;
}

/* CARDS / GRID */

.card {
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  padding: 16px 18px;
  box-shadow: var(--shadow-soft);
}

/* Welcome card */

.welcome-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.welcome-left h3 {
  margin: 0 0 4px;
}

.welcome-right {
  max-width: 360px;
  text-align: right;
}

.welcome-quote-label {
  font-size: 0.75rem;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--brand-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.welcome-quote {
  margin: 0;
  font-style: italic;
  font-size: 0.9rem;
}

/* Stats grid */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-card h3 {
  margin: 0 0 8px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stats-item {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px dashed rgba(0, 0, 0, 0.04);
  background: #fafafa;
}

.stats-label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.stats-value {
  font-size: 1.05rem;
  font-weight: 700;
}

/* Chart card */

.chart-card {
  margin-bottom: 18px;
}

.chart-header h3 {
  margin: 0 0 4px;
}

.chart-body {
  margin-top: 10px;
}

/* FORM LAYOUT (INSIDE TABS) */

.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-group.flex-1 {
  flex: 1;
}

/* Dynamic input rows */

.dynamic-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.dynamic-input-row input {
  flex: 1;
}

/* Filters / pagination / tables */

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  justify-content: space-between;
  margin: 14px 0 6px;
}

.form-group.inline {
  display: flex;
  flex-direction: column;
}

.table-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin: 6px 0;
}

.table-controls.inline {
  margin: 0;
}

.table-controls select {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  font-size: 0.8rem;
}

/* Table */

.table-wrapper {
  background: #ffffff;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead {
  background: #fafafa;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid #f0f0f3;
  text-align: left;
}

th {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #555;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:nth-child(even) td {
  background: #fcfcfc;
}

tbody tr:hover td {
  background: #f9f9ff;
}

/* Pagination */

.pagination {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

/* Incentive summary */

.incentive-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-bottom: 10px;
}

.highlight-number {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 6px 0 0;
}

/* LINKS */

a {
  color: var(--brand-dark);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
}

/* RESPONSIVE */

@media (max-width: 900px) {
  .main-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-right: none;
    border-bottom: 1px solid var(--border-soft);
  }

  .sidebar-section-title {
    width: 100%;
  }

  .tab-button {
    flex: 1 1 calc(25% - 6px);
  }

  .welcome-card {
    flex-direction: column;
  }

  .welcome-right {
    text-align: left;
  }

  .topbar-right {
    gap: 6px;
  }
}

@media (max-width: 600px) {
  .content-area {
    padding: 14px 10px 18px;
  }

  .tab-button {
    flex: 1 1 calc(50% - 6px);
  }

  th,
  td {
    padding: 7px 6px;
  }
}
