:root {
  --bg: #f5f8fc;
  --surface: #edf4fa;
  --card: #fff;
  --border: #d6e2ee;
  --primary: #0ea5e9;
  --primary-hover: #0284c7;
  --text: #102033;
  --muted: #5d7086;
  --soft: #eaf1f8;
  --green: #eaf8f1;
  --yellow: #fff7e8;
  --warn: #b54708;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}
body.dragging {
  overflow: hidden;
}
body.auth-locked {
  overflow: hidden;
}
.topline { height: 3px; background: var(--primary); }
.app { max-width: 1180px; margin: 0 auto; padding: 6px 18px 22px; }
.brand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 2px 0 6px;
  color: var(--primary);
  font-weight: 800;
  font-size: 11px;
}
.brand-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.dev-credit {
  color: var(--muted);
  font-weight: 500;
  overflow-wrap: anywhere;
}
.stat-shortcut {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(14, 165, 233, .24);
  border-radius: 8px;
  background: rgba(14, 165, 233, .08);
  color: var(--primary);
  text-decoration: none;
  font-size: 17px;
  line-height: 1;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.stat-shortcut:hover {
  background: rgba(14, 165, 233, .16);
  border-color: rgba(14, 165, 233, .42);
  transform: translateY(-1px);
}
.stat-shortcut:focus-visible {
  outline: 3px solid rgba(14, 165, 233, .26);
  outline-offset: 2px;
}
.home-shortcut {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1px solid rgba(14, 165, 233, .22);
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
  color: var(--primary-hover);
  text-decoration: none;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(14, 165, 233, .08);
  transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.home-shortcut:hover {
  background: rgba(224, 242, 254, .92);
  border-color: rgba(14, 165, 233, .4);
  box-shadow: 0 8px 22px rgba(14, 165, 233, .12);
  transform: translateY(-1px);
}
.home-shortcut:focus-visible {
  outline: 3px solid rgba(14, 165, 233, .26);
  outline-offset: 2px;
}
.legacy-version-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 8px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 158, 11, .25);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffdf8 0%, #fff7ed 100%);
  box-shadow: inset 4px 0 0 rgba(245, 158, 11, .75);
}
.legacy-version-banner strong {
  display: block;
  color: #92400e;
  font-size: 14px;
}
.legacy-version-banner span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.legacy-version-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.legacy-version-actions .secondary,
.legacy-version-link {
  height: 34px;
  padding: 0 18px;
}
.legacy-version-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.legacy-disabled-app {
  min-height: calc(100vh - 3px);
  display: grid;
  grid-template-rows: auto 1fr;
}
.legacy-disabled-panel {
  align-self: center;
  max-width: 760px;
  margin: 42px auto;
  padding: 34px;
  border: 1px solid rgba(14, 165, 233, .22);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .96) 0%, rgba(238, 248, 255, .96) 100%);
  box-shadow: 0 22px 70px rgba(16, 32, 51, .12);
}
.legacy-disabled-tag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(14, 165, 233, .11);
  color: var(--primary-hover);
  font-weight: 800;
}
.legacy-disabled-panel h1 {
  margin: 18px 0 10px;
  font-size: 38px;
  line-height: 1.05;
}
.legacy-disabled-panel p {
  max-width: 620px;
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}
.legacy-disabled-action {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 24px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 14px 28px rgba(14, 165, 233, .2);
}
.legacy-disabled-action:hover {
  background: var(--primary-hover);
}
.overview, .card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.overview { background: var(--surface); margin-bottom: 8px; }
.overview-head { padding: 8px 12px 4px; }
.overview-top-row {
  display: grid;
  grid-template-columns: minmax(340px, max-content) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}
