:root {
  --sona-navy: #17233f;
  --sona-navy-2: #22304f;
  --sona-blue: #2477bd;
  --sona-blue-soft: #eaf3fb;
  --sona-border: #d8dfe9;
  --sona-bg: #f3f6f9;
  --sona-text: #263249;
  --sona-muted: #6d788d;
  --sona-sidebar: 224px;
  --sona-topbar: 52px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body.sona-admin {
  margin: 0;
  background: var(--sona-bg);
  color: var(--sona-text);
  font: 13px/1.45 Inter, "Segoe UI", Arial, sans-serif;
}
body.sona-admin a { color: var(--sona-blue); text-decoration: none; }
body.sona-admin a:hover { color: #155f9f; }
.skip-link { position: fixed; left: -9999px; top: 0; z-index: 9999; background: #fff; padding: 8px 12px; }
.skip-link:focus { left: 0; }

/* Shell */
.sona-topbar {
  align-items: center; background: #fff; border-bottom: 1px solid var(--sona-border); display: flex;
  height: var(--sona-topbar); left: 0; padding: 0 14px; position: fixed; right: 0; top: 0; z-index: 1040;
}
.brand { align-items: center; align-self: stretch; background: transparent; display: flex; flex: 0 0 var(--sona-sidebar); justify-content: center; margin-left: -14px; }
.brand-logo { display: block; object-fit: contain; }
.brand-logo-header { height: 46px; width: 78px; }
.sidebar-toggle { background: transparent; border: 0; color: #687187; display: none; font-size: 17px; height: 34px; margin-right: 8px; width: 34px; }
.topbar-spacer { flex: 1; }
.user-menu { align-items: center; display: flex; gap: 10px; }
.user-avatar { align-items: center; background: var(--sona-navy); color: #fff; display: inline-flex; font-weight: 700; height: 28px; justify-content: center; width: 28px; }
.user-name { color: #3d475d; font-weight: 600; }
.user-menu a, .user-menu button { background: none; border: 0; color: #717b90; cursor: pointer; font-size: 14px; padding: 6px; }
.user-menu form { margin: 0; }

.sona-sidebar {
  background: #fff; border-right: 1px solid var(--sona-border); bottom: 0; left: 0; overflow-y: auto;
  padding: 14px 10px 48px; position: fixed; top: var(--sona-topbar); width: var(--sona-sidebar); z-index: 1030;
}
.nav-section { color: #9aa3b3; font-size: 10px; font-weight: 700; letter-spacing: .9px; padding: 16px 10px 6px; text-transform: uppercase; }
.nav-item { align-items: center; color: #4a556c !important; display: flex; font-weight: 500; gap: 11px; margin: 1px 0; min-height: 36px; padding: 7px 10px; }
.nav-item i { color: #7b8598; font-size: 13px; text-align: center; width: 18px; }
.nav-item:hover { background: #f2f5f9; color: var(--sona-navy) !important; }
.nav-item.active { background: var(--sona-navy); color: #fff !important; }
.nav-item.active i { color: #fff; }
.sidebar-footer { bottom: 0; color: #a3abbb; font-size: 10px; left: 0; padding: 12px 20px; position: fixed; width: var(--sona-sidebar); }
.sidebar-footer span { float: right; }

.sona-page { margin-left: var(--sona-sidebar); min-height: 100vh; padding-top: var(--sona-topbar); }
.sona-page.page-plain { margin-left: 0; padding-top: 0; }
.page-heading { align-items: flex-end; background: #fff; border-bottom: 1px solid var(--sona-border); display: flex; justify-content: space-between; min-height: 76px; padding: 11px 20px 12px; }
.page-heading h1 { color: var(--sona-navy); font-size: 21px; font-weight: 600; line-height: 1.15; margin: 5px 0 0; }
.subtitle { color: var(--sona-muted); font-size: 12px; }
.sona-breadcrumb, .page-heading .breadcrumbs { align-items: center; background: transparent; color: #8791a4; display: flex; font-size: 11px; gap: 7px; line-height: 1.4; margin: 0; padding: 0; }
.page-heading .breadcrumbs a { color: var(--sona-blue); }
.sona-breadcrumb i { font-size: 7px; }
.heading-actions .object-tools { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.heading-actions .object-tools a { background: var(--sona-blue); color: #fff; display: block; font-weight: 600; padding: 8px 12px; }
.sona-content { padding: 16px 20px 56px; width: 100%; }
#content, #content-main { max-width: none !important; width: 100% !important; }

/* Dashboard */
.dashboard .page-heading { min-height: 68px; }
.metric-grid { display: grid; gap: 10px; grid-template-columns: repeat(6, minmax(135px, 1fr)); margin-bottom: 12px; }
.metric-card { align-items: center; background: #fff; border: 1px solid var(--sona-border); color: var(--sona-text) !important; display: flex; min-height: 80px; padding: 12px; position: relative; }
.metric-card::before { background: var(--accent); content: ""; height: 3px; left: -1px; position: absolute; right: -1px; top: -1px; }
.metric-icon { align-items: center; background: var(--soft); color: var(--accent); display: flex; font-size: 17px; height: 36px; justify-content: center; margin-right: 10px; width: 36px; }
.metric-copy { display: flex; flex-direction: column; min-width: 0; }
.metric-copy small { color: var(--sona-muted); font-size: 11px; white-space: nowrap; }
.metric-copy strong { color: var(--sona-navy); font-size: 23px; line-height: 1.2; }
.accent-blue { --accent: #287ecb; --soft: #e8f2fb; }.accent-cyan { --accent: #1ca5a8; --soft: #e4f6f6; }
.accent-amber { --accent: #e39a20; --soft: #fff4df; }.accent-red { --accent: #d45454; --soft: #faeaea; }
.accent-green { --accent: #2d9d66; --soft: #e6f5ed; }.accent-violet { --accent: #7356b9; --soft: #eeeafb; }
.dashboard-grid { display: grid; gap: 12px; grid-template-columns: 2fr 1fr; }
.panel { background: #fff; border: 1px solid var(--sona-border); min-width: 0; }
.panel-head { align-items: center; border-bottom: 1px solid var(--sona-border); display: flex; justify-content: space-between; min-height: 56px; padding: 9px 14px; }
.panel-head h2 { color: var(--sona-navy); font-size: 14px; font-weight: 650; margin: 0; }
.panel-head p { color: var(--sona-muted); font-size: 11px; margin: 2px 0 0; }
.panel-head > a { font-size: 11px; font-weight: 600; }
.data-table { border-collapse: collapse; margin: 0; width: 100%; }
.data-table th { background: #f8f9fb; border-bottom: 1px solid var(--sona-border); color: #758095; font-size: 10px; font-weight: 700; letter-spacing: .35px; padding: 8px 11px; text-align: left; text-transform: uppercase; }
.data-table td { border-bottom: 1px solid #edf0f4; color: #4f5a70; padding: 9px 11px; }
.data-table tr:last-child td { border-bottom: 0; }
.primary-link { color: #22345a !important; font-weight: 650; }
.status-chip { background: #edf4fb; color: #3377b2; display: inline-block; font-size: 10px; padding: 3px 7px; }
.empty-row, .empty-state { color: var(--sona-muted); padding: 22px !important; text-align: center; }
.quick-actions { padding: 5px 14px; }
.quick-actions > a { align-items: center; border-bottom: 1px solid #edf0f4; color: var(--sona-text); display: flex; gap: 11px; padding: 11px 2px; }
.quick-actions > a:last-child { border: 0; }
.quick-actions i { align-items: center; background: var(--sona-blue-soft); color: var(--sona-blue); display: flex; height: 30px; justify-content: center; width: 30px; }
.quick-actions span { display: flex; flex-direction: column; }
.quick-actions strong { color: #344057; font-size: 12px; }
.quick-actions small, .management-grid small, .activity-item small { color: var(--sona-muted); font-size: 10px; }
.management-grid { display: grid; grid-template-columns: repeat(3, 1fr); padding: 6px 12px 12px; }
.management-grid > a { align-items: center; border-bottom: 1px solid #edf0f4; color: var(--sona-text); display: flex; gap: 10px; padding: 10px 4px; }
.management-grid > a > span:nth-child(2) { display: flex; flex: 1; flex-direction: column; }
.management-grid > a > i { color: #a5adbb; font-size: 9px; }
.management-icon { align-items: center; border: 1px solid var(--sona-border); color: #637088; display: flex; height: 30px; justify-content: center; width: 30px; }
.activity-list { padding: 7px 14px 10px; }
.activity-item { align-items: flex-start; display: flex; gap: 9px; padding: 7px 0; }
.activity-item > div { display: flex; flex-direction: column; }
.activity-item a, .activity-item strong { color: #354158; font-size: 11px; font-weight: 600; }
.activity-dot { background: #95bddd; height: 7px; margin-top: 5px; width: 7px; }

/* Django admin content restyled as compact AdminLTE panels */
#content { min-width: 0; }
#content-main { float: none; width: auto; }
.module, .inline-group { background: #fff; border: 1px solid var(--sona-border); margin: 0 0 12px; }
.module h2, .module caption, .inline-group h2, fieldset.module > h2 { background: var(--sona-navy) !important; color: #fff !important; font-size: 12px; font-weight: 600; letter-spacing: .2px; margin: 0; padding: 8px 11px; text-align: left; }
.module table { width: 100%; }
.module th, .module td { border-bottom: 1px solid #e8ecf1; padding: 8px 10px; vertical-align: middle; }
.module th { color: #3f4b62; font-size: 11px; font-weight: 600; text-align: left; }
.module td { color: #5d677a; }
.module tbody tr:hover { background: #fafbfd; }
.form-row { border-bottom: 1px solid #edf0f4; overflow: visible; padding: 9px 12px; }
.form-row:last-child { border-bottom: 0; }
.form-row > div { width: 100%; }
.form-row label { color: #4d586d; display: block; float: none; font-size: 11px; font-weight: 650; line-height: 1.3; margin: 0 0 4px; padding: 0; width: auto; }
.form-row .fieldBox { margin: 0 !important; min-width: 0; }
.aligned label { padding: 0; width: auto; }
.aligned .form-row > div > .flex-container:not(.form-multiline) { align-items: start; display: grid; gap: 12px; grid-template-columns: 148px minmax(0, 1fr); width: 100%; }
.aligned .form-row > div > .flex-container:not(.form-multiline) > label { padding-top: 9px; }
.aligned .form-multiline { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
.aligned .form-multiline > div > .fieldBox { align-items: start; display: grid; gap: 12px; grid-template-columns: 148px minmax(0, 1fr); width: 100%; }
.aligned .form-multiline .fieldBox > label { padding-top: 9px; }
input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="number"], input[type="tel"], input[type="date"], input[type="datetime-local"], textarea, select, .vTextField {
  background: #fff; border: 1px solid #c9d2df; border-radius: 0 !important; box-shadow: none !important; color: #2e394e; font: inherit; min-height: 34px; padding: 6px 8px; width: 100% !important;
}
textarea { height: 86px !important; min-height: 76px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: #4892ce; outline: 1px solid #4892ce; }
.select2-container { max-width: none !important; min-width: 220px; width: 100% !important; }
.select2-container--admin-autocomplete .select2-selection--single, .select2-container--default .select2-selection--multiple { border: 1px solid #cfd6e1 !important; border-radius: 0 !important; min-height: 34px; }
.help, p.help, form p.help { color: #818b9c; font-size: 10px; margin: 4px 0 0 !important; padding: 0 !important; }
.required label, label.required { color: #35425b; }
.required label::after, label.required::after { color: #cf5050; content: " *"; }

/* Human-friendly staff role permissions */
#id_permissions { display: grid; gap: 10px; grid-template-columns: repeat(3, minmax(220px, 1fr)); width: 100%; }
#id_permissions > div { background: #f8fafc; border: 1px solid var(--sona-border); min-width: 0; padding: 0 11px 8px; }
#id_permissions > div > label:first-child { background: #e9eef5; border-bottom: 1px solid var(--sona-border); color: var(--sona-navy); display: block; font-size: 12px; font-weight: 700; margin: 0 -11px 6px; padding: 8px 10px; width: calc(100% + 22px) !important; }
#id_permissions > div > div { border-bottom: 1px solid #e8edf3; }
#id_permissions > div > div:last-child { border-bottom: 0; }
#id_permissions > div > div > label { align-items: flex-start; color: #435067; cursor: pointer; display: flex; font-size: 11px; font-weight: 500; gap: 7px; line-height: 1.35; margin: 0; padding: 7px 1px; }
#id_permissions input[type="checkbox"] { accent-color: var(--sona-blue); flex: 0 0 auto; height: 15px; margin: 0; width: 15px; }
#id_permissions input[type="checkbox"]:checked + span { color: var(--sona-blue); }
.field-role_template select { font-weight: 600; }

/* Change lists */
#changelist { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr) 210px; }
#changelist .changelist-form-container { min-width: 0; }
#changelist-filter { background: #fff; border: 1px solid var(--sona-border); grid-column: 2; grid-row: 1; margin: 0; min-width: 0; position: static; }
#changelist-filter h2 { background: var(--sona-navy); color: #fff; font-size: 12px; padding: 9px 11px; }
#changelist-filter h3 { color: #566176; font-size: 11px; margin: 0; padding: 10px 11px 4px; }
#changelist-filter ul { margin: 0; padding: 0 11px 8px; }
#changelist-filter li { list-style: none; margin: 0; padding: 3px 0; }
#changelist-filter li.selected { border-left: 2px solid var(--sona-blue); padding-left: 6px; }
#changelist-filter a { font-size: 11px; }
#toolbar { align-items: center; background: #fff; border: 1px solid var(--sona-border); display: flex; margin: 0 0 8px; padding: 7px 9px; }
#toolbar form, #toolbar form > div { align-items: center; display: flex; gap: 6px; margin: 0; width: 100%; }
#toolbar #searchbar { margin-right: 5px; max-width: 420px; }
#toolbar input[type="submit"], .actions button { background: #68758b; border: 0; color: #fff; min-height: 34px; padding: 6px 12px; }
.actions { align-items: center; background: #fff; border: 1px solid var(--sona-border); display: flex; gap: 6px; margin-bottom: 8px; padding: 7px 9px; }
.actions select { max-width: 260px; }
.actions label { align-items: center; display: flex; gap: 6px; margin: 0; }
#result_list { background: #fff; border: 1px solid var(--sona-border); }
#result_list thead th { background: #f0f3f7; border-bottom: 1px solid #d7dde7; color: #59657a; padding: 8px 9px; }
#result_list tbody td, #result_list tbody th { border-bottom: 1px solid #e8ecf1; padding: 8px 9px; }
#result_list tbody tr:nth-child(even) { background: #fafbfd; }
.paginator { background: #fff; border: 1px solid var(--sona-border); margin: 8px 0 0 !important; padding: 9px 11px !important; }

/* Buttons */
.button, input[type="submit"], input[type="button"], .submit-row input, a.button {
  background: var(--sona-blue); border: 1px solid var(--sona-blue); border-radius: 0 !important; color: #fff; font: inherit; font-weight: 600; min-height: 34px; padding: 7px 13px;
}
.button:hover, input[type="submit"]:hover { background: #1f6fac; border-color: #1f6fac; }
.submit-row { align-items: center; background: #fff; border: 1px solid var(--sona-border); border-radius: 0; display: flex; gap: 7px; justify-content: flex-end; margin: 12px 0 16px; overflow: visible; padding: 10px 12px; }
.submit-row p { margin: 0; }
.submit-row .deletelink-box { margin-right: auto; }
.submit-row a.deletelink, .deletelink { align-items: center; background: #c95151; color: #fff !important; display: inline-flex; height: auto !important; line-height: 1.2 !important; min-height: 34px; padding: 8px 13px; }

.audit-changes { border-collapse: collapse; max-width: 900px; width: 100%; }
.audit-changes th, .audit-changes td { border: 1px solid var(--sona-border); padding: 8px 10px; text-align: left; vertical-align: top; }
.audit-changes thead th { background: #edf2f8; color: var(--sona-navy); }
.object-tools { list-style: none; margin: 0; padding: 0; }
.object-tools a:link, .object-tools a:visited { background: var(--sona-blue); border-radius: 0; color: #fff; }
.change-list #content-main > .object-tools, .change-form #content-main > .object-tools { display: flex; justify-content: flex-end; margin: -48px 0 28px; position: relative; z-index: 2; }

/* Tabs/inlines/messages */
.inline-related h3 { background: #f0f3f7; border-bottom: 1px solid var(--sona-border); color: #465269; font-size: 11px; margin: 0; padding: 8px 10px; }
.tabular.inline-related table { background: #fff; }
.tabular.inline-related th { background: #f7f8fa; font-size: 10px; }
.messagelist { list-style: none; margin: 0 0 10px; padding: 0; }
.messagelist li { background: #e8f5ed; border-left: 3px solid #319261; color: #286447; padding: 9px 11px; }
.messagelist li.error { background: #faeaea; border-color: #c84e4e; color: #873939; }
.errornote, ul.errorlist { background: #faeaea; border: 0; border-left: 3px solid #c84e4e; border-radius: 0; color: #873939; padding: 8px 10px; }

/* Login */
.sona-login-page { background: #eef2f6; }
.sona-login-page .sona-content, .sona-login-page #content { height: 100vh; padding: 0; }
.login-shell { display: grid; grid-template-columns: minmax(320px, 44%) 1fr; min-height: 100vh; }
.login-brand-panel { background: var(--sona-navy); color: #fff; display: flex; flex-direction: column; justify-content: space-between; padding: 42px 52px; }
.login-brand { align-items: center; display: flex; }
.brand-logo-login { height: auto; width: 180px; }
.login-brand-panel .eyebrow { color: #e7af36; font-size: 10px; font-weight: 700; letter-spacing: 1.4px; margin: 0 0 13px; }
.login-brand-panel h1 { color: #fff; font-size: clamp(29px, 3.4vw, 46px); font-weight: 600; line-height: 1.14; margin: 0 0 18px; }
.login-intro { color: #b8c1d4; font-size: 14px; line-height: 1.6; max-width: 440px; }
.login-foot { color: #818da8; font-size: 10px; margin: 0; }
.login-form-panel { align-items: center; background: #fff; display: flex; justify-content: center; padding: 35px; }
.login-box { max-width: 390px; width: 100%; }
.login-box h2 { color: var(--sona-navy); font-size: 25px; font-weight: 650; margin: 0 0 4px; }
.login-box > p { color: var(--sona-muted); margin: 0 0 26px; }
.field-block { margin-bottom: 15px; }
.field-block label { color: #435069; display: block; font-size: 11px; font-weight: 650; margin-bottom: 5px; }
.field-block input { min-height: 42px; }
.login-button { align-items: center; background: var(--sona-blue); border: 1px solid var(--sona-blue); color: #fff; cursor: pointer; display: flex; font: inherit; font-weight: 650; justify-content: space-between; margin-top: 22px; min-height: 42px !important; padding: 8px 12px; width: 100%; }
.login-button:hover { background: #1f6fac; border-color: #1f6fac; }
.login-error { background: #faeaea; border-left: 3px solid #c84e4e; color: #873939; margin-bottom: 15px; padding: 9px 10px; }

/* Strict square visual language */
.sona-admin *, .sona-admin *::before, .sona-admin *::after { border-radius: 0 !important; }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .management-grid { grid-template-columns: repeat(2, 1fr); }
  #id_permissions { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar-toggle { display: inline-block; }
  .brand { flex-basis: 150px; min-width: 0; }
  .sona-sidebar { transform: translateX(-100%); transition: transform .18s ease; }
  .sidebar-open .sona-sidebar { box-shadow: 8px 0 20px rgba(20, 30, 55, .15); transform: translateX(0); }
  .sona-page { margin-left: 0; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  #changelist { grid-template-columns: 1fr; }
  #changelist-filter { grid-column: 1; grid-row: auto; }
  .aligned .form-multiline { grid-template-columns: 1fr; }
  .aligned .form-multiline > div > .fieldBox { grid-template-columns: 132px minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .sona-content { padding: 10px; }
  .page-heading { padding: 10px 12px; }
  .user-name { display: none; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 7px; }
  .metric-card { min-height: 70px; padding: 9px; }
  .management-grid { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand-panel { display: none; }
  .login-form-panel { padding: 24px; }
  .aligned .form-row > div > label { flex-basis: 100%; padding-top: 0; }
  .aligned .form-row > div > .flex-container:not(.form-multiline), .aligned .form-multiline > div > .fieldBox { grid-template-columns: 1fr; gap: 4px; }
  .aligned .form-multiline { grid-template-columns: 1fr; }
  .aligned .form-row > div > .flex-container:not(.form-multiline) > label, .aligned .form-multiline .fieldBox > label { padding-top: 0; }
  #id_permissions { grid-template-columns: 1fr; }
}
