:root {
  --bg: #f2f7f8;
  --bg-soft: #e9f2f4;
  --text: #0d2531;
  --muted: #55707c;
  --line: #d7e4e8;
  --teal-900: #063d4b;
  --teal-700: #0c6f81;
  --teal-600: #0d8a98;
  --teal-500: #0faeb3;
  --white: #fff;
  --danger: #b42131;
  --success: #12795a;
  --warning: #9f6500;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow: 0 10px 30px rgba(6, 61, 75, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", "Arial Nova", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--teal-700);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.admin-shell {
  --sidebar-width: 280px;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  align-items: start;
  transition: grid-template-columns 0.25s ease;
}

.admin-sidebar {
  background: linear-gradient(180deg, #052f3a 0%, #0a5665 100%);
  color: var(--white);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow: hidden auto;
  transition: padding 0.25s ease, width 0.25s ease;
  border-right: 2px solid rgba(255, 20, 147, 0.68);
  padding-bottom: 84px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
}

.brand {
  display: block;
  min-width: 0;
}

.brand-logo {
  width: min(220px, 100%);
  height: auto;
  display: block;
}

.admin-nav {
  display: grid;
  gap: 8px;
}

.admin-nav a {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  padding: 10px 12px;
  border-radius: 10px;
}

.admin-nav a.active,
.admin-nav a:hover {
  background: rgba(255, 255, 255, 0.14);
  text-decoration: none;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.sidebar-logout-form {
  position: absolute;
  left: 20px;
  bottom: 18px;
  margin: 0;
}

.sidebar-logout-form .btn {
  min-height: 44px;
}

.whoami {
  font-size: 14px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.9);
}

.whoami small {
  color: rgba(255, 255, 255, 0.7);
}

.admin-main {
  padding: 28px;
  display: grid;
  gap: 18px;
  min-width: 0;
  min-height: 100vh;
}

.sidebar-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  border-radius: 12px;
  padding: 0;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(2, 34, 41, 0.18);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
}

.sidebar-toggle-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(2, 34, 41, 0.22);
}

.sidebar-toggle-button:focus-visible {
  outline: 2px solid var(--teal-500);
  outline-offset: 2px;
}

.sidebar-toggle-bars {
  width: 16px;
  display: inline-grid;
  gap: 3px;
}

