:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(17, 31, 52, 0.9);
  --panel-strong: rgba(21, 39, 64, 0.96);
  --line: rgba(153, 190, 239, 0.2);
  --line-bright: rgba(73, 150, 255, 0.55);
  --text: #f7fbff;
  --muted: #a7b8d5;
  --orange: #ff8a00;
  --green: #75c85b;
  --amber: #f5a623;
  --blue: #5aa0f0;
  --cyan: #41bed0;
  --red: #f04444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(7, 17, 31, 0.92), rgba(7, 17, 31, 0.66), rgba(7, 17, 31, 0.94)),
    radial-gradient(circle at 15% 25%, rgba(31, 113, 185, 0.22), transparent 34%),
    radial-gradient(circle at 85% 20%, rgba(255, 138, 0, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.ui-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 5px 6px 5px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 17, 31, 0.72);
  color: var(--text);
}

.ui-mode-switch > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.ui-mode-options {
  display: inline-flex;
  gap: 4px;
}

.ui-mode-options button {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.ui-mode-options button:hover,
.ui-mode-options button.is-active {
  border-color: rgba(255, 138, 0, 0.42);
  background: rgba(255, 138, 0, 0.14);
  color: var(--text);
}

.app-shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.login-card {
  width: min(620px, calc(100vw - 32px));
  margin: 18vh auto 0;
  padding: 34px;
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  background: rgba(9, 20, 36, 0.92);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.35);
}

.eyebrow {
  margin: 0 0 10px;
  color: #9ec9ff;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.2rem, 5vw, 4.6rem);
  line-height: 0.96;
}

h2 {
  margin-bottom: 4px;
}

.muted {
  color: var(--muted);
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0 18px;
  color: var(--text);
  font-weight: 900;
  background: rgba(14, 27, 47, 0.9);
}

.primary-button {
  border-color: rgba(255, 138, 0, 0.8);
  background: var(--orange);
  color: #101827;
}

.danger-button {
  border-color: rgba(240, 68, 68, 0.75);
  background: rgba(240, 68, 68, 0.2);
}

.topbar,
.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.5rem);
}

.task-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.task-logo {
  width: 86px;
  height: 86px;
  flex: 0 0 86px;
  object-fit: contain;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.35));
}

.user-menu {
  position: relative;
  display: grid;
  justify-items: end;
  gap: 10px;
}

.user-menu-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(7, 17, 31, 0.72);
  cursor: pointer;
}

.profile-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: min(380px, calc(100vw - 32px));
}

.profile-popover-card {
  padding: 16px;
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  background: rgba(9, 20, 36, 0.98);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
}

.member-admin-button {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid rgba(255, 138, 0, 0.8);
  border-radius: 12px;
  background: var(--orange);
  color: #101827;
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.3);
}

.user-menu-admin {
  width: 180px;
}

.avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  object-fit: cover;
  background: #0d5b8a;
}

.grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 16px;
  align-items: start;
}

.dashboard-grid {
  grid-template-columns: minmax(320px, 420px) 1fr;
}

.panel {
  padding: 18px;
}

.profile-form,
.manager-form,
.edit-grid {
  display: grid;
  gap: 10px;
}

.status-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.status-profile-form {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 17, 31, 0.5);
}

.manager-block {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.member-admin-list {
  max-height: min(620px, 60vh);
  overflow: auto;
  margin: 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 17, 31, 0.62);
}

.member-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.member-admin-list table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.dnr-member-admin-list table {
  min-width: 0;
}

.member-admin-list th,
.member-admin-list td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(153, 190, 239, 0.12);
  text-align: left;
  vertical-align: top;
  font-size: 0.82rem;
}

.member-admin-list th {
  color: #9ec9ff;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.member-admin-list tr:last-child td {
  border-bottom: 0;
}

.member-admin-row {
  cursor: context-menu;
}

.member-admin-row:hover td {
  background: rgba(90, 160, 240, 0.08);
}

.member-admin-name-cell {
  display: grid;
  gap: 3px;
}

.member-admin-name-cell small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.archive-section {
  display: grid;
  gap: 8px;
}

.archive-section h3 {
  margin: 0;
}

.dsi-pending-members {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.archive-reason-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  min-width: 300px;
}

.member-edit-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.65);
}

.member-edit-modal {
  width: min(620px, 100%);
  padding: 20px;
  border: 1px solid var(--line-bright);
  border-radius: 14px;
  background: var(--panel-strong);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.5);
}

.member-admin-page {
  display: grid;
  gap: 16px;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-heading h2 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.toggle-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(7, 17, 31, 0.62);
}

.toggle-line input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-pill {
  position: relative;
  width: 56px;
  height: 30px;
  flex: 0 0 56px;
  border-radius: 999px;
  background: rgba(240, 68, 68, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.toggle-pill::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.16s ease;
}

.toggle-line.is-on .toggle-pill,
.toggle-line input:checked + .toggle-pill {
  background: rgba(34, 197, 94, 0.95);
}

.toggle-line.is-on .toggle-pill::after,
.toggle-line input:checked + .toggle-pill::after {
  transform: translateX(26px);
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: rgba(7, 17, 31, 0.85);
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--orange);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.status-button {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #06101e;
  font-weight: 900;
}

.status-button[data-status="8"] {
  background: #a7adb6;
}

.status-button[data-status="1"] {
  background: var(--green);
}

.status-button[data-status="0"] {
  background: var(--blue);
}

.status-button[data-status="4"] {
  background: var(--amber);
}

.status-button.is-active {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3) inset;
}

.summary-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.summary-tile {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: rgba(7, 17, 31, 0.72);
}

.summary-tile strong {
  display: block;
  font-size: 1.7rem;
  line-height: 1;
}

