@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f4f5f7;
  --ink: #1a1a1a;
  --ink-light: #2d2d2d;
  --accent: #1a1a1a;
  --accent-hover: #333333;
  --border: #e0e0e0;
  --border-light: #ebebeb;
  --card: #ffffff;
  --muted: #6b7280;
  --surface: #f9fafb;
  --green: #15803d;
  --green-bg: #dcfce7;
  --amber: #a16207;
  --amber-bg: #fef3c7;
  --red: #991b1b;
  --red-bg: #fee2e2;
  --neutral: #4b5563;
  --neutral-bg: #f3f4f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* --- Loading screen --- */
.page-loading {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.97);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.page-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.page-loading-inner {
  text-align: center;
  max-width: 520px;
  padding: 32px 36px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.page-loading-title {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.page-loading-sub {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* --- Top bar --- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: #ffffff;
  color: var(--ink);
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}

a.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  height: 120px;
  width: auto;
}

.title {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.role {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.role label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.role select {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.85rem;
  background: var(--surface);
}

.role button {
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.role button:hover {
  background: var(--accent-hover);
}

/* --- Status badges --- */
.status-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.status {
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--neutral-bg);
  color: var(--neutral);
  border: 1px solid var(--border);
  letter-spacing: 0.01em;
}

.status.ok {
  background: var(--green-bg);
  color: var(--green);
  border-color: #bbf7d0;
}

.status.warn {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: #fde68a;
}

.status.bad {
  background: var(--red-bg);
  color: var(--red);
  border-color: #fecaca;
}

/* --- User info --- */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-badge {
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* --- Navigation --- */
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  padding: 0 2rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav a:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* --- Main content --- */
.content {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

/* --- Hero --- */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.hero h1 {
  margin: 0 0 0.3rem 0;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
}

/* --- Cards --- */
.card {
  background: var(--card);
  padding: 1.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  margin-bottom: 1.5rem;
}

/* --- Grid --- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.grid.summary {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* --- Forms --- */
label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.88rem;
}

input, select, textarea {
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 2px rgba(26, 26, 26, 0.08);
}

textarea {
  min-height: 90px;
}

/* --- Buttons --- */
.button {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  background: var(--ink);
  color: #ffffff;
  text-decoration: none;
  border: 1px solid var(--ink);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
  transition: background 0.15s, box-shadow 0.15s;
}

.button:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.button.secondary {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--ink);
}

.button.secondary:hover {
  background: var(--surface);
  border-color: var(--ink);
}

/* --- Alerts --- */
.alert {
  padding: 0.85rem 1rem;
  background: var(--red-bg);
  border: 1px solid #fecaca;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--red);
  font-weight: 500;
}

.muted {
  color: var(--muted);
}

.note {
  background: var(--surface);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  font-size: 0.9rem;
}

/* --- Pills --- */
.pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.01em;
}

.pill.financial_assistance {
  background: var(--green-bg);
  color: var(--green);
}

.pill.free_goods {
  background: var(--amber-bg);
  color: var(--amber);
}

.pill.free_goods_compliance_review {
  background: var(--red-bg);
  color: var(--red);
}

.pill.reject {
  background: var(--neutral-bg);
  color: var(--neutral);
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 2px solid var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
}

tr:hover td {
  background: var(--surface);
}

/* --- Chat --- */
.chat {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-input {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

/* --- Responsive --- */
@media (max-width: 700px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
  }

  .nav {
    padding: 0 1rem;
    gap: 0;
  }

  .content {
    padding: 1.5rem 1rem;
  }
}
