:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #111827;
  --muted: #64748b;
  --line: #d7dee8;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --primary-soft: #e6f4f1;
  --danger: #c2410c;
  --danger-dark: #9a3412;
  --danger-soft: #fff1eb;
  --shadow: 0 18px 45px rgba(15, 23, 42, .10);
  --shadow-soft: 0 10px 24px rgba(15, 23, 42, .07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #f8fafc 0, var(--bg) 360px),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.secondary-button,
.danger-button {
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-weight: 700;
}

.icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

button {
  background: var(--primary);
  color: #fff;
}

button:hover {
  background: var(--primary-dark);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

input,
select {
  min-height: 42px;
  padding-top: 0;
  padding-bottom: 0;
}

textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .14);
  outline: 0;
}

label {
  display: grid;
  gap: 7px;
  color: #475569;
  font-size: 13px;
  font-weight: 800;
}

.access-page {
  display: grid;
  place-items: start center;
  padding: 28px;
}

.admin-link {
  position: fixed;
  top: 18px;
  right: 18px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 7px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
  z-index: 5;
}

.admin-link:hover {
  background: var(--surface-soft);
}

.access-shell {
  width: min(100%, 1220px);
  margin-top: 90px;
}

.access-panel,
.member-area,
.admin-gate,
#admin-panel,
.public-migration-panel {
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.access-panel {
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(24px, 5vw, 44px);
}

.brand-block {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 30px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  font-size: clamp(28px, 5vw, 40px);
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 20px;
}

.stack {
  display: grid;
  gap: 14px;
}

.code-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.message {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 800;
}

.member-area {
  padding: 24px;
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  min-height: 86px;
  padding: 18px clamp(18px, 4vw, 42px);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 4;
  backdrop-filter: blur(10px);
}

.admin-layout {
  width: min(1360px, calc(100% - 32px));
  margin: 26px auto 42px;
}

.admin-gate {
  max-width: 520px;
  padding: 26px;
}

#admin-panel {
  padding: 24px;
}

.toolbar {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.subtoolbar {
  margin-top: 30px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.migration-board {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  padding: 20px;
  margin-bottom: 22px;
}

.migration-head,
.company-card-head {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
}

.migration-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 22px;
  align-items: start;
  margin-top: 18px;
}

.migration-totals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  color: var(--muted);
}

.migration-totals strong {
  color: var(--text);
  font-size: 26px;
}

.pie-chart {
  width: 190px;
  min-width: 190px;
  height: 190px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 26px;
  font-weight: 900;
  background:
    radial-gradient(circle at center, var(--surface-soft) 0 48%, transparent 49%),
    conic-gradient(#16a34a calc(var(--resolved) * 1%), #dc2626 0);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .8), var(--shadow-soft);
}

.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, .54);
}

.modal-panel {
  width: min(100%, 1040px);
  max-height: min(92vh, 860px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(15, 23, 42, .24);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
}

.company-modal-panel .company-form {
  padding: 22px;
}

.branch-modal-panel {
  width: min(100%, 1040px);
}

.access-modal-panel,
.security-modal-panel,
.checklist-detail-panel {
  width: min(100%, 880px);
}

.checklist-info-panel {
  width: min(100%, 1120px);
}

.branch-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 14px;
  padding: 22px;
}

.company-form {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) minmax(220px, 2fr);
  gap: 12px;
  align-items: end;
}

.wide-field {
  grid-column: span 2;
}

.migration-checklist {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 6px;
}

.check-row {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 7px 8px;
  background: #fff;
  display: grid;
  grid-template-columns: repeat(3, auto);
  align-items: start;
  gap: 6px;
  color: var(--text);
  font-weight: 800;
  align-content: start;
}

.check-row input {
  width: 15px;
  min-height: 15px;
}

.check-title {
  grid-column: 1 / -1;
  min-width: 0;
  font-size: 12px;
  line-height: 1.2;
}

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.check-row .check-control {
  grid-row: 2;
}

.check-row .muted-control {
  grid-row: 2;
}

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

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.company-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.manager-group {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  padding: 16px;
}

.manager-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}

