:root {
  --navy: #192755;
  --navy-dark: #121c3f;
  --orange: #e18d00;
  --bg: #f4f6fb;
  --border: #e4e8f1;
  --text: #2b3445;
  --muted: #7a8599;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

a { color: var(--navy); }
a:hover { color: var(--orange); }

.btn-theme { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 700; }
.btn-theme:hover, .btn-theme:focus { background: #c97e00; border-color: #c97e00; color: #fff; }
.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-dark); color: #fff; }

/* ---------- Shell ---------- */
.admin-wrap { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--navy);
  color: #c9d1e6;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand { display: block; padding: 24px 22px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand img { max-height: 36px; display: block; }
.sidebar .brand small { display: block; margin-top: 6px; color: #8d99bd; text-transform: uppercase; letter-spacing: .08em; font-size: 11px; font-weight: 700; }

.sidebar nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
.sidebar nav a, .sidebar-foot a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: #c9d1e6;
  font-weight: 600;
  text-decoration: none;
  margin-bottom: 2px;
}
.sidebar nav a i, .sidebar-foot a i { width: 18px; text-align: center; opacity: .8; }
.sidebar nav a:hover, .sidebar-foot a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--orange); color: #fff; }
.sidebar nav a.active i { opacity: 1; }
.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 20px; font-weight: 800; margin: 0; color: var(--navy); }
.content { padding: 28px; max-width: 1400px; }

@media (max-width: 991px) {
  .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .25s; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .content { padding: 18px; }
  .topbar { padding: 12px 16px; }
}

/* ---------- Cards ---------- */
.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 24px;
}
.panel > h3, .panel-title { font-size: 16px; font-weight: 800; color: var(--navy); margin: 0 0 16px; display: flex; align-items: center; gap: 8px; }
.panel-title .ml-auto { font-weight: 600; }

