:root {
  --ink: #172033;
  --muted: #667085;
  --line: #e4e7ec;
  --surface: #ffffff;
  --canvas: #f4f6f8;
  --brand: #4f46e5;
  --brand-dark: #3730a3;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.10);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  min-height: 100vh;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.page-shell { min-height: calc(100vh - 48px); }
.login-layout {
  min-height: calc(100vh - 48px);
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(360px, .85fr);
}
.brand-panel {
  padding: clamp(36px, 6vw, 84px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 30px;
  background: linear-gradient(145deg, #ffffff 0%, #eef1ff 100%);
}
.brand-logo { width: min(280px, 72%); height: auto; }
.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: .75rem;
  font-weight: 800;
  color: var(--brand);
}
h1, h2 { margin: 0; line-height: 1.15; }
h1 { font-size: clamp(2rem, 5vw, 4rem); max-width: 720px; }
h2 { font-size: clamp(1.5rem, 3vw, 2.15rem); }
.lead { max-width: 650px; font-size: 1.1rem; line-height: 1.65; color: var(--muted); }
.muted { color: var(--muted); margin: 8px 0 0; line-height: 1.55; }
.demo-box {
  display: grid;
  gap: 8px;
  width: fit-content;
  padding: 16px 18px;
  border: 1px solid #c7d2fe;
  background: rgba(255,255,255,.72);
  border-radius: 14px;
}
code { background: #eef2ff; padding: 2px 6px; border-radius: 6px; }

.login-card {
  align-self: center;
  justify-self: center;
  width: min(440px, calc(100% - 40px));
  background: var(--surface);
  padding: 38px;
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.mobile-logo-wrap { display: none; }
form label {
  display: block;
  margin: 18px 0 7px;
  font-weight: 700;
  font-size: .9rem;
}
input, select {
  width: 100%;
  border: 1px solid #d0d5dd;
  background: white;
  border-radius: 10px;
  padding: 12px 13px;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(79,70,229,.12);
}
.primary-btn, .secondary-btn, .ghost-btn, .danger-ghost-btn {
  border-radius: 10px;
  padding: 11px 16px;
  border: 1px solid transparent;
  font-weight: 800;
}
.primary-btn { background: var(--brand); color: white; }
.primary-btn:hover { background: var(--brand-dark); }
.link-btn { border: 0; background: transparent; color: var(--brand); font-weight: 800; }
.secondary-btn { background: white; color: var(--ink); border-color: #d0d5dd; }
.ghost-btn { background: transparent; color: white; border-color: rgba(255,255,255,.4); }
.danger-ghost-btn { background: white; color: var(--danger); border-color: #fecdca; }
.full-width { width: 100%; margin-top: 24px; }
.form-error { color: var(--danger); font-weight: 700; margin-bottom: 0; }

.app-layout { min-height: calc(100vh - 48px); }
.topbar {
  min-height: 74px;
  padding: 12px clamp(18px, 4vw, 54px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #111827;
  color: white;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand img { width: 56px; height: 42px; object-fit: contain; background: white; border-radius: 8px; padding: 4px; }
.topbar-brand div { display: grid; }
.topbar-brand span { color: #cbd5e1; font-size: .82rem; text-transform: capitalize; }

.content { width: min(1180px, calc(100% - 32px)); margin: 28px auto 50px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; }
.tab {
  background: transparent;
  border: 0;
  padding: 10px 14px;
  border-radius: 9px;
  font-weight: 800;
  white-space: nowrap;
}
.tab.active { background: #e0e7ff; color: var(--brand-dark); }
.panel {
  background: var(--surface);
  border-radius: 18px;
  padding: clamp(20px, 3vw, 34px);
  box-shadow: 0 10px 32px rgba(16,24,40,.07);
}
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 25px;
}
.stat-card {
  min-width: 150px;
  padding: 16px 20px;
  border-radius: 14px;
  background: #eef2ff;
  display: grid;
}
.stat-card span { color: var(--muted); font-size: .85rem; }
.stat-card strong { font-size: 1.8rem; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.search-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr) auto auto;
  align-items: end;
  gap: 12px;
}
.search-grid label, .form-grid label { margin-top: 0; }
.search-summary { color: var(--muted); min-height: 24px; margin: 22px 0 8px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: #f9fafb; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: #475467; }
tr:last-child td { border-bottom: 0; }
.empty-row { text-align: center; color: var(--muted); padding: 28px; }
.action-btn {
  border: 0;
  background: transparent;
  color: var(--brand);
  padding: 5px 7px;
  font-weight: 800;
}
.action-btn.danger { color: var(--danger); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  align-items: end;
  padding: 18px;
  background: #f9fafb;
  border-radius: 14px;
  margin-bottom: 18px;
}
.compact-form { grid-template-columns: 1fr 1fr 1fr auto; }
.form-actions { display: flex; gap: 8px; }
.csv-note { color: var(--muted); font-size: .9rem; }
.list-tools {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 18px 0 12px;
}
.list-tools label { display: block; margin: 0 0 7px; font-weight: 700; font-size: .9rem; }
.list-tools select { min-width: 170px; }
.list-tools .muted { margin: 0 0 11px; }
.sort-btn, .search-sort-btn {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  font-weight: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.sort-btn:hover, .sort-btn.active, .search-sort-btn:hover, .search-sort-btn.active { color: var(--brand-dark); }
.sort-btn span, .search-sort-btn span { display: inline-block; min-width: 12px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: 10px;
  background: #101828;
  color: white;
  box-shadow: var(--shadow);
  transform: translateY(120px);
  opacity: 0;
  transition: .25s ease;
  z-index: 20;
}
.toast.show { transform: translateY(0); opacity: 1; }
.footer { height: 48px; display: grid; place-items: center; color: var(--muted); font-size: .82rem; }

@media (max-width: 900px) {
  .login-layout { grid-template-columns: 1fr; }
  .brand-panel { display: none; }
  .login-card { margin: 36px auto; }
  .mobile-logo-wrap { display: block; text-align: center; margin-bottom: 20px; }
  .mobile-logo { width: 170px; }
  .search-grid { grid-template-columns: 1fr 1fr; }
  .form-grid, .compact-form { grid-template-columns: 1fr 1fr; }
  .section-heading { flex-direction: column; }
}
@media (max-width: 560px) {
  .login-card { padding: 26px 22px; }
  .search-grid, .form-grid, .compact-form { grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; }
  .topbar-brand strong { font-size: .92rem; }
  .content { width: min(100% - 18px, 1180px); margin-top: 14px; }
  .panel { padding: 18px 14px; }
}
