/* ==========================================================================
   Orders & billing
   A quiet ledger for plan subscriptions and add-on purchases.
   ========================================================================== */

.orders-page .page-head { margin-bottom: 18px; }

.order-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.32fr) minmax(320px, 0.68fr);
  gap: 28px;
  overflow: hidden;
  padding: 28px 30px;
  color: #f7f4ed;
  background:
    radial-gradient(100% 150% at 96% 0%, rgba(221, 121, 64, 0.34) 0%, rgba(34, 47, 49, 0) 52%),
    radial-gradient(90% 130% at 0% 100%, rgba(28, 62, 65, 0.55) 0%, rgba(17, 25, 29, 0) 68%),
    linear-gradient(118deg, #111b1f 0%, #182528 55%, #10181b 100%);
  border: 1px solid #2b3538;
  border-radius: 20px;
  box-shadow: 0 18px 42px rgba(17, 25, 29, 0.16);
}

.order-hero::before,
.order-hero::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
  pointer-events: none;
}

.order-hero::before {
  width: 380px;
  height: 380px;
  top: -235px;
  right: -80px;
}

.order-hero::after {
  width: 240px;
  height: 240px;
  top: -158px;
  right: 68px;
}

.order-hero-copy,
.order-hero-side { position: relative; z-index: 1; }

.order-hero-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 13px;
  color: #a9a79f;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
}

.order-hero-eyebrow .pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #72bf8d;
  box-shadow: 0 0 0 4px rgba(114, 191, 141, 0.09);
}

