:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #667085;
  --blue: #1f4e79;
  --blue-2: #2563eb;
  --line: #d9e2ec;
  --green: #16803c;
  --green-bg: #e7f6eb;
  --amber: #a66300;
  --amber-bg: #fff4d6;
  --red: #b42318;
  --red-bg: #ffe7e5;
  --gray-bg: #eef2f6;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Calibri, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 30rem),
    linear-gradient(180deg, #eef5ff 0%, var(--bg) 22rem);
}

body.locked .app-header,
body.locked .layout {
  display: none;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.22), transparent 34rem),
    linear-gradient(135deg, #0f253b, #1f4e79 55%, #2563eb);
}

.login-card {
  width: min(34rem, 100%);
  padding: 1.4rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 24px;
  color: white;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(18px);
}

.login-brand {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.login-brand img {
  flex: 0 0 auto;
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.login-brand h1 {
  margin-bottom: 0.25rem;
}

.login-brand p {
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.82);
}

.login-form {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
}

.login-form label {
  color: #1f2937;
}

.login-help {
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: 16px;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(0, 0, 0, 0.18);
}

.login-help p {
  margin-bottom: 0.35rem;
}

.user-badge {
  max-width: 18rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  color: white;
  background: rgba(255, 255, 255, 0.14);
  font-weight: 700;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem;
  color: white;
  background: linear-gradient(135deg, #173b5f, #1f4e79 55%, #2563eb);
}

.eyebrow {
  margin: 0 0 0.35rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.78rem;
  opacity: 0.82;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.45rem;
  font-size: clamp(1.65rem, 2.5vw, 2.45rem);
}

.subtitle {
  max-width: 52rem;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.86);
}

.header-actions,
.inline-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.layout {
  display: grid;
  grid-template-columns: 16rem minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1.25rem;
}

.sidebar {
  position: sticky;
  top: 1.25rem;
  align-self: start;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.nav-btn {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 0;
  border-radius: 13px;
  color: #314155;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav-btn:hover {
  background: #eef5ff;
}

.nav-btn.active {
  color: white;
  background: var(--blue);
}

.content {
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.section-title h2 {
  margin-bottom: 0.25rem;
  color: #142b44;
}

.section-title p,
.panel-header p,
.note {
  color: var(--muted);
}

.panel {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 0.75rem;
}

.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(10rem, 1fr));
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  box-shadow: var(--shadow);
}

.card.clickable {
  cursor: pointer;
}

.card.clickable:hover {
  transform: translateY(-2px);
}

.card.active-filter {
  outline: 3px solid rgba(37, 99, 235, 0.35);
}

.card p {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.card strong {
  display: block;
  font-size: 1.9rem;
  line-height: 1.1;
}

.card small {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
}

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

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

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

.card.blue {
  border-color: #bfdbfe;
  background: #e8f1ff;
}

.btn,
.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.45rem;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn:hover,
.file-btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  color: white;
  background: var(--blue-2);
}

.btn-secondary,
.file-btn {
  color: var(--blue);
  border-color: #bfdbfe;
  background: white;
}

.btn-danger {
  color: white;
  background: var(--red);
}

.file-btn input {
  display: none;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 52rem;
}

th,
td {
  padding: 0.72rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: white;
  background: var(--blue);
  white-space: nowrap;
}

tr:hover td {
  background: #f8fbff;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.65rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

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

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

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

.badge.gray {
  color: #475467;
  background: var(--gray-bg);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.9rem;
}

.dashboard-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(10rem, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.filter-actions {
  display: flex;
  align-items: end;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(18rem, 0.85fr);
  gap: 1rem;
}

.bar-chart {
  display: grid;
  gap: 0.75rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 6rem minmax(8rem, 1fr) 5rem;
  gap: 0.65rem;
  align-items: center;
}

.bar-label {
  font-weight: 800;
}

.bar-track {
  height: 1rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e5eaf1;
}

.bar-fill {
  height: 100%;
  min-width: 0.25rem;
  border-radius: inherit;
  background: linear-gradient(90deg, #16a34a, #2563eb);
}

.bar-fill.warning {
  background: linear-gradient(90deg, #f59e0b, #dc2626);
}

.bar-value {
  color: var(--muted);
  text-align: right;
}

.recent-list {
  display: grid;
  gap: 0.65rem;
}

.recent-item {
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbff;
}

.recent-item strong {
  display: block;
}

.recent-item small {
  color: var(--muted);
}

.permissions-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(12rem, 1fr));
  gap: 0.85rem;
}

.permissions-grid .panel {
  margin-bottom: 0;
}

label {
  display: grid;
  gap: 0.35rem;
  color: #344054;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.72rem 0.8rem;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  color: var(--text);
  background: white;
}

textarea {
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

.row-actions {
  display: flex;
  gap: 0.4rem;
}

.mini-btn {
  padding: 0.35rem 0.55rem;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  color: #334155;
  background: white;
  cursor: pointer;
}

.mini-btn.danger {
  color: var(--red);
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: none;
  max-width: min(28rem, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  border-radius: 14px;
  color: white;
  background: #111827;
  box-shadow: var(--shadow);
}

.toast.show {
  display: block;
}

.note {
  margin-top: 1rem;
  margin-bottom: 0;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .cards {
    grid-template-columns: repeat(2, minmax(10rem, 1fr));
  }

  .dashboard-filters,
  .dashboard-grid,
  .permissions-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-header,
  .section-title,
  .panel-header {
    flex-direction: column;
  }

  .layout {
    padding: 0.75rem;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .cards,
  .form-grid,
  .dashboard-filters {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }
}
