/* Shared Admin UI Theme */
:root {
  --primary: #5C89C1;
  --primary-dark: #233B68;
  --primary-hover: #3164c2;
  --bg-white: #FFFFFF;
  --text-dark: #111827;
  --text-secondary: #4B5563;
  --border: #E5E7EB;
  --danger: #EF4444;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  --page-bg: #FFFFFF;
  --soft-bg: #F8FAFC;
}

* {
  box-sizing: border-box;
}

body {
  --primary: #5C89C1;
  --primary-dark: #233B68;
  --primary-hover: #3164c2;
  --bg-white: #FFFFFF;
  --text-dark: #111827;
  --text-secondary: #4B5563;
  --border: #E5E7EB;
  --danger: #EF4444;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --radius: 16px;
  margin: 0;
  background: var(--page-bg) !important;
  color: var(--text-dark) !important;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a {
  color: var(--primary);
}

.admin-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg-white);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: 8px 0 28px rgba(35, 59, 104, 0.18);
  overflow-y: auto;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  margin-bottom: 14px;
}

.admin-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  padding: 4px;
}

.admin-brand strong {
  display: block;
  color: #fff;
  font-size: 16px;
  line-height: 1.2;
}

.admin-brand span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}

.admin-nav-title {
  margin: 18px 10px 8px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  margin: 5px 0;
  color: #fff;
  text-decoration: none;
  border-radius: 12px;
  font-weight: 650;
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}

.admin-nav a:hover,
.admin-nav a.active {
  background: var(--primary-hover);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.10);
  transform: translateX(2px);
}

.admin-nav a.logout,
.logout {
  background: #F43F5E;
  color: #fff;
}

.admin-nav a.logout:hover,
.logout:hover {
  background: var(--danger);
}

.admin-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-white);
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 26px;
  background: linear-gradient(90deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  box-shadow: 0 8px 24px rgba(35, 59, 104, 0.18);
}

.admin-topbar-title {
  color: #fff;
  font-size: 20px;
  font-weight: 800;
}

.admin-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  text-align: right;
}

.admin-avatar {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-weight: 800;
}

.admin-content {
  width: 100%;
  padding: 26px;
}

.master-wrap,
.wrapper {
  width: 100% !important;
  max-width: 1400px !important;
  margin: 0 auto !important;
  padding: 0 !important;
  background: transparent !important;
  color: var(--text-dark) !important;
}

/* .headbar,
.topbar {
  background: transparent !important;
  color: var(--text-dark) !important;
  margin-bottom: 22px !important;
  padding: 0 !important;
  border: 0 !important;
  box-shadow: none !important;
} */

h1,
h2,
h3,
.dash-title,
.section-label,
.section-title,
.card-title,
.action-title {
  color: var(--text-dark) !important;
  letter-spacing: 0;
}

.muted,
.dash-sub,
.section-sub,
.todayline,
.text-muted,
.action-desc,
.mini-card .label,
.metric .k,
.kv-label,
.followup-title {
  color: var(--text-secondary) !important;
}

.card,
.panel,
.mini-card,
.action-card,
.followup-card,
.metric,
.kv-row {
  background: var(--bg-white) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  color: var(--text-dark) !important;
  box-shadow: var(--shadow) !important;
}

.card,
.panel,
.action-card {
  padding: 20px !important;
}

.mini-card {
  min-height: 116px;
  padding: 20px !important;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.mini-card:hover,
.action-card:hover,
.followup-card:hover,
.kpi-card:hover {
  transform: translateY(-3px);
  border-color: rgba(47, 79, 136, .35) !important;
  box-shadow: 0 8px 28px rgba(47, 79, 136, .14) !important;
}

.mini-card .value,
.card-value,
.metric .v,
.kv-value {
  color: var(--text-dark) !important;
  font-weight: 850;
}

.card-value,
.mini-card .value {
  font-size: clamp(28px, 4vw, 38px) !important;
}

.grid,
.grid-2,
.grid-5,
.kpi-grid,
.button-grid {
  gap: 18px !important;
}

.btn,
button,
.action-btn,
.btn-link,
.actions a {
  border-radius: 12px !important;
  transition: background .18s ease, transform .18s ease, box-shadow .18s ease;
}

.btn,
.action-btn,
.btn.primary,
.range-buttons button,
.actions a,
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 16px !important;
  border: 1px solid transparent !important;
  background: var(--primary) !important;
  color: #fff !important;
  font-weight: 750;
  text-decoration: none !important;
  cursor: pointer;
}

.btn:hover,
button:hover,
.action-btn:hover,
.btn-link:hover,
.actions a:hover,
.range-buttons button:hover,
.range-buttons button.active-filter {
  background: var(--primary-hover) !important;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(47, 79, 136, .22);
}

.btn.danger,
.btn.red,
.danger,
.btn-delete {
  background: var(--danger) !important;
  color: #fff !important;
}

.btn.secondary,
.btn.gray {
  background: #6B7280 !important;
  color: #fff !important;
}