.order-hero-eyebrow > span { color: #5d6767; letter-spacing: 0; }

.order-hero-total {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  color: #fbf7ef;
  font-size: 58px;
  font-weight: 500;
  line-height: 0.98;
  letter-spacing: -0.065em;
  font-variant-numeric: tabular-nums;
}

.order-hero-total > span {
  margin-top: 7px;
  color: #d6a27e;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0;
}

.order-hero-caption {
  margin-top: 12px;
  color: #b8b4ab;
  font-size: 13.5px;
  line-height: 1.6;
}

.order-hero-caption i {
  margin: 0 7px;
  color: #646a67;
  font-style: normal;
}

.order-hero-lower {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 30px;
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.order-hero-lower > div { display: flex; flex-direction: column; gap: 5px; }
.order-hero-lower span { color: #96958e; font-size: 12px; }
.order-hero-lower strong {
  color: #f5f0e7;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.order-hero-lower em {
  color: #8e908a;
  font-size: 12px;
  font-style: normal;
}

.order-hero-side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  padding-left: 26px;
  border-left: 1px solid rgba(255, 255, 255, 0.09);
}

.order-hero-chart {
  margin-top: 2px;
  opacity: 0.95;
}

.order-hero-chart svg { display: block; width: 100%; height: auto; }

.order-hero-chart-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  color: #888e88;
  font-size: 12px;
}

.order-hero-chart-label strong { color: #c1bdb3; font-weight: 400; }

.order-hero-split {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  padding-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.order-hero-split > div { display: flex; flex-direction: column; gap: 4px; }
.order-hero-split span { color: #8d918b; font-size: 12px; }
.order-hero-split strong {
  color: #f2ede4;
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.order-hero-split em { color: #777d78; font-size: 12px; font-style: normal; }

/* --------------------------------------------------------------------------
   Ledger workbench
   -------------------------------------------------------------------------- */

.order-workbench {
  margin-top: 22px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(50, 45, 37, 0.04);
}

.order-workbench-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 21px 24px 0;
}

.order-workbench-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.02em;
}
.order-workbench-head p { margin: 5px 0 0; color: var(--text-3); font-size: 12.5px; }
.order-workbench-mark {
  padding: 4px 7px;
  color: #aaa49a;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  background: #f7f4ee;
  border: 1px solid #ece7de;
  border-radius: 6px;
}

.order-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  padding: 16px 24px 0;
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.order-tabs::-webkit-scrollbar { display: none; }

.order-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  height: 38px;
  padding: 0 11px;
  margin-bottom: -1px;
  color: #77756e;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}
.order-tab:hover { color: #292e2f; }
.order-tab.is-active { color: #1d2324; border-bottom-color: var(--brand); }
.order-tab em {
  min-width: 18px;
  padding: 1px 5px;
  color: #9c978d;
  font-size: 12px;
  font-style: normal;
  text-align: center;
  background: #f6f3ed;
  border-radius: 99px;
  font-variant-numeric: tabular-nums;
}
.order-tab.is-active em { color: #a25425; background: var(--brand-soft); }

.order-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 13px 24px;
  background: #fdfbf8;
  border-bottom: 1px solid #f1ede5;
}

.order-search {
  position: relative;
  display: flex;
  align-items: center;
  width: min(330px, 100%);
  height: 37px;
  color: #9a958b;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.order-search:focus-within { border-color: #d7a17d; box-shadow: 0 0 0 3px rgba(239, 106, 43, 0.08); }
.order-search > svg { position: absolute; left: 12px; pointer-events: none; }
.order-search input {
  width: 100%;
  height: 100%;
  padding: 0 12px 0 35px;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  background: transparent;
  border: 0;
  outline: 0;
}
.order-search input::placeholder { color: #a9a49b; }

.order-kind-filter {
  width: 134px;
  height: 37px;
  font-size: 13px;
  background-color: #fff;
}

.order-clear { flex: 0 0 auto; font-size: 12.5px; }

.order-result {
  margin-left: auto;
  color: #8d897f;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Ledger table
   -------------------------------------------------------------------------- */

.order-table-wrap { width: 100%; overflow-x: auto; }

.order-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.order-table thead th {
  height: 42px;
  padding: 0 12px;
  color: #9b968c;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.065em;
  text-transform: uppercase;
  white-space: nowrap;
  background: #fbf9f5;
  border-bottom: 1px solid var(--line);
}
.order-table thead th:first-child { padding-left: 24px; }
.order-table thead th:last-child { padding-right: 18px; }
.order-table thead th.is-money { text-align: right; }
.order-table thead th.is-date { text-align: right; }

.order-table tbody td {
  padding: 13px 12px;
  vertical-align: middle;
  border-bottom: 1px solid #f3efe8;
  color: #5f615d;
}
.order-table tbody td:first-child { padding-left: 24px; }
.order-table tbody td:last-child { padding-right: 18px; }
.order-table tbody tr:last-child td { border-bottom: 0; }
.order-table tbody tr.order-row { cursor: pointer; transition: background 150ms ease; }
.order-table tbody tr.order-row:hover { background: #fbf8f3; }
.order-table tbody tr.order-row:focus-visible { outline: 2px solid #e2a17c; outline-offset: -2px; }

.order-id-cell { display: flex; align-items: center; gap: 9px; min-width: 132px; }
.order-id-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  color: #a66a3d;
  background: #fbf1e7;
  border-radius: 8px;
}
.order-id-cell > div,
.order-tenant-cell > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.order-id-cell strong {
  color: #353a3b;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.015em;
  white-space: nowrap;
}
.order-id-cell span { color: #a09b91; font-size: 12px; white-space: nowrap; }

.order-tenant-cell { display: flex; align-items: center; gap: 9px; min-width: 150px; }
.order-tenant-cell strong { color: #2f3435; font-size: 13.5px; font-weight: 500; white-space: nowrap; }
.order-tenant-cell span { color: #9b968d; font-size: 12px; white-space: nowrap; }

.order-kind {
  display: inline-flex;
  align-items: center;
  height: 23px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 6px;
}
.order-kind.is-plan { color: #4d6d5c; background: #edf5ef; }
.order-kind.is-upgrade { color: #8c6329; background: #fbf3e3; }
.order-kind.is-app { color: #4d6384; background: #eef3f9; }
.order-kind.is-ai { color: #a35b25; background: #fdf2e7; }

.order-product-cell { max-width: 260px; }
.order-product-cell strong {
  display: block;
  overflow: hidden;
  color: #404546;
  font-size: 13px;
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-product-cell span {
  display: block;
  margin-top: 4px;
  color: #9d988e;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-money {
  color: #24292a !important;
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.order-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 23px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 6px;
}
.order-status::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.order-status.is-paid { color: #297253; background: #ebf5f0; }
.order-status.is-pending { color: #9b701f; background: #fbf3e3; }
.order-status.is-refunded { color: #a14f43; background: #fbeeec; }
.order-status.is-cancelled { color: #7e7c75; background: #f2f1ed; }

.order-pay { display: block; color: #64645e; font-size: 12.5px; white-space: nowrap; }
.order-invoice { display: block; margin-top: 3px; color: #a09b91; font-size: 12px; white-space: nowrap; }

.order-date-cell { text-align: right; white-space: nowrap; }
.order-date-cell strong { display: block; color: #5d605b; font-size: 12.5px; font-weight: 400; font-variant-numeric: tabular-nums; }
.order-date-cell span { display: block; margin-top: 3px; color: #aaa49a; font-size: 12px; }

.order-arrow-cell { color: #c3bdb2; text-align: right; }
.order-table tbody tr:hover .order-arrow-cell { color: var(--brand-strong); }

.order-table .order-skeleton-cell { height: 67px; }

/* Empty state inside the ledger */
.order-table-wrap .empty-state { min-height: 300px; border: 0; }

/* --------------------------------------------------------------------------
   Pagination footer
   -------------------------------------------------------------------------- */

.order-workbench .pagination { padding: 12px 24px; background: #fdfbf8; }

/* --------------------------------------------------------------------------
   Order form
   -------------------------------------------------------------------------- */

.modal.order-form-modal { max-height: 94vh; }
.order-form { padding-top: 2px; }
.order-form .form-grid { row-gap: 17px; }

.order-form-intro {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 14px;
  background: #fbf7f0;
  border: 1px solid #f0e8da;
  border-radius: 10px;
}
.order-form-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  color: #ae6b3d;
  background: #fff;
  border: 1px solid #f0e4d7;
  border-radius: 8px;
}
.order-form-intro strong { display: block; color: #3b4040; font-size: 13px; font-weight: 500; }
.order-form-intro p { margin: 4px 0 0; color: #827d73; font-size: 12px; line-height: 1.55; }
.order-form .field-hint { min-height: 17px; }
.order-form .form-note { margin-top: 18px; }

.order-drawer { width: min(590px, 100%); }
.order-drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px 28px;
  overscroll-behavior: contain;
}

.order-detail-hero {
  position: relative;
  overflow: hidden;
  padding: 24px;
  color: #f8f4ec;
  background:
    radial-gradient(95% 140% at 100% 0%, rgba(219, 121, 63, 0.3) 0%, rgba(36, 46, 48, 0) 58%),
    linear-gradient(120deg, #121c20 0%, #1b292c 60%, #121a1d 100%);
  border: 1px solid #2c383b;
  border-radius: 16px;
}
.order-detail-hero::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -150px;
  width: 260px;
  height: 260px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
}
.order-detail-hero-top { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.order-detail-eyebrow { color: #a8a59d; font-size: 12px; letter-spacing: 0.06em; }
.order-detail-eyebrow i { margin: 0 5px; color: #646b68; font-style: normal; }
.order-detail-hero .order-status { background: rgba(255, 255, 255, 0.08); }
.order-detail-hero .order-status.is-paid { color: #8bd1aa; }
.order-detail-hero .order-status.is-pending { color: #ebc57c; }
.order-detail-hero .order-status.is-refunded { color: #e7a398; }
.order-detail-hero .order-status.is-cancelled { color: #b8b6ae; }
.order-detail-amount {
  position: relative;
  z-index: 1;
  margin-top: 20px;
  color: #fbf7ef;
  font-size: 42px;
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.order-detail-title { position: relative; z-index: 1; margin: 10px 0 0; color: #c2bdb3; font-size: 13px; }
.order-detail-created { position: relative; z-index: 1; display: flex; align-items: center; gap: 5px; margin-top: 14px; color: #7d837e; font-size: 12px; }

.order-tenant-link {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 11px;
  margin-top: 14px;
  padding: 11px 13px;
  font: inherit;
  text-align: left;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.order-tenant-link:hover { border-color: #e3cbb8; background: #fffcf8; }
.order-tenant-copy { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.order-tenant-copy strong { color: #303536; font-size: 13.5px; font-weight: 500; }
.order-tenant-copy span { color: #99948a; font-size: 12px; }
.order-tenant-action { display: inline-flex; align-items: center; gap: 4px; color: #a66a3d; font-size: 12px; white-space: nowrap; }

.order-detail-section { margin-top: 22px; }
.order-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 11px;
}
.order-info-field { padding: 12px 14px; border-bottom: 1px solid #f2eee7; }
.order-info-field:nth-child(odd) { border-right: 1px solid #f2eee7; }
.order-info-field:nth-last-child(-n + 2) { border-bottom: 0; }
.order-info-field.is-wide { grid-column: span 2; border-right: 0 !important; }
.order-info-field > span { display: block; color: #9c978d; font-size: 12px; }
.order-info-field > strong { display: block; margin-top: 5px; color: #454a48; font-size: 12.5px; font-weight: 400; line-height: 1.5; }
.order-info-field > strong em { margin: 0 4px; color: #aaa49a; font-style: normal; }
.order-info-field > strong small { display: block; margin-top: 3px; color: #a19b90; font-size: 12px; }

.order-timeline { position: relative; padding-left: 4px; }
.order-timeline-row {
  position: relative;
  display: grid;
  grid-template-columns: 17px minmax(0, 1fr) auto;
  gap: 9px;
  padding: 9px 0;
}
.order-timeline-row:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 19px;
  bottom: -9px;
  width: 1px;
  background: #ece7de;
}
.order-timeline-dot {
  width: 11px;
  height: 11px;
  margin-top: 2px;
  background: #f7f3ec;
  border: 2px solid #c7c0b5;
  border-radius: 50%;
  z-index: 1;
}
.order-timeline-dot.is-paid { background: #eaf3ed; border-color: #72a58a; }
.order-timeline-row strong { color: #505453; font-size: 12.5px; font-weight: 500; }
.order-timeline-row p { margin: 3px 0 0; color: #999389; font-size: 12px; }
.order-timeline-row time { color: #aba59a; font-size: 12px; white-space: nowrap; text-align: right; }

.order-detail-note,
.order-detail-remark {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin-top: 17px;
  padding: 10px 12px;
  color: #8e877b;
  font-size: 12px;
  line-height: 1.55;
  background: #fbf7f0;
  border: 1px solid #f0e9de;
  border-radius: 9px;
}
.order-detail-note svg { flex: 0 0 auto; margin-top: 1px; color: #b77b50; }
.order-detail-remark { flex-direction: column; gap: 4px; color: #6f6c63; background: #fdfbf7; }
.order-detail-remark span { color: #a0988b; font-size: 12px; }
.order-detail-remark p { margin: 0; }

.order-drawer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  flex: none;
  padding: 13px 24px;
  background: #fbf9f5;
  border-top: 1px solid var(--line);
}
.order-drawer-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.btn-danger-soft { color: #a24c41; background: #fff7f6; border-color: #f0d4d0; }
.btn-danger-soft:hover { color: #8e3e34; background: #fcecea; border-color: #ecc4be; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .order-hero { grid-template-columns: minmax(0, 1fr) minmax(285px, 0.58fr); padding: 24px; gap: 20px; }
  .order-hero-total { font-size: 51px; }
  .order-hero-side { padding-left: 20px; }
}

@media (max-width: 980px) {
  .order-hero { grid-template-columns: 1fr; }
  .order-hero-side { padding: 17px 0 0; border-top: 1px solid rgba(255, 255, 255, 0.09); border-left: 0; }
  .order-hero-chart { max-width: 560px; }
  .order-hero-split { max-width: 560px; }
}

@media (max-width: 760px) {
  .order-hero { padding: 21px 19px; border-radius: 16px; }
  .order-hero-total { font-size: 44px; }
  .order-hero-total > span { margin-top: 4px; font-size: 19px; }
  .order-hero-caption { font-size: 12.5px; }
  .order-hero-lower { gap: 15px 24px; margin-top: 20px; padding-top: 15px; }
  .order-hero-lower strong { font-size: 16px; }
  .order-workbench { margin-top: 16px; border-radius: 15px; }
  .order-workbench-head { padding: 17px 17px 0; }
  .order-workbench-head h2 { font-size: 16.5px; }
  .order-tabs { padding: 12px 17px 0; }
  .order-toolbar { padding: 11px 17px; gap: 8px; }
  .order-search { width: 100%; }
  .order-kind-filter { width: 128px; }
  .order-result { margin-left: 0; }
  .order-workbench .pagination { padding: 10px 17px; }
  .order-table { min-width: 1060px; }
  .order-table thead th:first-child { padding-left: 17px; }
  .order-table tbody td:first-child { padding-left: 17px; }
  .order-drawer { width: 100%; }
  .order-hero-chart,
  .order-hero-chart-label { display: none; }
  .order-hero-side { padding-top: 14px; }
  .order-hero-split { padding-top: 0; border-top: 0; }
  .order-drawer-scroll { padding: 16px 17px 24px; }
  .order-drawer-foot { padding: 11px 17px; }
  .order-detail-grid { grid-template-columns: 1fr; }
  .order-info-field:nth-child(odd) { border-right: 0; }
  .order-info-field:nth-last-child(-n + 2) { border-bottom: 1px solid #f2eee7; }
  .order-info-field:last-child { border-bottom: 0; }
  .order-info-field.is-wide { grid-column: span 1; }
  .order-detail-amount { font-size: 36px; }
  .order-drawer-actions { flex: 1; justify-content: flex-end; }
}

@media (max-width: 480px) {
  .order-hero-lower { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
  .order-hero-lower > div:last-child { grid-column: span 2; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
  .order-hero-chart-label { font-size: 12px; }
  .order-tab { padding: 0 8px; gap: 5px; }
  .order-tenant-action { display: none; }
  .order-tenant-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .order-detail-hero { padding: 19px; }
  .order-detail-hero-top { align-items: flex-start; flex-direction: column; gap: 8px; }
  .order-detail-title { font-size: 12.5px; }
  .order-detail-section { margin-top: 18px; }
  .order-drawer-foot { align-items: center; flex-wrap: nowrap; gap: 8px; }
  .order-drawer-foot > .btn { width: auto; flex: 0 0 auto; min-width: 68px; padding-left: 12px; padding-right: 12px; }
  .order-drawer-actions { flex: 1; justify-content: flex-end; flex-wrap: nowrap; gap: 6px; }
  .order-drawer-actions .btn { flex: 0 1 auto; padding-left: 11px; padding-right: 11px; }
}