.kpi {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  height: 100%;
}
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 30px; font-weight: 800; color: var(--navy); line-height: 1.2; margin-top: 6px; }
.kpi .sub { font-size: 13px; color: var(--muted); }
.kpi .delta-up { color: #148f77; font-weight: 700; }
.kpi .delta-down { color: #c0254d; font-weight: 700; }

.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 220px; }

.bar-list .row-item { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f0f2f7; font-size: 14px; }
.bar-list .row-item:last-child { border-bottom: 0; }
.bar-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list .bar { flex: 0 0 35%; height: 8px; background: #eef1f7; border-radius: 4px; overflow: hidden; }
.bar-list .bar span { display: block; height: 100%; background: var(--navy); border-radius: 4px; }
.bar-list .num { width: 54px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Forms ---------- */
label { font-weight: 700; font-size: 13px; color: #4a5568; }
.form-control { border-color: #d7dce7; }
.form-control:focus { border-color: var(--orange); box-shadow: 0 0 0 .2rem rgba(225,141,0,.15); }
.form-text { color: var(--muted); }
.page-editor { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; line-height: 1.6; }

.image-field { display: flex; gap: 14px; align-items: flex-start; }
.image-field .preview {
  width: 150px; height: 96px; flex-shrink: 0;
  border: 1px dashed #c9d0de; border-radius: 8px; background: #f8f9fc;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.image-field .preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-field .preview span { color: var(--muted); font-size: 12px; }
.custom-file-sm, .custom-file-sm .custom-file-input, .custom-file-sm .custom-file-label { height: calc(1.5em + .5rem + 2px); font-size: 13px; }
.custom-file-sm .custom-file-label { padding: .25rem .5rem; }
.custom-file-sm .custom-file-label::after { height: calc(1.5em + .5rem); padding: .25rem .5rem; }

.section-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 20px; }
.section-tabs a {
  padding: 7px 14px; border-radius: 20px; background: #fff; border: 1px solid var(--border);
  font-weight: 700; font-size: 14px; color: var(--text); text-decoration: none;
}
.section-tabs a.active, .section-tabs a:hover { background: var(--navy); color: #fff; border-color: var(--navy); }
.section-tabs a .count { opacity: .6; margin-left: 4px; }

.sticky-save {
  position: sticky; bottom: 0; background: rgba(244,246,251,.95); padding: 14px 0; margin-top: 10px;
  border-top: 1px solid var(--border); z-index: 5;
}

/* ---------- Tables ---------- */
.table { background: #fff; }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 0; font-weight: 800; }
.table td { vertical-align: middle; }
.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: auto; }
.table-wrap .table { margin: 0; }
tr.unread td { font-weight: 700; background: #fffaf0; }
.thumb-sm { width: 70px; height: 44px; object-fit: cover; border-radius: 4px; border: 1px solid var(--border); }
.icon-cell i { font-size: 28px; color: var(--orange); }
.drag-handle { cursor: grab; color: #b0b8c9; }

/* ---------- Pricing & Packages editor ---------- */
.pe-intro {
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; margin-bottom: 28px;
}
.pe-intro > div:first-child { flex: 1 1 360px; }
.pe-stats { display: flex; gap: 10px; }
.pe-stats > div { background: var(--bg); border-radius: 10px; padding: 10px 16px; min-width: 150px; }
.pe-stats b { display: block; font-size: 22px; font-weight: 800; color: var(--navy); line-height: 1.1; }
.pe-stats span { font-size: 12px; color: var(--muted); font-weight: 700; }

.pe-section-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin: 0 0 14px; }
.pe-section-head h2 { font-size: 17px; font-weight: 800; color: var(--navy); margin: 0; display: flex; align-items: center; gap: 10px; }
.pe-step {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: 13px;
}

/* Package cards */
.pe-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; margin-bottom: 36px; }
.pe-card {
  position: relative; background: #fff; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 1px 2px rgba(25, 39, 85, .04); transition: box-shadow .2s, border-color .2s, opacity .2s;
}
.pe-card:hover { box-shadow: 0 10px 30px -14px rgba(25, 39, 85, .25); }
.pe-card.is-featured { border-color: var(--orange); box-shadow: 0 0 0 1px var(--orange); }
.pe-card.is-featured::before {
  content: "Highlighted"; position: absolute; top: -10px; left: 18px; background: var(--orange); color: #fff;
  font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 2px 10px; border-radius: 10px;
}
.pe-card.is-hidden { opacity: .6; }
.pe-card.is-hidden .pe-card-body { filter: grayscale(1); }
.pe-card-top { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid #eef1f6; }
.pe-card-top .pe-visible { margin-left: auto; }
.pe-card-body { padding: 16px 16px 18px; }
.pe-card-body .form-group { margin-bottom: 14px; }
.pe-card-body label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 4px; }
.pe-optional { text-transform: none; letter-spacing: 0; font-weight: 600; color: #a6aec0; margin-left: 4px; }
.pe-name { font-weight: 800; color: var(--navy); font-size: 16px; text-transform: uppercase; letter-spacing: .02em; }
.pe-price { display: flex; border: 1px solid #d7dce7; border-radius: .25rem; overflow: hidden; }
.pe-price .form-control { border: 0; border-radius: 0; flex: 0 0 64px; text-align: center; color: var(--muted); font-weight: 700; padding-left: 6px; padding-right: 6px; }
.pe-price .form-control + .form-control { border-left: 1px solid #e4e8f1; }
.pe-price .pe-amount { flex: 1 1 auto; min-width: 0; font-size: 20px; font-weight: 800; color: var(--navy); }
.pe-price:focus-within { border-color: var(--orange); box-shadow: 0 0 0 .2rem rgba(225,141,0,.15); }
.pe-price .form-control:focus { box-shadow: none; }
.pe-button-fields { background: #f8f9fc; border: 1px solid #eef1f6; border-radius: 10px; padding: 12px; }
.pe-button-fields .form-control { background: #fff; }
.pe-link-chip {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding: 3px 10px; border: 1px dashed #c9d0de;
  border-radius: 20px; background: #fff; color: var(--navy); font-size: 12px; font-weight: 700; cursor: pointer;
}
.pe-link-chip:hover { border-color: var(--orange); color: var(--orange); }

.pe-order { display: inline-flex; align-items: center; gap: 2px; }
.pe-order.vertical { flex-direction: column; gap: 0; }
.pe-order.vertical .pe-icon-btn { height: 15px; width: 22px; font-size: 10px; }
.pe-pos { min-width: 22px; text-align: center; font-size: 12px; font-weight: 800; color: var(--muted); }
.pe-icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: #8d97ab; font-size: 13px; cursor: pointer;
}
.pe-icon-btn:hover:not([disabled]) { background: #eef1f7; color: var(--navy); }
.pe-icon-btn.danger:hover { background: #fdecef; color: #c0254d; }
.pe-icon-btn[disabled] { opacity: .3; cursor: default; }

.pe-add-inline { display: flex; gap: 8px; margin-left: auto; align-self: center; }
.pe-add-inline .form-control { width: 250px; }
.pe-empty { grid-column: 1 / -1; padding: 30px; text-align: center; color: var(--muted); border: 2px dashed #d3d9e6; border-radius: 14px; }

/* Brand-coloured switches in the editor */
.pe-card .custom-switch .custom-control-input:checked ~ .custom-control-label::before,
.pe-matrix .custom-switch .custom-control-input:checked ~ .custom-control-label::before { background-color: #22a389; border-color: #22a389; }
.pe-card .custom-switch .custom-control-input:focus ~ .custom-control-label::before,
.pe-matrix .custom-switch .custom-control-input:focus ~ .custom-control-label::before { box-shadow: 0 0 0 .2rem rgba(34,163,137,.2); }
.pe-card .custom-switch .custom-control-label { font-size: 13px; text-transform: none; letter-spacing: 0; color: var(--text); padding-top: 1px; }

.pe-feature-head { display: flex; align-items: flex-end; gap: 8px; }
.pe-feature-head > span:first-child { flex: 1; padding-left: 30px; }
.pe-head-kind { flex: 0 0 76px; }
.pe-head-show { flex: 0 0 64px; }

/* Availability matrix */
.pe-legend { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.pe-legend .pe-chip { width: 22px; height: 22px; font-size: 10px; display: inline-flex; }
.pe-legend .pe-chip + .pe-chip, .pe-legend .pe-type { margin-left: 10px; }
.pe-type { font-size: 11px; font-weight: 800; text-transform: uppercase; background: #eef1f7; color: var(--navy); border-radius: 4px; padding: 1px 6px; }

.pe-matrix-wrap { background: #fff; border: 1px solid var(--border); border-radius: 14px; overflow: auto; max-height: calc(100vh - 230px); }
.pe-matrix { width: 100%; border-collapse: separate; border-spacing: 0; }
.pe-matrix th, .pe-matrix td { border-bottom: 1px solid #eef1f6; padding: 8px 12px; vertical-align: middle; }
.pe-matrix thead th {
  position: sticky; top: 0; z-index: 3; background: #fbfcfe; border-bottom: 1px solid var(--border);
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 800;
}
.pe-matrix .pe-feature-col { position: sticky; left: 0; z-index: 2; background: #fff; min-width: 380px; box-shadow: 1px 0 0 #eef1f6; }
.pe-matrix thead .pe-feature-col { z-index: 4; background: #fbfcfe; vertical-align: bottom; }
.pe-pkg-col { text-align: center; min-width: 150px; }
.pe-col-name { display: block; color: var(--navy); font-size: 13px; }
.pe-col-price { display: block; text-transform: none; letter-spacing: 0; font-weight: 700; font-size: 12px; }
.pe-col-actions { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }
.pe-col-actions button {
  border: 1px solid var(--border); background: #fff; border-radius: 12px; font-size: 11px; font-weight: 700;
  padding: 1px 8px; color: var(--muted); text-transform: none; letter-spacing: 0; cursor: pointer;
}
.pe-col-actions button:hover { border-color: var(--navy); color: var(--navy); }
.pe-pkg-col.is-hidden .pe-col-name::after { content: " (hidden)"; color: var(--muted); font-weight: 600; }
.pe-cell { text-align: center; }
.pe-cell.is-hidden, .pe-pkg-col.is-hidden { background: repeating-linear-gradient(135deg, #fff, #fff 6px, #f7f8fb 6px, #f7f8fb 12px); }
.pe-matrix tbody tr:hover td { background-color: #fafbfe; }
.pe-matrix tbody tr:hover td.pe-feature-col { background: #fafbfe; }

.pe-feature { display: flex; align-items: center; gap: 8px; }
.pe-feature-name { flex: 1 1 auto; min-width: 160px; border-color: transparent; background: transparent; font-weight: 700; color: var(--text); }
.pe-feature-name:hover { border-color: #d7dce7; background: #fff; }
.pe-feature-name:focus { background: #fff; }
.pe-kind { flex: 0 0 76px; font-size: 12px; font-weight: 700; color: var(--navy); }
.pe-row-visible { flex: 0 0 auto; padding-left: 2.25rem; margin-right: -8px; }
tr.is-hidden .pe-feature-name { color: #a6aec0; text-decoration: line-through; }
tr.is-hidden .pe-cell { opacity: .45; }

.pe-toggle { position: relative; margin: 0; cursor: pointer; user-select: none; display: inline-flex; }
/* Anchored to the label so the hidden checkbox stays inside the scrolling table (otherwise it widens the page on phones) */
.pe-toggle input { position: absolute; top: 0; left: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.pe-chip { width: 30px; height: 30px; border-radius: 50%; align-items: center; justify-content: center; font-size: 12px; transition: transform .1s; }
.pe-toggle .pe-chip { display: none; }
.pe-chip.on { background: #e3f6f1; color: #148f77; }
.pe-chip.off { background: #f1f3f7; color: #b3bac8; }
.pe-toggle input:checked ~ .pe-chip.on { display: inline-flex; }
.pe-toggle input:not(:checked) ~ .pe-chip.off { display: inline-flex; }
.pe-toggle:hover .pe-chip { transform: scale(1.1); }
.pe-toggle input:focus-visible ~ .pe-chip { box-shadow: 0 0 0 3px rgba(225,141,0,.35); }
.pe-label { text-align: center; font-weight: 700; max-width: 140px; margin: 0 auto; }

.pe-add-row td { background: #fbfcfe !important; border-bottom: 0; }
.pe-add-row .pe-feature { max-width: 640px; }
.pe-add-row .pe-feature-name { border-color: #d7dce7; background: #fff; font-weight: 600; }
.pe-add-icon { width: 22px; text-align: center; }

/* Save bar */
.pe-savebar {
  position: sticky; bottom: 0; z-index: 6; display: flex; align-items: center; gap: 12px;
  margin: 18px -28px -28px; padding: 14px 28px; background: rgba(255,255,255,.96); border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px -16px rgba(25, 39, 85, .25);
}
.pe-dirty { display: none; font-weight: 800; color: #b45309; font-size: 14px; }
.pe-dirty i { font-size: 8px; vertical-align: middle; margin-right: 4px; }
.pe-is-dirty .pe-dirty { display: inline; }
.pe-is-dirty .pe-clean { display: none; }

@media (max-width: 991px) {
  .pe-savebar { margin: 18px -18px -18px; padding: 12px 18px; }
  .pe-matrix .pe-feature-col { min-width: 300px; }
  .pe-matrix-wrap { max-height: none; }
}
@media (max-width: 575px) {
  .pe-stats { width: 100%; }
  .pe-stats > div { flex: 1; min-width: 0; }
  .pe-matrix .pe-feature-col { position: static; min-width: 260px; }
  .pe-add-inline { width: 100%; margin-left: 0; }
  .pe-add-inline .form-control { width: auto; flex: 1; }
  .pe-savebar .btn-link { display: none; }
}

/* Icon picker */
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; max-height: 210px; overflow-y: auto; padding: 4px; border: 1px solid var(--border); border-radius: 8px; }
.icon-picker label { margin: 0; cursor: pointer; }
.icon-picker input { display: none; }
.icon-picker span { display: flex; align-items: center; justify-content: center; height: 50px; border-radius: 8px; border: 2px solid transparent; font-size: 24px; color: var(--navy); }
.icon-picker input:checked + span { border-color: var(--orange); background: #fff6e6; color: var(--orange); }
.icon-picker span::before { margin: 0 !important; font-size: 26px !important; }

/* Messages */
.msg-body { white-space: pre-wrap; background: #f8f9fc; border-radius: 8px; padding: 16px; border: 1px solid var(--border); }
.msg-attachments { margin-top: 14px; }
.msg-file { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; background: #fff; }
.msg-file > i { font-size: 18px; color: var(--orange); width: 20px; text-align: center; }
.msg-file .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; color: var(--navy); }
.msg-file .size { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* Media grid */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.media-grid .m { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.media-grid .m .im { height: 120px; background: #f4f6fa; display: flex; align-items: center; justify-content: center; }
.media-grid .m img { max-width: 100%; max-height: 120px; object-fit: contain; }
.media-grid .m .meta { padding: 8px 10px; font-size: 12px; word-break: break-all; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #edf5ff, #fff 60%); padding: 20px; }
.login-card { background: #fff; width: 100%; max-width: 420px; padding: 40px; border-radius: 16px; box-shadow: 0 30px 60px -20px rgba(25,39,85,.25); }
.login-card h2 { font-weight: 800; color: var(--navy); font-size: 24px; }