.order-heading {
  min-width: 0;
}
.order-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
h1 { margin: 0; font-size: 22px; line-height: 1.2; }
.copy-order {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
}
.copy-order::before,
.copy-order span {
  content: "";
  position: absolute;
  width: 13px;
  height: 15px;
  border-radius: 4px;
}
.copy-order::before {
  left: 10px;
  top: 9px;
  border: 2px solid rgba(2, 132, 199, .72);
  background: transparent;
}
.copy-order span {
  left: 6px;
  top: 5px;
  border: 2px solid rgba(14, 165, 233, .42);
  background: rgba(14, 165, 233, .18);
  box-shadow: 0 4px 10px rgba(2, 132, 199, .12);
}
.copy-order:hover {
  background: rgba(14, 165, 233, .1);
  border-color: rgba(14, 165, 233, .2);
}
.copy-order:hover span {
  background: rgba(14, 165, 233, .26);
  border-color: rgba(14, 165, 233, .62);
}
p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 0 12px 10px; }
.stat { min-height: 92px; border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; justify-content: center; }
.stat span, .section-title { color: var(--muted); font-weight: 700; font-size: 11px; }
.stat strong { margin-top: 14px; font-size: 17px; line-height: 1.25; }
.stat small { margin-top: 10px; color: var(--muted); font-size: 12px; }
.price-summary {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.price-summary b {
  font-size: 15px;
}
.price-summary em {
  font-style: normal;
  font-size: 18px;
}
.muted {
  background: #f1f5f9;
  border: 1px solid rgba(148, 163, 184, .2);
  box-shadow: inset 4px 0 0 rgba(148, 163, 184, .72);
}
.green {
  background: var(--green);
  border: 1px solid rgba(16, 185, 129, .18);
  box-shadow: inset 4px 0 0 rgba(16, 185, 129, .68);
}
.muted strong {
  color: #0f2a44;
}
.green strong {
  color: #065f46;
}
.yellow { background: #eef7ff; color: var(--text); }
.status-ready {
  background: linear-gradient(180deg, #f8fcff 0%, #eef8ff 100%);
  border: 1px solid rgba(14, 165, 233, .22);
  box-shadow: inset 4px 0 0 rgba(14, 165, 233, .85);
}
.status-ready strong {
  color: #0369a1;
}
.status-warning {
  background: linear-gradient(180deg, #fffdf8 0%, #fff7ed 100%);
  border: 1px solid rgba(245, 158, 11, .25);
  box-shadow: inset 4px 0 0 rgba(245, 158, 11, .75);
}
.status-warning strong {
  color: #92400e;
}
.status-idle {
  background: #f8fbff;
  border: 1px solid rgba(148, 163, 184, .2);
}
.upload-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  margin-bottom: 8px;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.upload-row.dragover {
  background: #e0f2fe;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .18);
}
.attention {
  background: #e0f2fe;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .18);
}
.upload-text { display: flex; flex-direction: column; gap: 2px; }
.upload-text small { color: var(--muted); font-size: 11px; }
.file-button, button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
}
.file-button {
  background: var(--primary);
  color: white;
  padding: 11px 32px;
}
.file-button input { display: none; }
.compact { padding: 10px 12px; margin-bottom: 8px; }
.form-grid {
  margin-top: 9px;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto minmax(260px, 1fr);
  gap: 8px 12px;
  align-items: center;
}
.approver-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.approver-picker select {
  grid-column: 1 / -1;
}
.default-approver {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid rgba(14, 165, 233, .18);
  border-radius: 8px;
  background: #f8fcff;
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}
.default-approver small {
  color: var(--muted);
  font-weight: 600;
}
.form-options {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 10px;
}
.push-panel {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(14, 165, 233, .28);
  border-radius: 8px;
  background: rgba(224, 242, 254, .45);
}
.push-panel div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.push-panel strong { font-size: 13px; }
.push-panel small { color: var(--muted); font-size: 11px; }
.push-panel button { flex: 0 0 auto; }
.overview-push {
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 6px 8px 6px 12px;
  border-color: rgba(14, 165, 233, .22);
  background: rgba(248, 252, 255, .72);
}
.overview-push strong {
  font-size: 12px;
}
.overview-push small {
  font-size: 11px;
}
.overview-push button {
  height: 32px;
  padding: 0 16px;
}
.history-card {
  padding-bottom: 12px;
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.history-head small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}
.history-wrap {
  max-height: 220px;
}
.history-sort {
  position: relative;
  width: 100%;
  height: auto;
  padding: 0 18px 0 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
}
.history-sort::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid rgba(93, 112, 134, .45);
  transform: translateY(-35%);
}
.history-sort.active {
  color: var(--primary-hover);
}
.history-sort.active[data-direction="asc"]::after {
  border-top: 0;
  border-bottom: 5px solid var(--primary-hover);
}
.history-sort.active[data-direction="desc"]::after {
  border-top-color: var(--primary-hover);
}
.reason-button {
  height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(14, 165, 233, .32);
  border-radius: 7px;
  background: rgba(224, 242, 254, .62);
  color: #0369a1;
  font-size: 12px;
  font-weight: 800;
}
.reason-button:hover {
  background: rgba(186, 230, 253, .82);
}
.reason-popover {
  position: fixed;
  z-index: 40;
  max-height: min(280px, calc(100vh - 24px));
  overflow: auto;
  padding: 14px 16px;
  border: 1px solid rgba(14, 165, 233, .38);
  border-radius: 8px;
  background: rgba(224, 242, 254, .92);
  color: #0f3653;
  box-shadow: 0 18px 55px rgba(14, 165, 233, .26);
  backdrop-filter: blur(10px);
  line-height: 1.45;
  white-space: pre-wrap;
}
.muted-cell {
  color: var(--muted);
}
body.permission-coach-active {
  overflow: hidden;
}
body.permission-coach-active .push-panel {
  position: relative;
  z-index: 36;
  background: #fff;
  border-color: var(--primary);
  box-shadow:
    0 0 0 4px rgba(14, 165, 233, .2),
    0 18px 60px rgba(14, 165, 233, .32);
}
body.permission-coach-active .push-panel::before {
  content: "";
  position: absolute;
  inset: -7px;
  border: 2px solid rgba(14, 165, 233, .75);
  border-radius: 12px;
  pointer-events: none;
}
.permission-coach {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background: rgba(14, 165, 233, .34);
  backdrop-filter: blur(2px);
}
.permission-coach::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 43%, rgba(255,255,255,.16), rgba(255,255,255,0) 16%),
    linear-gradient(135deg, rgba(255,255,255,.12), rgba(255,255,255,0));
}
.permission-card {
  position: absolute;
  left: 50%;
  top: 24%;
  transform: translate(-50%, -50%);
  width: min(480px, calc(100vw - 48px));
  padding: 18px 20px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(14, 165, 233, .35);
  box-shadow: 0 20px 70px rgba(16, 32, 51, .2);
  color: var(--text);
  text-align: center;
}
.permission-card strong {
  display: block;
  font-size: 20px;
  margin-bottom: 6px;
}
.permission-card span {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}
.permission-email-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 14px;
  pointer-events: auto;
}
.permission-email-row input {
  min-width: 0;
  background: #fff;
}
.permission-email-row button {
  padding: 0 22px;
}
.permission-arrow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.permission-arrow path {
  fill: none;
  stroke: rgba(255, 255, 255, .92);
  stroke-width: 18;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 10px rgba(2, 132, 199, .34));
}
.permission-arrow .arrow-head {
  stroke-width: 20;
}
input, select, textarea {
  width: 100%;
  border: 1px solid #c8d7e6;
  background: #fcfcfd;
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  font: inherit;
}
textarea { resize: vertical; margin-top: 8px; }
.margin-row { margin-top: 10px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.margin-options { display: inline-flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.margin-row label, .check { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.margin-row #customMargin {
  flex: 0 0 84px;
  width: 84px;
  padding: 7px 9px;
}
input[type="radio"], input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }
.actions { display: flex; align-items: center; gap: 12px; margin: 2px 0 8px; }
button { height: 40px; padding: 0 34px; }
button:disabled {
  cursor: not-allowed;
  opacity: .55;
}
.primary { background: var(--primary); color: white; }
.primary:hover { background: var(--primary-hover); }
.secondary { background: var(--soft); color: var(--text); border: 1px solid var(--border); }
.small { height: 34px; padding: 0 22px; }
.items-panel { padding: 10px 12px; margin-bottom: 8px; }
.hidden { display: none !important; }
.items-head { display: flex; justify-content: space-between; gap: 16px; align-items: end; margin-bottom: 10px; }
.items-head > div:first-child { min-width: 320px; }
.item-tools { display: flex; gap: 10px; align-items: center; }
.item-tools input { width: 84px; }
.table-wrap { max-height: 330px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: center; border-bottom: 1px solid #edf2f7; }
th { position: sticky; top: 0; background: #f8fafc; font-weight: 700; }
tr.discounted { background: #e0f2fe; }
.code-cell {
  text-align: left;
}
.code-copy {
  height: auto;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--primary-hover);
  font: inherit;
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
}
.code-copy:hover {
  background: rgba(14, 165, 233, .12);
  border-color: rgba(14, 165, 233, .24);
}
.compare-cell {
  white-space: nowrap;
}
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 520px;
  background: rgba(224, 242, 254, .94);
  color: #0f3653;
  border: 1px solid rgba(14, 165, 233, .5);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 12px 30px rgba(14, 165, 233, .18);
  white-space: pre-wrap;
  backdrop-filter: blur(8px);
}
.toast.toast-error {
  background: rgba(224, 242, 254, .94);
}
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background: rgba(16, 32, 51, .38);
  padding: 20px;
}
.modal-card {
  width: min(520px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(16, 32, 51, .25);
}
.modal-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}
.modal-card p {
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.45;
}
.developer-auth-card {
  border-color: rgba(14, 165, 233, .32);
  background:
    linear-gradient(180deg, rgba(224, 242, 254, .65), rgba(255, 255, 255, .96) 42%),
    var(--card);
}
.developer-auth-card h2 {
  margin-top: 6px;
}
.developer-auth-card label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.developer-auth-card input {
  width: 100%;
  margin-bottom: 10px;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
}
.developer-auth-card small {
  display: block;
  min-height: 18px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.developer-auth-card small.error {
  color: #b91c1c;
}
.history-auth-card input {
  margin-bottom: 14px;
  text-align: center;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}
.site-auth-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, rgba(245, 248, 252, .98), rgba(237, 244, 250, .98));
}
.site-auth-card {
  width: min(560px, 100%);
  padding: 24px;
  border: 1px solid rgba(14, 165, 233, .25);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(16, 32, 51, .18);
}
.site-auth-card h2 {
  margin: 8px 0;
  font-size: 24px;
}
.site-auth-card p {
  margin-bottom: 18px;
  font-size: 14px;
  line-height: 1.45;
}
.site-auth-card label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
}
.site-auth-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  background: rgba(14, 165, 233, .16);
  border: 4px dashed var(--primary);
  pointer-events: none;
}
.drop-overlay div {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 26px;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 16px 50px rgba(16, 32, 51, .18);
}
.totals-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}
.totals-grid div {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
}
.totals-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.totals-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
}
.privacy-footer {
  padding: 10px 0 2px;
  text-align: center;
  font-size: 12px;
  line-height: 1.4;
}
.privacy-footer a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.privacy-footer a:hover,
.privacy-footer a:focus-visible {
  color: var(--primary-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}
@media (max-width: 900px) {
  .stats, .form-grid, .totals-grid, .overview-top-row { grid-template-columns: 1fr; }
  .brand { flex-wrap: wrap; }
  .approver-picker { grid-template-columns: 1fr; }
  .approver-picker select { grid-column: auto; }
  .items-head, .actions, .form-options, .push-panel, .history-head { flex-direction: column; align-items: stretch; }
  .legacy-version-banner { align-items: stretch; flex-direction: column; }
  .legacy-version-actions { justify-content: stretch; }
  .legacy-version-actions .secondary,
  .legacy-version-link { width: 100%; }
  .overview-push { grid-template-columns: 1fr; }
  .permission-email-row { grid-template-columns: 1fr; }
}
