:root {
  --ink: #172033;
  --muted: #6c7688;
  --line: #dfe5ee;
  --brand: #146c94;
  --brand-dark: #0c4059;
  --accent: #d98e2f;
  --danger: #b42318;
}

html {
  font-size: 15px;
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: #eef2f7;
  font-family: "Nunito", Arial, sans-serif;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 24px 18px;
  background: #101928;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 34px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent);
  color: #111827;
}

.side-nav {
  display: grid;
  gap: 7px;
}

.side-nav a,
.sidebar-footer a {
  color: #dbe5f2;
  border-radius: 8px;
  padding: 11px 12px;
  font-weight: 700;
}

.side-nav a:hover,
.sidebar-footer a:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
  color: #aebbd0;
}

.content {
  padding: 30px;
}

.page-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-title p {
  color: var(--muted);
  margin: 0 0 4px;
  font-weight: 800;
  text-transform: uppercase;
  font-size: .78rem;
}

.page-title h1 {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 800;
}

.page-actions {
  display: flex;
  justify-content: flex-end;
  margin: -62px 0 22px;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 12px 32px rgba(16, 24, 40, .06);
}

.panel + .panel {
  margin-top: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stat span {
  color: var(--muted);
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  line-height: 1;
}

.stat .stat-name {
  font-size: 1.35rem;
  line-height: 1.25;
}

.stat small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.contact-filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-control {
  position: relative;
  width: min(360px, 42vw);
}

.search-control .form-control {
  padding-right: 42px;
}

.clear-search {
  position: absolute;
  top: 50%;
  right: 5px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  transform: translateY(-50%);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
}

.clear-search:hover:not(:disabled) {
  color: var(--ink);
  background: #e8eef5;
}

.clear-search:disabled {
  visibility: hidden;
}

.contact-filters .form-select {
  width: auto;
  min-width: 140px;
}

.panel-subtitle {
  margin: 0;
  color: var(--muted);
}

.chart-filters {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-filters .form-select {
  width: auto;
  min-width: 115px;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 330px;
}

.group-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 9px;
}

.group-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
  cursor: pointer;
}

.group-option input {
  margin-top: 4px;
}

.group-option span,
.group-option small {
  display: block;
}

.group-option small {
  margin-top: 2px;
  color: var(--muted);
}

.empty-note {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f9fbfd;
}

.contacts-table {
  min-width: 980px;
}

.pagination-bar {
  display: flex;
  justify-content: flex-end;
  gap: 5px;
  margin-top: 18px;
}

.pagination-button {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

.pagination-button:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.pagination-button.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.pagination-button.disabled {
  pointer-events: none;
  opacity: .4;
}

.contact-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}

.status-label,
.call-sign {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: .78rem;
  font-weight: 800;
}

.status-yes {
  color: #12613c;
  background: #e8f7ef;
}

.status-no {
  color: var(--muted);
  background: #eef1f5;
}

.call-sign {
  color: var(--brand-dark);
  background: #e7f2f7;
  letter-spacing: 0;
}

.uppercase-input {
  text-transform: uppercase;
}

.binary-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
}

.binary-setting small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.modal-content {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(16, 24, 40, .22);
}

.modal-header,
.modal-footer {
  border-color: var(--line);
}

.modal-eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.modal-title {
  font-weight: 800;
}

.attachment-picker {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
}

.attachment-picker .panel-subtitle {
  margin-top: 8px;
  font-size: .9rem;
}

.attachment-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.attachment-item span {
  overflow-wrap: anywhere;
  font-weight: 700;
}

.attachment-item small {
  flex: 0 0 auto;
  color: var(--muted);
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, #101928, #146c94 55%, #e7eef6);
}

.auth-card {
  width: min(430px, 100%);
  background: #fff;
  border-radius: 8px;
  padding: 34px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, .28);
}

.auth-title {
  margin-bottom: 22px;
}

.auth-title h1 {
  font-weight: 800;
  margin: 0;
}

.auth-title p {
  color: var(--muted);
  margin: 6px 0 0;
}

.form-label {
  font-weight: 800;
}

.form-control,
.form-select {
  border-color: var(--line);
  border-radius: 8px;
  min-height: 42px;
}

.form-control:focus,
.form-check-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(20, 108, 148, .16);
}

.btn {
  border-radius: 8px;
  font-weight: 800;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
}

.btn-primary:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.btn-outline-danger {
  color: var(--danger);
  border-color: #f0b8b2;
}

.table {
  margin-bottom: 0;
}

.table th {
  color: var(--muted);
  font-size: .82rem;
  text-transform: uppercase;
}

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

.wysiwyg:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(20, 108, 148, .16);
}

.wysiwyg-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-height: 48px;
  padding: 7px;
  border-bottom: 1px solid var(--line);
  background: #f7f9fc;
}

.wysiwyg-toolbar button,
.color-tool {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  margin: 0;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.wysiwyg-toolbar button:hover,
.wysiwyg-toolbar button.active,
.color-tool:hover {
  border-color: var(--line);
  background: #e8eef5;
}

.wysiwyg-select {
  width: auto;
  height: 34px;
  padding: 0 28px 0 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background-color: #fff;
  color: var(--ink);
  font-family: inherit;
  font-weight: 700;
}

.toolbar-separator {
  width: 1px;
  height: 24px;
  margin: 0 3px;
  background: var(--line);
}

.color-tool {
  position: relative;
  text-decoration: underline;
  text-decoration-color: var(--brand);
  text-decoration-thickness: 3px;
}

.color-tool input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.wysiwyg-surface,
.wysiwyg-source {
  display: block;
  width: 100%;
  min-height: 360px;
  padding: 20px;
  border: 0;
  outline: 0;
  background: #fff;
}

.wysiwyg-surface:empty::before {
  color: #8a94a6;
  content: attr(data-placeholder);
  pointer-events: none;
}

.wysiwyg-source {
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
}

.preview-frame {
  min-height: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .content {
    padding: 20px;
  }

  .page-actions {
    margin: 0 0 18px;
    justify-content: stretch;
  }

  .page-actions .btn {
    width: 100%;
  }

  .panel-heading,
  .chart-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .contact-filters {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .search-control,
  .contact-filters .form-select {
    width: 100%;
  }

  .chart-filters .form-select {
    width: 100%;
  }
}