.filter-bar {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

label,
.filter-bar label {
  color: var(--text-secondary) !important;
  font-weight: 650;
}

.inp,
.control,
input,
select,
textarea,
.filter-bar input {
  border: 1px solid var(--border) !important;
  background: var(--bg-white) !important;
  color: var(--text-dark) !important;
  border-radius: 12px !important;
  outline: none;
}

.inp,
input,
select,
textarea {
  padding: 10px 12px;
}

.inp:focus,
.control:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(47, 79, 136, .14) !important;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-white);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-white);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dark) !important;
  text-align: left;
  vertical-align: middle;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #F9FAFB !important;
  color: var(--text-dark) !important;
  font-weight: 800;
}

tbody tr:hover {
  background: #F8FAFC;
}

.badge {
  display: inline-block;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.badge.active,
.on {
  background: #DCFCE7;
  color: #166534;
}

.badge.inactive,
.off {
  background: #FEE2E2;
  color: #991B1B;
}

.followup-value {
  background: var(--primary) !important;
  color: #fff !important;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px !important;
}

@media (max-width: 1100px) {
  .admin-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .admin-content {
    padding: 22px;
  }
}

@media (max-width: 820px) {
  .admin-shell {
    display: block;
  }

  .admin-sidebar {
    position: relative;
    height: auto;
    border-radius: 0 0 18px 18px;
  }

  .admin-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .admin-nav-title {
    grid-column: 1 / -1;
  }

  .admin-topbar {
    position: relative;
    padding: 14px 18px;
    align-items: flex-start;
  }

  .admin-content {
    padding: 18px;
  }

  .topbar,
  .headbar {
    flex-direction: column;
    align-items: stretch !important;
  }

  .filter-bar,
  .range-buttons {
    justify-content: flex-start !important;
  }
}

@media (max-width: 560px) {
  .admin-nav {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    flex-direction: column;
  }

  .admin-profile {
    text-align: left;
  }

  .admin-content {
    padding: 14px;
  }

  .grid-5,
  .kpi-grid,
  .button-grid {
    grid-template-columns: 1fr !important;
  }

  .filter-bar>*,
  .filter-bar input,
  .filter-bar .btn,
  .range-buttons a,
  .range-buttons button {
    width: 100%;
  }
}

@media (max-width: 820px) {
  body {
    overflow-x: hidden;
  }

  .master-wrap,
  .wrapper {
    max-width: 100% !important;
  }

  .card,
  .panel,
  .action-card {
    padding: 16px !important;
  }

  .toolbar,
  .search,
  .master-search,
  .poster-filters,
  .card-head,
  .header-actions {
    flex-wrap: wrap !important;
    align-items: stretch !important;
    gap: 10px !important;
  }

  .toolbar,
  .card-head {
    flex-direction: column !important;
  }

  .toolbar .right,
  .header-actions,
  .poster-filters,
  .search,
  .master-search {
    width: 100% !important;
    margin-left: 0 !important;
  }

  .inp,
  .control,
  input,
  select,
  textarea,
  .poster-filters .inp,
  .master-search .inp {
    max-width: 100% !important;
  }

  form[style*="grid-template-columns:1fr 1fr"],
  form[style*="grid-template-columns: 1fr 1fr"],
  form[style*="grid-template-columns:repeat(2"],
  form[style*="grid-template-columns: repeat(2"],
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .table-wrap {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table,
  .table-wrap .table {
    min-width: 720px;
  }

  .master-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important;
    padding: 0 !important;
  }

  .master-title {
    white-space: normal !important;
  }

  .master-wrap img {
    max-width: 100%;
    height: auto;
  }

  .master-wrap .table .t-head,
  .master-wrap .table .t-row {
    min-width: 860px;
  }
}

@media (max-width: 560px) {
  .card,
  .panel,
  .action-card {
    padding: 14px !important;
  }

  h1,
  h2,
  h3,
  .dash-title,
  .section-title,
  .card-title,
  .action-title {
    line-height: 1.25;
    word-break: break-word;
  }

  .toolbar .btn,
  .toolbar button,
  .toolbar a,
  .search .btn,
  .search button,
  .search a,
  .master-search .btn,
  .master-search button,
  .poster-filters .btn,
  .poster-filters button,
  .poster-filters a,
  .header-actions .btn,
  .header-actions button,
  .header-actions a {
    width: 100%;
  }

  .inp,
  .control,
  input,
  select,
  textarea,
  .poster-filters .inp,
  .master-search .inp {
    width: 100% !important;
    min-width: 0 !important;
  }

  .badge {
    white-space: normal;
  }
}

/* Operations mobile responsiveness */
@media (max-width: 768px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    font-size: 14px;
    line-height: 1.45;
  }

  .admin-content,
  .master-wrap,
  .wrapper,
  .container,
  .content,
  .page-content {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .master-wrap,
  .wrapper {
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  .headbar,
  .topbar,
  .toolbar,
  .search,
  .master-search,
  .filter-bar,
  .poster-filters,
  .header-actions,
  .card-head,
  .user-actions,
  .pager,
  .pagination,
  .vhm-head,
  .vhm-filter,
  .vhm-actions {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: 10px !important;
  }

  .headbar > *,
  .topbar > *,
  .toolbar > *,
  .search > *,
  .master-search > *,
  .filter-bar > *,
  .poster-filters > *,
  .header-actions > *,
  .card-head > *,
  .user-actions > *,
  .pager > *,
  .pagination > *,
  .vhm-filter > *,
  .vhm-actions > * {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .row,
  .filter-row,
  .form-row,
  .cards-row,
  .topcards,
  .stat-grid,
  .grid,
  .grid-2,
  .grid-3,
  .grid-4,
  .grid-5,
  .form-grid,
  .main-form-grid,
  .pac-grid3,
  .pac-labelgrid,
  .master-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    gap: 12px !important;
  }

  .group,
  .form-group,
  .field,
  .filters .group,
  .toolbar .group,
  .row .group,
  .main-form-grid textarea,
  .pac-grid3 .full,
  .pac-grid3 .actions {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  .card,
  .panel,
  .mini-card,
  .action-card,
  .followup-card,
  .stat-card,
  .scard,
  .metric,
  .kv-row {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .card[style],
  .panel[style],
  .toolbar[style],
  form[style],
  div[style*="max-width"],
  div[style*="min-width"],
  input[style*="min-width"],
  select[style*="min-width"],
  textarea[style*="min-width"] {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  form,
  fieldset {
    max-width: 100% !important;
    min-width: 0 !important;
  }

  label {
    display: block;
  }

  .inp,
  .control,
  input,
  select,
  textarea {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    font-size: 14px;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: auto !important;
  }

  textarea {
    min-height: 96px;
  }

  .btn,
  button,
  .action-btn,
  .btn-link,
  .actions a {
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  .actions,
  .save-sponsorship-wrap {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 10px !important;
  }

  .actions > *,
  .save-sponsorship-wrap > *,
  .save-sponsorship-btn {
    width: 100% !important;
  }

  .table-wrap,
  div[style*="overflow:auto"],
  div[style*="overflow: auto"],
  div[style*="overflow-x:auto"],
  div[style*="overflow-x: auto"] {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table,
  .table-wrap .table,
  table {
    width: max-content;
    min-width: 720px;
    max-width: none;
  }

  th,
  td {
    padding: 10px 12px;
    font-size: 13px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  td .btn,
  td button,
  td a.btn {
    width: auto !important;
    min-height: 34px;
    padding: 8px 10px !important;
    font-size: 12px;
  }

  img,
  video,
  canvas,
  iframe {
    max-width: 100%;
  }

  pre,
  code,
  .json,
  .nowrap {
    max-width: 100%;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere;
  }

  .modal,
  .pac-modal,
  .vhm-modal {
    padding: 12px !important;
    align-items: flex-start !important;
    overflow-y: auto !important;
  }

  .modal-content,
  .modal-box,
  .pac-modal .pac-panel,
  .vhm-dialog {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100vh - 24px) !important;
    margin: 0 !important;
    overflow-y: auto !important;
  }

  .flatpickr-calendar {
    max-width: calc(100vw - 24px) !important;
  }
}

@media (max-width: 480px) {
  .admin-content {
    padding: 10px !important;
  }

  .master-wrap,
  .wrapper {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .card,
  .panel,
  .mini-card,
  .action-card,
  .followup-card,
  .stat-card,
  .scard,
  .metric,
  .kv-row {
    padding: 12px !important;
    border-radius: 12px !important;
  }

  h1,
  .dash-title,
  .master-title {
    font-size: 22px !important;
  }

  h2,
  .section-title,
  .card-title {
    font-size: 18px !important;
  }

  h3,
  .action-title {
    font-size: 16px !important;
  }

  .btn,
  button,
  .action-btn,
  .btn-link,
  .actions a {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px !important;
    font-size: 14px;
  }

  .table-wrap table,
  .table-wrap .table,
  table {
    min-width: 640px;
  }

  th,
  td {
    padding: 9px 10px;
  }

  .badge,
  .pill,
  .chip {
    max-width: 100%;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
}


@media only screen and (max-width: 768px) {

  /* allow horizontal scroll */
  .master-wrap .card .table-wrap {
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  /* stop shrinking table */
  .master-wrap .card .table-wrap .table {
    width: max-content !important;
    min-width: 1600px !important;
    table-layout: auto !important;
    max-width: unset !important;
  }

  /* NO WORD BREAK IN ANY COLUMN */
  .master-wrap .card .table-wrap .table th,
  .master-wrap .card .table-wrap .table td {
    white-space: nowrap !important;
    word-break: keep-all !important;
    overflow-wrap: normal !important;
    word-wrap: normal !important;
    writing-mode: horizontal-tb !important;
    text-orientation: mixed !important;
    display: table-cell !important;
    min-width: fit-content !important;
    padding: 10px 8px;
  }

  /* toolbar full width */
  .toolbar {
    flex-direction: column !important;
  }

  .toolbar .inp,
  .toolbar .btn,
  .toolbar select {
    width: 100% !important;
    min-width: 100% !important;
  }
}