.member-section + .member-section {
  margin-top: 18px;
}

.dsi-unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.dsi-unit-card {
  padding: 14px;
  border: 1px solid var(--line-bright);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(12, 32, 54, 0.96), rgba(13, 24, 43, 0.96));
}

.dsi-unit-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.dsi-unit-head strong {
  font-size: 1.45rem;
}

.dsi-unit-head span,
.dsi-unit-member small {
  color: var(--muted);
  font-weight: 800;
}

.dsi-unit-member {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  align-items: center;
  width: 100%;
  gap: 9px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid rgba(153, 190, 239, 0.12);
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 900;
}

.dsi-unit-member:last-child {
  border-bottom: 0;
}

.dsi-context-menu,
.dnr-context-menu {
  position: fixed;
  z-index: 20;
  width: min(290px, calc(100vw - 24px));
  padding: 12px;
  border: 1px solid var(--line-bright);
  border-radius: 10px;
  background: #0b1729;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

.dnr-context-menu {
  width: min(320px, calc(100vw - 24px));
}

.dsi-context-title {
  margin-bottom: 10px;
  color: var(--text);
  font-weight: 900;
}

.dsi-context-menu > button,
.dsi-context-menu label,
.dnr-context-menu > button,
.dnr-context-menu label {
  display: block;
  width: 100%;
}

.dsi-context-menu > button,
.dnr-context-menu > button {
  padding: 10px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 800;
}

.dsi-context-menu > button:hover,
.dnr-context-menu > button:hover {
  background: rgba(255, 141, 0, 0.15);
}

.dsi-context-menu select,
.dnr-context-menu select {
  width: 100%;
  margin-top: 6px;
}

.dsi-context-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.dsi-context-close {
  margin-top: 6px;
  color: var(--muted) !important;
}

.dsi-unit-member .avatar {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
}

.member-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.member-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(12, 32, 54, 0.96), rgba(13, 24, 43, 0.96));
}

.member-card.inactive {
  border-color: rgba(245, 166, 35, 0.5);
}

.member-card.pending {
  border-color: rgba(90, 160, 240, 0.55);
}

.member-main {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
}

.member-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 900;
}

.status-pill,
.specialty-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.status-pill.active {
  border-color: rgba(117, 200, 91, 0.65);
  background: rgba(117, 200, 91, 0.18);
  color: #b8f3a7;
}

.status-pill.inactive {
  border-color: rgba(245, 166, 35, 0.65);
  background: rgba(245, 166, 35, 0.16);
  color: #ffd487;
}

.status-pill.pending {
  border-color: rgba(90, 160, 240, 0.65);
  background: rgba(90, 160, 240, 0.16);
  color: #cde5ff;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.specialty-chip {
  color: #cde5ff;
  background: rgba(23, 95, 150, 0.34);
}

.edit-grid {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.edit-grid .wide {
  grid-column: 1 / -1;
}

.button-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  grid-column: 1 / -1;
}

.alert {
  border: 1px solid rgba(240, 68, 68, 0.55);
  border-radius: 12px;
  padding: 12px;
  color: #ffd5d5;
  background: rgba(80, 20, 28, 0.5);
}

@media (max-width: 960px) {
  .grid,
  .summary-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .task-brand {
    align-items: flex-start;
  }

  .task-logo {
    width: 64px;
    height: 64px;
    flex-basis: 64px;
  }
}

html[data-ui-mode="calm"] {
  --bg: #0a1220;
  --panel: rgba(21, 31, 49, 0.84);
  --panel-strong: rgba(16, 25, 42, 0.9);
  --line: rgba(146, 166, 198, 0.16);
  --line-bright: rgba(146, 166, 198, 0.24);
  --text: #edf4ff;
  --muted: #9eb0c9;
  --orange: #f09021;
}

html[data-ui-mode="calm"] body {
  background:
    linear-gradient(180deg, rgba(10, 18, 32, 0.98), rgba(9, 16, 29, 1)),
    var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

html[data-ui-mode="calm"] .app-shell {
  width: min(1380px, calc(100vw - 40px));
}

html[data-ui-mode="calm"] .topbar,
html[data-ui-mode="calm"] .panel,
html[data-ui-mode="calm"] .login-card,
html[data-ui-mode="calm"] .member-card,
html[data-ui-mode="calm"] .summary-tile,
html[data-ui-mode="calm"] .profile-popover-card,
html[data-ui-mode="calm"] .modal-card {
  border-color: rgba(146, 166, 198, 0.14);
  background: rgba(21, 31, 49, 0.84);
  box-shadow: none;
}

html[data-ui-mode="calm"] .topbar {
  padding: 16px 18px;
  border-radius: 10px;
}

html[data-ui-mode="calm"] .topbar h1 {
  font-size: clamp(1.8rem, 3vw, 3rem);
}

html[data-ui-mode="calm"] .task-logo {
  width: 64px;
  height: 64px;
  flex-basis: 64px;
  filter: none;
}

html[data-ui-mode="calm"] .user-menu-row {
  gap: 8px;
}

html[data-ui-mode="calm"] .user-chip,
html[data-ui-mode="calm"] .ui-mode-switch,
html[data-ui-mode="calm"] .primary-button,
html[data-ui-mode="calm"] .secondary-button,
html[data-ui-mode="calm"] .danger-button {
  border-color: rgba(146, 166, 198, 0.16);
  box-shadow: none;
}

html[data-ui-mode="calm"] .status-button,
html[data-ui-mode="calm"] input,
html[data-ui-mode="calm"] select {
  background: rgba(16, 25, 42, 0.72);
  border-color: rgba(146, 166, 198, 0.16);
}

html[data-ui-mode="calm"] .member-list,
html[data-ui-mode="calm"] .dashboard-grid {
  gap: 14px;
}
