:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --text: #111827;
  --muted: #667085;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 8px 24px rgba(15, 23, 42, .08);
  --radius: 8px;
  --sidebar: 280px;
  --sidebar-mini: 84px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, .08), transparent 38%),
    linear-gradient(315deg, rgba(5, 150, 105, .08), transparent 42%),
    var(--bg);
}

.login-card {
  width: min(500px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 8px;
  margin-bottom: 26px;
  text-align: center;
}

.login-logo {
  display: grid;
  width: 116px;
  min-height: 92px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
  padding: 12px;
}

.login-logo img {
  max-width: 92px;
  max-height: 68px;
  object-fit: contain;
}

.login-logo span {
  display: grid;
  width: 68px;
  height: 68px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 24px;
  font-weight: 850;
}

.login-title {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 850;
  line-height: 1.1;
}

.login-subtitle {
  color: var(--muted);
  font-size: 15px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand-mark img {
  max-width: 28px;
  max-height: 28px;
  object-fit: contain;
}

.brand-logo {
  display: block;
  max-width: 168px;
  max-height: 32px;
  object-fit: contain;
}

.brand-title { font-weight: 750; line-height: 1.1; }
.brand-subtitle { color: var(--muted); font-size: 13px; margin-top: 3px; }

.form-stack { display: grid; gap: 18px; margin-top: 22px; }
.field { display: grid; gap: 7px; }
.field label { color: #344054; font-size: 13px; font-weight: 650; }

.input,
.select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d0d5dd;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 9px 12px;
  font: inherit;
  outline: none;
}

.login-card .input {
  min-height: 52px;
}

.login-card .button {
  min-height: 52px;
}

.input:focus,
.select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 8px 13px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.button:hover { background: var(--primary-strong); }
.button-secondary { background: #fff; border-color: var(--line); color: #344054; }
.button-secondary:hover { background: var(--panel-soft); }
.button-icon { width: 40px; padding: 0; }

.button-compact {
  min-height: 34px;
  padding: 6px 10px;
  gap: 6px;
  font-size: 14px;
}

.button-compact i,
.button-icon i {
  width: 18px;
  height: 18px;
}

.alert {
  margin-top: 18px;
  border-radius: var(--radius);
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  padding: 11px 13px;
  font-size: 14px;
}

.app-shell {
  min-height: 100vh;
  padding-left: var(--sidebar);
  transition: padding-left .2s ease;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fff;
  transition: width .2s ease, transform .2s ease;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: 72px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.sidebar-nav {
  display: grid;
  gap: 4px;
  padding: 14px 10px;
  overflow-y: auto;
}

.nav-link {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  min-height: 42px;
  border-radius: var(--radius);
  color: #475467;
  font-weight: 650;
}

.nav-link i {
  display: grid;
  place-items: center;
  color: #667085;
}

.nav-link:hover,
.nav-link.active {
  background: #eff6ff;
  color: #1d4ed8;
}

.nav-link.active i { color: #1d4ed8; }

.sidebar-foot {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.user-chip {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 800;
}

.sidebar-collapsed { padding-left: var(--sidebar-mini); }
.sidebar-collapsed .sidebar { width: var(--sidebar-mini); }
.sidebar-collapsed .brand-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .user-info,
.sidebar-collapsed .logout-text { display: none; }
.sidebar-collapsed .sidebar-head {
  align-items: center;
  flex-direction: column;
  height: auto;
  min-height: 112px;
  justify-content: center;
}
.sidebar-collapsed .sidebar-head .button { display: inline-flex; }
.sidebar-collapsed .nav-link { grid-template-columns: 1fr; justify-items: center; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .88);
  padding: 12px 24px;
  backdrop-filter: blur(12px);
}

.topbar-title h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.topbar-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.mobile-menu { display: none; }
.content { padding: 24px; }

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

.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.stat-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }

.panel { margin-top: 18px; overflow: hidden; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-title { margin: 0; font-size: 17px; }
.panel-body { padding: 18px; }

.filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.table-wrap { width: 100%; overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  white-space: nowrap;
}

.table th {
  background: var(--panel-soft);
  color: #475467;
  font-size: 12px;
  letter-spacing: 0;
  text-align: left;
  text-transform: uppercase;
}

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

.table tr:hover td { background: #fbfdff; }

.table tr.row-due-soon td {
  background: #fff1f2;
  color: #991b1b;
}

.table tr.row-due-soon:hover td {
  background: #ffe4e6;
}

.table tr.row-expired td {
  background: #fef2f2;
  color: #7f1d1d;
}

.table tr.row-expired:hover td {
  background: #fee2e2;
}

.muted { color: var(--muted); }
.strong { font-weight: 750; }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 750;
}

.badge-success { background: #ecfdf3; color: #027a48; }
.badge-muted { background: #f2f4f7; color: #475467; }
.badge-warning { background: #fffaeb; color: #b54708; }
.badge-danger { background: #fef3f2; color: #b42318; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.media-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.media-thumb {
  display: grid;
  height: 142px;
  place-items: center;
  background: var(--panel-soft);
}

.media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-meta { padding: 12px; }
.pagination { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.sidebar-backdrop { display: none; }

.brand-preview {
  display: grid;
  width: min(260px, 100%);
  height: 90px;
  margin-top: 10px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.brand-preview img {
  max-width: 220px;
  max-height: 70px;
  object-fit: contain;
}

.brand-preview-icon {
  width: 90px;
}

.brand-preview-icon img {
  max-width: 56px;
  max-height: 56px;
}

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

.field-full { grid-column: 1 / -1; }

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 18px;
}

.table-actions {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
}

.button-danger {
  background: #fff;
  border-color: #fecaca;
  color: var(--danger);
}

.button-danger:hover {
  background: #fef2f2;
}

.media-upload-actions {
  align-self: end;
  justify-content: end;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.detail-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
}

.detail-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-value {
  margin-top: 5px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

@media (max-width: 760px) {
  .app-shell { padding-left: 0; }
  .sidebar {
    transform: translateX(-100%);
    width: min(86vw, 300px);
  }
  .sidebar-collapsed { padding-left: 0; }
  .sidebar-collapsed .sidebar { width: min(86vw, 300px); }
  .sidebar-collapsed .brand-text,
  .sidebar-collapsed .nav-label,
  .sidebar-collapsed .user-info,
  .sidebar-collapsed .logout-text { display: block; }
  .sidebar-collapsed .nav-link { grid-template-columns: 38px minmax(0, 1fr); justify-items: stretch; }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: block;
    background: rgba(15, 23, 42, .42);
  }
  .desktop-toggle { display: none; }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .topbar-title h1 { font-size: 20px; }
  .content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr !important; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .table-actions { justify-content: flex-start; }
}