.manager-title span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.manager-title strong {
  display: block;
  margin-top: 6px;
  color: var(--text);
  font-family: "Rajdhani", "Agency FB", "Arial Narrow", "Segoe UI", sans-serif;
  font-size: clamp(34px, 4vw, 48px);
  font-weight: 900;
  line-height: .95;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.manager-summary {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.summary-chip {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.summary-chip.resolved {
  border-color: #fed7aa;
  background: #ffedd5;
  color: #9a3412;
}

.summary-chip.pending {
  border-color: #fecaca;
  background: #fee2e2;
  color: #991b1b;
}

.summary-chip.cloud {
  border-color: #bbf7d0;
  background: #dcfce7;
  color: #166534;
}

.summary-chip.cloud-pending {
  border-color: #fed7aa;
  background: #ffedd5;
  color: #9a3412;
}

.manager-progress {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #fee2e2;
  margin-top: 12px;
}

.manager-progress span {
  display: block;
  height: 100%;
  background: #16a34a;
}

.manager-company-list {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.company-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 16px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .045);
}

.company-card strong {
  display: block;
}

.company-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.company-units {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 12px 0 4px;
}

.unit-tab {
  min-height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 11px;
  font-size: 12px;
  box-shadow: none;
}

.unit-tab:hover {
  background: var(--surface-soft);
}

.unit-tab.active {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.company-progress-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 250px;
}

.progress-chart-item {
  width: 112px;
  display: grid;
  justify-items: center;
  gap: 4px;
  text-align: center;
}

.progress-chart-item span {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.progress-chart-item strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.company-pie-chart {
  width: 88px;
  min-width: 88px;
  height: 88px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 18px;
  font-weight: 900;
  background:
    radial-gradient(circle at center, #fff 0 48%, transparent 49%),
    conic-gradient(#f59e0b calc(var(--resolved) * 1%), #dc2626 0);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .9), 0 12px 26px rgba(15, 23, 42, .08);
}

.cloud-chart {
  background:
    radial-gradient(circle at center, #fff 0 48%, transparent 49%),
    conic-gradient(#16a34a calc(var(--resolved) * 1%), #f59e0b 0);
}

.progress-pill {
  min-width: 92px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 900;
  padding: 8px 11px;
  text-align: center;
}

.mini-progress {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: #fee2e2;
  margin: 14px 0;
}

.mini-progress span {
  display: block;
  height: 100%;
  background: #16a34a;
}

.pending-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.pending-list span,
.pending-list strong {
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger-dark);
  padding: 5px 8px;
  font-size: 12px;
}

.pending-list strong {
  background: #dcfce7;
  color: #166534;
}

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

.status-toggle {
  min-height: 76px;
  border-radius: 9px;
  padding: 10px 11px;
  display: grid;
  align-content: center;
  justify-items: start;
  text-align: left;
  color: #fff;
  box-shadow: none;
}

.status-toggle span {
  color: inherit;
  font-size: 13px;
  line-height: 1.25;
  margin: 0;
}

.status-toggle strong {
  color: inherit;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.status-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.status-badges strong {
  border-radius: 999px;
  padding: 4px 7px;
  background: rgba(255, 255, 255, .22);
}

.status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.status-actions button {
  min-height: 30px;
  padding: 0 9px;
  font-size: 11px;
}

.status-toggle.pending {
  background: #dc2626;
}

.status-toggle.pending:hover {
  background: #b91c1c;
}

.status-toggle.cloud-pending {
  background: #f59e0b;
}

.status-toggle.cloud-pending:hover {
  background: #d97706;
}

.status-toggle.cloud-complete {
  background: #16a34a;
}

.status-toggle.cloud-complete:hover {
  background: #15803d;
}

.status-toggle.cloud-alert {
  background: #7c2d12;
}

.status-toggle.readonly {
  cursor: default;
  opacity: 1;
}

.status-toggle.readonly:hover {
  filter: none;
}

.public-migration-panel {
  margin-top: 18px;
  padding: 24px;
}

.compact-list {
  min-width: 0;
  margin-top: 0;
  max-height: none;
  overflow: visible;
}

.toolbar-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-panel {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 10px;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 2px;
}

.action-group {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  flex: 0 0 auto;
}

.action-group button,
.action-group .secondary-button {
  min-height: 36px;
  padding: 0 11px;
  font-size: 13px;
}

.utility-actions {
  background: #fff;
}

.icon-only-button {
  width: 36px;
  min-width: 36px;
  padding: 0;
  font-size: 16px;
}

.admin-user-control {
  align-self: end;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 0 12px;
}

.admin-user-control input {
  width: 18px;
  min-height: 18px;
}

.row-action-menu {
  position: relative;
}

.row-action-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 6;
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow-soft);
  padding: 8px;
  display: grid;
  gap: 6px;
}

.row-action-panel button {
  width: 100%;
  justify-content: flex-start;
}

.checklist-info-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  padding: 22px;
}

.checklist-info-card {
  position: relative;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px 48px 14px 14px;
  display: grid;
  align-content: center;
  gap: 8px;
  text-align: left;
}

.checklist-info-card strong {
  color: var(--text);
  font-size: 16px;
  line-height: 1.18;
  font-weight: 900;
}

.checklist-info-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.checklist-info-card > button:first-of-type {
  position: absolute;
  inset: 0;
  border: 0;
  background: transparent;
  color: transparent;
}

.checklist-edit-icon {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 1;
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
}

.checklist-detail-content,
.checklist-edit-form {
  padding: 22px;
}

.checklist-detail-content {
  display: grid;
  gap: 14px;
}

.checklist-detail-content h4 {
  margin: 0;
  font-size: 20px;
}

.checklist-detail-content p {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.5;
}

.pdf-action {
  position: relative;
}

.pdf-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 8;
  width: min(320px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.print-company-report {
  display: none;
}

.print-company-report .company-card {
  margin-top: 12px;
}

.code-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 22px;
}

.password-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 22px 22px 10px;
}

.modal-message {
  padding: 0 22px 18px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

code {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-radius: 5px;
  padding: 4px 7px;
}

.secondary-button {
  background: #e8eef4;
  color: var(--text);
}

.secondary-button:hover {
  background: #dbe4ee;
}

.danger-button {
  background: var(--danger-soft);
  color: var(--danger-dark);
}

.danger-button:hover {
  background: #fed7cc;
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .migration-overview {
    grid-template-columns: 1fr;
  }

  .pie-chart {
    justify-self: center;
  }
}

@media (max-width: 760px) {
  .access-page {
    padding: 18px;
  }

  .access-shell {
    margin-top: 72px;
  }

  .code-row,
  .code-form,
  .password-form {
    grid-template-columns: 1fr;
  }

  .check-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .check-row .check-control,
  .check-row .muted-control {
    grid-row: auto;
    justify-self: start;
  }

  .topbar,
  .toolbar,
  .member-area,
  .migration-head,
  .manager-group-head,
  .company-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .manager-summary {
    justify-content: flex-start;
  }

  .company-progress-summary {
    justify-content: flex-start;
    min-width: 0;
  }

  .company-pie-chart {
    width: 76px;
    min-width: 76px;
    height: 76px;
    font-size: 16px;
  }

  .progress-chart-item {
    width: 92px;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions > * {
    flex: 1;
  }

  .action-panel,
  .action-group {
    width: 100%;
  }

  .action-panel {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .action-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    flex: 1 1 100%;
  }

  .action-group button,
  .action-group .secondary-button,
  .pdf-action,
  .pdf-action > button {
    width: 100%;
  }

  .company-form,
  .branch-form,
  .migration-checklist,
  .status-grid,
  .checklist-info-list {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: stretch;
    padding: 12px;
  }

  .modal-panel {
    max-height: calc(100vh - 24px);
  }

  .modal-head {
    padding: 16px;
  }

  .company-modal-panel .company-form {
    padding: 16px;
  }

  .branch-form {
    padding: 16px;
  }

  .wide-field {
    grid-column: auto;
  }
}

@media print {
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  @page {
    size: A4 landscape;
    margin: 10mm;
  }

  body {
    background: #fff !important;
  }

  body > *:not(.admin-layout),
  .topbar,
  #admin-panel {
    display: none !important;
  }

  .admin-layout {
    width: auto;
    max-width: none;
    padding: 0;
    margin: 0;
  }

  .print-company-report,
  .print-company-report[hidden] {
    display: block !important;
  }

  .print-company-report .company-card .actions,
  .print-company-report .company-units {
    display: none !important;
  }

  .print-company-report h2 {
    margin-bottom: 6px;
  }

  .print-company-report .company-card,
  .print-company-report .status-grid {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .company-card {
    box-shadow: none;
  }

  .status-grid {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
  }

  .status-toggle {
    border: 0;
  }
}
