:root {
  --red: #E31E24;
  --red-dark: #B0161B;
  --black: #191919;
  --gray-900: #2b2b2b;
  --gray-600: #6b6b6b;
  --gray-300: #d8d8d8;
  --gray-100: #f4f4f4;
  --white: #ffffff;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(0,0,0,0.08);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.app-header {
  background: var(--black);
  padding: 14px 24px;
  border-bottom: 4px solid var(--red);
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1200px;
  margin: 0 auto;
}
.brand-logo {
  height: 44px;
  width: auto;
  background: white;
  border-radius: 6px;
  padding: 4px 8px;
}
.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand-title {
  font-family: "Barlow Condensed", sans-serif;
  font-weight: 700;
  font-size: 26px;
  letter-spacing: 0.5px;
  color: var(--white);
  text-transform: uppercase;
}
.brand-subtitle {
  font-size: 12.5px;
  color: #bdbdbd;
}

/* ---------- Layout ---------- */
.app-body {
  flex: 1;
  display: flex;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  gap: 24px;
  padding: 20px 20px 40px;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-900);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--gray-300); }
.nav-item.active {
  background: var(--red);
  color: var(--white);
  font-weight: 600;
}
.nav-icon { font-size: 16px; }

.content {
  flex: 1;
  min-width: 0;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.content-header h1 {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 30px;
  margin: 0 0 4px;
  letter-spacing: 0.3px;
}
.muted { color: var(--gray-600); font-size: 13.5px; margin: 0; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary {
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
.btn-primary {
  background: var(--red);
  color: var(--white);
}
.btn-primary:hover { background: var(--red-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  background: var(--gray-300);
  color: var(--gray-900);
}
.btn-secondary:hover { background: #c7c7c7; }

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--gray-300); }
.icon-btn.danger:hover { background: #fbdada; }

/* ---------- Table ---------- */
.table-wrap {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: var(--gray-100);
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
  border-bottom: 2px solid var(--gray-300);
}
tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--gray-300);
  white-space: nowrap;
}
tbody tr:hover { background: #fafafa; }
.col-formula { color: var(--red-dark); font-weight: 600; }
.col-actions { text-align: right; white-space: nowrap; }

.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--gray-600);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 14px;
}

/* ---------- Footer ---------- */
.app-footer {
  background: var(--black);
  color: #bdbdbd;
  font-size: 12.5px;
  padding: 14px 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px solid #333;
}
.app-footer a {
  color: var(--red);
  text-decoration: none;
  font-weight: 600;
}
.app-footer a:hover { text-decoration: underline; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-300);
}
.modal-header h2 {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 20px;
  margin: 0;
}
.modal-form {
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--gray-900); }
.form-field input, .form-field select, .form-field textarea {
  border: 1px solid var(--gray-300);
  border-radius: 7px;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: 2px solid var(--red);
  outline-offset: 1px;
}
.form-field small { color: var(--gray-600); font-size: 11.5px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--gray-300);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--black);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red-dark); }

/* ---------- Responsive ---------- */
@media (max-width: 800px) {
  .app-body { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .nav-item { flex-shrink: 0; }
  .brand-title { font-size: 22px; }
}
