:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #172033;
  --muted: #667085;
  --line: #dfe5ec;
  --primary: #155eef;
  --primary-dark: #0b4bd4;
  --success: #079455;
  --warning: #dc6803;
  --danger: #d92d20;
  --info: #1570ef;
  --sidebar: #0f172a;
  --sidebar-muted: #94a3b8;
  --radius: 16px;
  --shadow: 0 12px 32px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }
.container { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }
.narrow { width: min(780px, calc(100% - 32px)); margin-inline: auto; }
.text-right { text-align: right; }
.text-link { color: var(--primary); font-weight: 700; }
.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--primary);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 750;
  transition: .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.button-light { background: #fff; color: #0f172a; }
.button-outline-light { color: #fff; border-color: rgba(255,255,255,.5); background: transparent; }
.button-danger { background: var(--danger); color: #fff; }
.button-sm { min-height: 34px; padding: 7px 11px; font-size: .86rem; }
.button-lg { min-height: 50px; padding: 13px 20px; border-radius: 12px; }
.button-block { width: 100%; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 252px;
  padding: 22px 16px;
  background: var(--sidebar);
  color: #fff;
  z-index: 40;
  overflow-y: auto;
}
.sidebar-brand, .brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
}
.sidebar-brand { margin: 0 10px 28px; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: #fff;
  font-weight: 900;
}
.sidebar-brand small, .brand small {
  display: block;
  color: var(--sidebar-muted);
  font-size: .72rem;
}
.sidebar-nav { display: grid; gap: 5px; }
.sidebar-nav a {
  padding: 11px 12px;
  border-radius: 10px;
  color: #dbeafe;
  font-weight: 650;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); }
.nav-section {
  margin: 18px 12px 6px;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .68rem;
  font-weight: 800;
}

.app-main { width: calc(100% - 252px); margin-left: 252px; min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.icon-button {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}
.topbar-title { display: grid; }
.topbar-title span { color: var(--muted); font-size: .8rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-badge {
  padding: 8px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: .86rem;
  font-weight: 700;
}
.app-content { padding: 28px; }
.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .85rem;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 22px;
}
.page-header h1 { margin: 0 0 6px; font-size: clamp(1.65rem, 2.6vw, 2.25rem); }
.page-header p { margin: 0; color: var(--muted); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 18px; }
.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.card-header h2 { margin: 0 0 5px; font-size: 1.1rem; }
.card-header p { margin: 0; color: var(--muted); font-size: .92rem; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.kpi-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.kpi-card small { display: block; color: var(--muted); margin-bottom: 10px; }
.kpi-card strong { display: block; font-size: 1.8rem; margin-bottom: 5px; }
.kpi-card span { color: var(--success); font-size: .82rem; font-weight: 700; }

.content-grid {
  display: grid;
  grid-template-columns: 1.35fr .9fr;
  gap: 18px;
}
.quick-actions { display: grid; gap: 10px; }
.quick-actions a {
  display: grid;
  gap: 3px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.quick-actions a:hover { border-color: #b3c8f5; background: #f8fbff; }
.quick-actions span { color: var(--muted); font-size: .86rem; }
.status-list { display: grid; gap: 8px; }
.status-list div {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
td small { display: block; color: var(--muted); margin-top: 3px; }
.status {
  display: inline-flex;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 800;
}
.status-success { color: #067647; background: #ecfdf3; }
.status-info { color: #175cd3; background: #eff8ff; }
.status-warning { color: #b54708; background: #fffaeb; }
.status-danger { color: #b42318; background: #fef3f2; }

.toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.search-form { display: flex; gap: 8px; width: min(520px,100%); }
.search-form input { flex: 1; }
.form-grid, .filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 16px;
}
.filter-grid { grid-template-columns: repeat(4, minmax(0,1fr)); align-items: end; margin-bottom: 20px; }
label { display: grid; gap: 7px; font-size: .88rem; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21,94,239,.12);
}
.field-span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; }
.checkbox-row input { width: 18px; min-height: 18px; }
.dropzone {
  min-height: 190px;
  place-items: center;
  align-content: center;
  text-align: center;
  border: 2px dashed #b9c7d8;
  border-radius: 14px;
  background: #f8fafc;
  cursor: pointer;
}
.dropzone input { max-width: 360px; }
.dropzone span { color: var(--muted); font-weight: 500; }
.upload-card form { display: grid; gap: 16px; }

.flash-stack { display: grid; gap: 10px; margin: 16px auto; width: min(1180px, calc(100% - 32px)); }
.app-content > .flash-stack { width: 100%; margin-top: 0; }
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.flash-success { border-color: #abefc6; background: #ecfdf3; }
.flash-danger, .flash-error { border-color: #fecdca; background: #fef3f2; }
.flash-warning { border-color: #fedf89; background: #fffaeb; }
.flash button { border: 0; background: transparent; font-size: 1.2rem; cursor: pointer; }

.breadcrumbs { display: flex; gap: 8px; margin-bottom: 18px; color: var(--muted); font-size: .84rem; }
.pagination { display: flex; justify-content: center; gap: 18px; align-items: center; padding-top: 18px; }
.empty-state { padding: 34px !important; text-align: center !important; color: var(--muted); }
.empty-state-panel { text-align: center; padding: 38px 20px; }
.empty-icon { font-size: 2rem; color: var(--muted); }
.notice { padding: 14px; border-radius: 10px; background: #fffaeb; color: #92400e; }

.confirm-dialog { width: min(430px, calc(100% - 32px)); border: 0; border-radius: 16px; box-shadow: 0 24px 80px rgba(15,23,42,.25); }
.confirm-dialog::backdrop { background: rgba(15,23,42,.55); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.auth-section {
  min-height: calc(100vh - 76px);
  display: grid;
  place-items: center;
  padding: 48px 16px;
  background:
    radial-gradient(circle at 10% 10%, rgba(37,99,235,.14), transparent 35%),
    radial-gradient(circle at 90% 80%, rgba(14,165,233,.12), transparent 30%),
    #f8fafc;
}
.auth-card {
  width: min(900px, 100%);
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 30px 80px rgba(15,23,42,.12);
}
.auth-card-small { grid-template-columns: 1fr; max-width: 520px; }
.auth-intro { padding: 42px; background: #0f172a; color: #fff; }
.auth-intro .brand { margin-bottom: 38px; }
.auth-intro h1 { margin: 0 0 12px; font-size: 2rem; }
.auth-intro p { color: #cbd5e1; line-height: 1.7; }
.auth-form { padding: 42px; display: grid; gap: 16px; align-content: center; }

.error-page { min-height: 70vh; display: grid; place-items: center; text-align: center; padding: 60px 0; }
.error-page span { font-size: 5rem; font-weight: 900; color: var(--primary); }
.error-page h1 { margin: 0 0 10px; }

@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .content-grid { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .app-main { width: 100%; margin-left: 0; }
  .icon-button { display: inline-grid; place-items: center; }
  .app-content { padding: 20px 16px; }
  .topbar { padding-inline: 16px; }
  .user-badge { display: none; }
  .page-header { flex-direction: column; }
  .kpi-grid, .form-grid, .filter-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .auth-card { grid-template-columns: 1fr; }
  .auth-intro, .auth-form { padding: 28px; }
  .app-footer { flex-direction: column; padding-inline: 16px; }
}
