:root {
  color-scheme: light;
  --primary: #0f172a;
  --secondary: #1e3a8a;
  --accent: #a16207;
  --background: #f8fafc;
  --surface: #ffffff;
  --text: #020617;
  --muted: #475569;
  --border: #e2e8f0;
  --soft: #f1f5f9;
  --success: #166534;
  --success-bg: #f0fdf4;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --focus: #2563eb;
  font-family: "IBM Plex Sans", "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--background);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--secondary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

button,
.button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 15px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

button:hover,
.button:hover {
  background: var(--secondary);
  color: #fff;
  text-decoration: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

:focus-visible {
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 5;
  display: flex;
  width: 236px;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 24px 16px 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--primary);
}

.brand-logo {
  display: block;
  flex: 0 0 auto;
  width: 72px;
  height: auto;
  object-fit: contain;
}

.brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.brand-name {
  color: var(--primary);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
}

.brand-slogan {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
}

.brand-sidebar {
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
}

.brand-sidebar .brand-logo {
  width: 110px;
}

.brand-auth {
  align-items: flex-start;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}

.brand-auth .brand-logo {
  width: 145px;
}

.brand-auth .brand-name {
  font-size: 20px;
}

.side-nav,
.mobile-nav {
  display: grid;
  gap: 5px;
}

.side-nav {
  margin-top: 34px;
}

.side-nav a,
.mobile-nav a {
  display: block;
  border-radius: 6px;
  padding: 10px 12px;
  color: #334155;
  font-weight: 500;
}

.side-nav a:hover,
.mobile-nav a:hover {
  background: var(--soft);
  color: var(--primary);
  text-decoration: none;
}

.sidebar-user {
  display: grid;
  gap: 8px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 16px 8px 0;
  color: var(--muted);
  font-size: 13px;
}

.user-name {
  overflow-wrap: anywhere;
  color: var(--text);
  font-weight: 600;
}

.role-pill {
  width: fit-content;
  border-radius: 999px;
  background: #eff6ff;
  padding: 3px 9px;
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 600;
}

.link-button {
  min-height: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--secondary);
  font-weight: 500;
  text-align: left;
}

.link-button:hover {
  background: transparent;
  color: var(--primary);
  text-decoration: underline;
}

.main-column {
  min-height: 100vh;
  margin-left: 236px;
}

.page-content {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 34px 38px 56px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-heading h1 {
  margin: 0;
  color: var(--primary);
  font-size: clamp(24px, 3vw, 31px);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mobile-header {
  display: none;
}

.panel,
.stat-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.panel {
  margin-bottom: 20px;
  padding: 22px;
}

.panel h2 {
  margin: 0 0 16px;
  color: var(--primary);
  font-size: 17px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  min-width: 0;
  padding: 18px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  display: block;
  margin-top: 8px;
  color: var(--primary);
  font-size: clamp(20px, 2vw, 27px);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

.filters {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
}

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
}

.field label {
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #fff;
  padding: 9px 11px;
  color: var(--text);
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--focus);
  outline: 3px solid #dbeafe;
  outline-offset: 0;
}

.field-hint,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.form-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.span-all {
  grid-column: 1 / -1;
}

.auth-title {
  margin-top: 24px !important;
}

.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: #cbd5e1;
  background: #fff;
  color: var(--primary);
}

.button-secondary:hover {
  border-color: #94a3b8;
  background: var(--soft);
  color: var(--primary);
}

.button-small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 13px;
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

td {
  color: #1e293b;
  font-size: 14px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.number {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.flash {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 10px 13px;
}

.flash-success {
  border-color: #bbf7d0;
  background: var(--success-bg);
  color: var(--success);
}

.flash-error {
  border-color: #fecaca;
  background: var(--danger-bg);
  color: var(--danger);
}

.empty-state {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.pagination-links {
  display: flex;
  gap: 8px;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  align-content: center;
  justify-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, calc(100vw - 48px));
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 30px;
}

.auth-card h1 {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 25px;
}

.auth-card .form-stack {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

.auth-card button {
  width: 100%;
}

.mobile-menu {
  position: relative;
}

.mobile-menu summary {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 12px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.mobile-menu summary::-webkit-details-marker {
  display: none;
}

.mobile-menu[open] summary {
  border-color: #94a3b8;
  background: var(--soft);
}

.mobile-menu-panel {
  position: absolute;
  z-index: 10;
  top: 48px;
  right: 0;
  width: min(280px, calc(100vw - 32px));
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: 0 8px 24px rgb(15 23 42 / 12%);
}

.mobile-nav {
  display: grid;
  gap: 4px;
}

.mobile-user {
  display: grid;
  gap: 9px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.mobile-user form {
  margin: 0;
}

.current-image {
  display: block;
  max-width: min(100%, 520px);
  max-height: 360px;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  object-fit: contain;
}

.notice {
  border-left: 3px solid var(--accent);
  background: #fffbeb;
  padding: 11px 14px;
  color: #713f12;
}

@media (max-width: 1024px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-content {
    padding-right: 24px;
    padding-left: 24px;
  }
}

@media (max-width: 760px) {
  .sidebar {
    display: none;
  }

  .main-column {
    margin-left: 0;
  }

  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 8;
    display: flex;
    min-height: 62px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: rgb(255 255 255 / 96%);
    padding: 9px 16px;
  }

  .mobile-header .brand-logo {
    width: 46px;
  }

  .mobile-header .brand-name {
    font-size: 14px;
  }

  .mobile-header .brand-slogan {
    font-size: 9px;
  }

  .page-content {
    padding: 23px 16px 42px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 13px;
    margin-bottom: 18px;
  }

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

  .stat-grid {
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
  }

  .panel {
    padding: 16px;
  }

  .mobile-nav a,
  .mobile-user a,
  .mobile-user .link-button,
  .mobile-user summary {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .mobile-user .link-button {
    padding: 0;
  }

  .mobile-user form {
    display: flex;
    align-items: center;
  }

  button,
  .button {
    min-height: 44px;
  }

  th,
  td {
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