.sidebar-toggle-bars span {
  display: block;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.admin-sidebar-backdrop {
  display: none;
}

body.admin-sidebar-collapsed .admin-shell {
  --sidebar-width: 72px;
}

body.admin-sidebar-collapsed .admin-sidebar {
  padding: 18px 10px;
  gap: 18px;
  align-items: center;
  padding-bottom: 84px;
}

body.admin-sidebar-collapsed .sidebar-head {
  justify-content: center;
}

body.admin-sidebar-collapsed .brand,
body.admin-sidebar-collapsed .admin-nav,
body.admin-sidebar-collapsed .sidebar-foot {
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
}

body.admin-sidebar-collapsed .sidebar-logout-form {
  display: none;
}

body.admin-sidebar-collapsed .sidebar-toggle-button {
  width: 44px;
  height: 44px;
}

.sidebar-toggle-button-floating {
  position: absolute;
  right: 14px;
  bottom: 18px;
  z-index: 3;
}

.flash-wrap {
  display: grid;
  gap: 10px;
}

.flash {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--white);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.flash-error {
  border-color: #f2c6cc;
  color: var(--danger);
}

.flash-success {
  border-color: #b8e7d5;
  color: var(--success);
}

.flash-info {
  border-color: #c8e9ed;
  color: var(--teal-700);
}

.panel-head {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.panel-head h1 {
  margin: 0;
  font-size: 28px;
}

.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 14px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-card h3 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.stat-card strong {
  font-size: 28px;
}

.table-wrap {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.table-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.table-head h2 {
  margin: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.proposal-table {
  min-width: 1280px;
}

.data-table.table-compact {
  min-width: 0;
}

.users-grid {
  grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr);
  align-items: start;
}

.users-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

.users-table-wrap .data-table {
  min-width: 760px;
}

.data-table th,
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  font-size: 14px;
}

.data-table th {
  background: #f8fbfb;
  font-size: 12px;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--line);
}

.badge-draft {
  color: #8f5d00;
  background: #fff9e6;
}

.badge-published {
  color: #0a6f82;
  background: #e7f8fb;
}

.badge-viewed {
  color: #0c7757;
  background: #e8f8f0;
}

.badge-signing {
  color: #4a2f8f;
  background: #f0ecff;
}

.badge-signed {
  color: #0d6941;
  background: #dcf6e9;
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel-inner {
  padding: 16px;
  border-radius: var(--radius-md);
}

.panel.compact {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel h2 {
  margin: 0 0 8px;
}

.panel-collapsible {
  position: relative;
}

.panel-collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.panel-collapse-header h2 {
  margin: 0;
}

.panel-collapse-toggle {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(12, 111, 129, 0.18);
  border-radius: 10px;
  background: #f4fafb;
  color: var(--teal-900);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.panel-collapse-toggle:hover {
  background: #ebf6f8;
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(6, 61, 75, 0.08);
}

.panel-collapse-toggle:focus-visible {
  outline: 2px solid var(--teal-500);
  outline-offset: 2px;
}

.panel-collapse-icon {
  position: relative;
  width: 12px;
  height: 12px;
  display: inline-block;
}

.panel-collapse-icon::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-135deg);
  transition: transform 0.18s ease;
}

.panel-collapse-toggle[data-collapsed="1"] .panel-collapse-icon::before {
  transform: rotate(45deg);
}

.panel-collapsible.is-collapsed .panel-collapse-header {
  margin-bottom: 0;
}

.panel-collapse-body {
  display: grid;
  gap: 14px;
}

.panel-collapse-body[hidden] {
  display: none !important;
}

.form-grid {
  display: grid;
  gap: 16px;
}

.grid {
  display: grid;
  gap: 10px;
}

.cols-2 {
  grid-template-columns: repeat(2, minmax(120px, 1fr));
}

.cols-3 {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.cols-4 {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.cols-5 {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.col-span-2 {
  grid-column: span 2;
}

.stack-sm {
  display: grid;
  gap: 10px;
}

.stack-md {
  display: grid;
  gap: 14px;
}

.stack-lg {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  font-weight: 700;
}

.settings-form .field {
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 6px;
}

.settings-form .field.field-top {
  grid-template-columns: 1fr;
}

.settings-form .field.field-top > span {
  margin-bottom: 2px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 4px;
  box-shadow: none;
  accent-color: var(--teal-600);
  flex: 0 0 auto;
}

textarea {
  resize: vertical;
  min-height: 90px;
}

input:focus,
textarea:focus,
select:focus {
  outline: 0;
  border-color: var(--teal-600);
  box-shadow: 0 0 0 3px rgba(15, 174, 179, 0.12);
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
  box-shadow: none;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
}

.btn-icon-only {
  width: 46px;
  min-width: 46px;
  height: 46px;
  padding: 0;
}

.btn-icon-only svg {
  width: 20px;
  height: 20px;
  display: block;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #0b6d7f, #0db1a5);
  color: #fff;
}

.btn-ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--teal-900);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline-info {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.discipline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.discipline-card {
  display: grid;
  grid-template-columns: 20px 1fr 140px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fdfefe;
}

.discipline-card strong {
  display: block;
}

.discipline-card small {
  color: var(--muted);
  font-size: 12px;
}

.panel-subhead {
  margin-top: 14px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-subhead h3 {
  margin: 0;
  font-size: 15px;
}

.panel-subhead p {
  margin: 0;
}

.panel-subhead > .btn:only-child,
.panel-subhead > button:only-child {
  margin-left: auto;
}

.repeater-row {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfd;
  padding: 10px;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

.payment-toggle {
  font-weight: 700;
  color: var(--text);
}

.payment-config-block {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(12, 111, 129, 0.12);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(248, 252, 253, 0.96), rgba(240, 247, 249, 0.96));
  transition: opacity 0.18s ease, filter 0.18s ease, background 0.18s ease;
}

.payment-config-block.is-disabled {
  opacity: 0.58;
  filter: saturate(0.55);
  background: linear-gradient(180deg, rgba(244, 247, 248, 0.94), rgba(238, 242, 244, 0.94));
}

.payment-config-block.is-disabled .field span {
  color: #7a8f98;
}

.toggle-config-block {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid rgba(12, 111, 129, 0.12);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(248, 252, 253, 0.96), rgba(240, 247, 249, 0.96));
  transition: opacity 0.18s ease, filter 0.18s ease, background 0.18s ease;
}

.toggle-config-block.is-disabled {
  opacity: 0.58;
  filter: saturate(0.55);
  background: linear-gradient(180deg, rgba(244, 247, 248, 0.94), rgba(238, 242, 244, 0.94));
}

.toggle-config-block.is-disabled .field span {
  color: #7a8f98;
}

.total-box {
  margin-top: 14px;
  background: linear-gradient(160deg, #0d8e97, #0b5b72);
  color: #fff;
  border-radius: 14px;
  padding: 14px;
}

.total-box h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: .03em;
}

.total-box strong {
  display: block;
  font-size: 30px;
  margin-top: 4px;
}

.total-box small {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.9);
}

.sticky-actions {
  position: sticky;
  bottom: 12px;
  z-index: 5;
  padding: 12px;
  background: rgba(242, 247, 248, 0.95);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.metrics-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.focus-metrics {
  display: grid;
  gap: 14px;
}

.focus-metrics .metrics-columns {
  margin-top: 16px;
}

.analytics-charts {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-top: 14px;
}

.chart-panel h3 {
  margin-top: 0;
  margin-bottom: 12px;
}

.bar-chart {
  display: grid;
  gap: 10px;
}

.bar-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 4px;
}

.bar-track {
  height: 10px;
  background: #e8f1f3;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0d8a98, #10b7a4);
}

.device-chart {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 14px;
  align-items: center;
}

.device-donut {
  width: 180px;
  height: 180px;
  border-radius: 999px;
  display: grid;
  place-items: center;
}

.device-donut-center {
  width: 112px;
  height: 112px;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  text-align: center;
  box-shadow: 0 4px 12px rgba(6, 61, 75, 0.08);
}

.device-donut-center strong {
  font-size: 24px;
  line-height: 1;
}

.device-donut-center span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.device-legend {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

.device-legend div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fbfefe;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 8px;
}

.dot-desktop {
  background: #0d8a98;
}

.dot-mobile {
  background: #10b7a4;
}

.dot-tablet {
  background: #244e7f;
}

.funnel-rows {
  display: grid;
  gap: 10px;
}

.funnel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
  font-size: 13px;
}

.funnel-track {
  height: 10px;
  background: #e8f1f3;
  border-radius: 999px;
  overflow: hidden;
}

.funnel-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0b6d7f, #0faeb3);
  border-radius: inherit;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal-900);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.settings-tab.is-active {
  background: linear-gradient(135deg, #0b6d7f, #0db1a5);
  color: #fff;
  border-color: transparent;
}

.settings-pane {
  display: none;
}

.settings-pane.is-active {
  display: block;
}

.settings-separator {
  border: none;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

.settings-vars {
  margin-top: 14px;
  border: 1px dashed var(--line);
  background: #f8fcfc;
  border-radius: 12px;
  padding: 12px;
}

.settings-spoiler {
  margin-top: 14px;
}

.settings-spoiler summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #f4fbfb;
  border-radius: 12px;
  font-weight: 700;
  color: var(--text);
}

.settings-spoiler summary::-webkit-details-marker {
  display: none;
}

.settings-spoiler summary::after {
  content: "+";
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
}

.settings-spoiler[open] summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.settings-spoiler[open] summary::after {
  content: "-";
}

.settings-spoiler .settings-vars {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.settings-vars h3 {
  margin: 0 0 6px;
}

.settings-vars-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 8px;
}

.settings-var-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
}

.settings-var-item small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.simple-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.simple-list li {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-content: center;
  gap: 12px;
  background: radial-gradient(circle at top right, #0cb4b9 0%, #063b49 60%);
  padding: 16px;
}

.auth-logo-wrap {
  display: grid;
  place-items: center;
}

.auth-logo-wrap img {
  width: min(320px, 82vw);
  height: auto;
  display: block;
}

.auth-card {
  width: min(440px, 100%);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 30px 80px rgba(3, 31, 39, 0.3);
  padding: 24px;
}

code {
  background: #eef5f7;
  border-radius: 8px;
  padding: 2px 6px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
}

.settings-form .toggle {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

@media (max-width: 1300px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }
}

@media (max-width: 980px) {
  .admin-sidebar {
    padding: 16px;
    box-shadow: 0 24px 48px rgba(2, 34, 41, 0.28);
  }

  .admin-nav {
    grid-template-columns: 1fr;
  }

  .admin-main {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .cols-2,
  .cols-3,
  .cols-4,
  .users-grid,
  .discipline-grid,
  .metrics-columns,
  .analytics-charts,
  .device-chart,
  .settings-vars-grid {
    grid-template-columns: 1fr;
  }

  .discipline-card {
    grid-template-columns: 20px 1fr;
  }

  .settings-form .field {
    grid-template-columns: 1fr;
  }
}
