:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-soft: rgba(10, 18, 34, 0.88);
  --panel: rgba(12, 23, 43, 0.84);
  --panel-strong: rgba(17, 31, 56, 0.96);
  --line: rgba(139, 178, 255, 0.14);
  --line-strong: rgba(139, 178, 255, 0.3);
  --text: #f4f8ff;
  --text-soft: #a8b9d8;
  --text-muted: #72829f;
  --primary: #53b6ff;
  --primary-strong: #1e8dff;
  --success: #2fd7a1;
  --warning: #ffbd5d;
  --danger: #ff6d7a;
  --info: #74d5ff;
  --shadow: 0 22px 64px rgba(0, 0, 0, 0.35);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(23, 74, 145, 0.28), transparent 38%),
    radial-gradient(circle at top right, rgba(21, 128, 116, 0.22), transparent 42%),
    linear-gradient(180deg, #08111d 0%, #050b14 100%);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  cursor: pointer;
}

.bg-orb {
  position: fixed;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  filter: blur(30px);
  pointer-events: none;
  opacity: 0.55;
  z-index: 0;
}

.bg-orb-left {
  top: -70px;
  left: -90px;
  background: rgba(41, 124, 255, 0.38);
}

.bg-orb-right {
  right: -100px;
  top: 140px;
  background: rgba(43, 215, 161, 0.18);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(255, 255, 255, 0.22), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 460px);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 14px calc(env(safe-area-inset-bottom) + 24px);
}

body.with-tabs .app-shell {
  padding-bottom: calc(env(safe-area-inset-bottom) + 98px);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid rgba(115, 198, 255, 0.24);
  border-radius: 999px;
  background: rgba(23, 45, 76, 0.62);
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--info);
}

.title-block {
  margin-top: 12px;
}

.page-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

.page-description {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.6;
}

.user-pill {
  min-width: 108px;
  max-width: 148px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(12, 23, 43, 0.82);
  box-shadow: var(--shadow);
  text-align: right;
}

.user-pill__name {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.user-pill__meta {
  display: block;
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 11px;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mobile-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(18, 31, 57, 0.88), rgba(10, 20, 39, 0.92));
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.card-body {
  padding: 18px;
}

.hero-card {
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(83, 182, 255, 0.14), transparent 42%, rgba(47, 215, 161, 0.12));
  pointer-events: none;
}

.section-header,
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-header {
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.section-note,
.muted-text {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.segmented input {
  display: none;
}

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  transition: all 0.18s ease;
}

.segmented input:checked + label {
  border-color: rgba(83, 182, 255, 0.45);
  background: rgba(31, 99, 194, 0.28);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(83, 182, 255, 0.12);
}

.input-label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-soft);
  font-size: 13px;
}

.text-input,
.select-input,
.textarea-input {
  width: 100%;
  border: 1px solid rgba(124, 151, 198, 0.2);
  border-radius: 16px;
  background: rgba(5, 13, 24, 0.65);
  color: var(--text);
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.text-input,
.select-input {
  min-height: 48px;
  padding: 0 14px;
}

.textarea-input {
  min-height: 138px;
  padding: 14px;
  resize: vertical;
}

.text-input:focus,
.select-input:focus,
.textarea-input:focus {
  border-color: rgba(83, 182, 255, 0.48);
  box-shadow: 0 0 0 3px rgba(83, 182, 255, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 18px;
  font-size: 14px;
  font-weight: 700;
  transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, #2a89ff, #43c0ff);
  color: #f6fbff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost {
  background: rgba(83, 182, 255, 0.08);
  border-color: rgba(83, 182, 255, 0.18);
  color: var(--info);
}

.btn-success {
  background: linear-gradient(135deg, #109c7d, #1fd0a0);
  color: #ecfffb;
}

.btn-danger {
  background: rgba(255, 109, 122, 0.12);
  border-color: rgba(255, 109, 122, 0.22);
  color: #ffc1c7;
}

.btn-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.form-stack,
.config-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.badge-row,
.metric-grid,
.detail-grid,
.quick-grid {
  display: grid;
  gap: 10px;
}

.metric-grid,
.detail-grid,
.quick-grid {
  grid-template-columns: repeat(2, 1fr);
}

.metric-item,
.detail-item,
.quick-link {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
}

.metric-item__label,
.detail-item__label,
.field-tip {
  color: var(--text-muted);
  font-size: 12px;
}

.metric-item__value,
.detail-item__value {
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-published,
.status-settled,
.status-succeeded,
.status-active {
  background: rgba(47, 215, 161, 0.16);
  color: #8cf7d1;
}

.status-draft,
.status-created,
.status-held,
.status-selected,
.status-pending {
  background: rgba(255, 189, 93, 0.16);
  color: #ffd591;
}

.status-running {
  background: rgba(83, 182, 255, 0.16);
  color: #99dbff;
}

.status-archived,
.status-canceled,
.status-skipped,
.status-none {
  background: rgba(187, 199, 223, 0.12);
  color: #c9d5ec;
}

.status-failed,
.status-blocked,
.status-disabled,
.status-frozen {
  background: rgba(255, 109, 122, 0.16);
  color: #ffb6bf;
}

.article-list,
.order-list,
.ledger-list,
.quick-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.article-card,
.order-card,
.ledger-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
}

.article-card__title,
.order-card__title,
.list-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
}

.article-card__meta,
.order-card__meta,
.list-meta {
  margin-top: 6px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.article-followed-flag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 8px;
  padding: 0 10px;
  border: 1px solid rgba(116, 213, 255, 0.18);
  border-radius: 999px;
  background: rgba(116, 213, 255, 0.12);
  color: var(--info);
  font-size: 12px;
  font-weight: 700;
}

.logic-preview,
.logic-box {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(121, 158, 214, 0.14);
  border-radius: 16px;
  background: rgba(7, 16, 29, 0.54);
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.article-actions,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.inline-actions .btn {
  min-height: 40px;
  padding: 0 14px;
  font-size: 13px;
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.product-item {
  display: grid;
  grid-template-columns: 26px 58px 1fr;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
}

.product-checkbox {
  width: 18px;
  height: 18px;
  margin-top: 20px;
  accent-color: var(--primary);
}

.product-thumb {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  object-fit: cover;
}

.sticky-action {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
}

.estimate-box,
.empty-state,
.notice-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(5, 13, 24, 0.55);
  color: var(--text-soft);
  line-height: 1.7;
}

.empty-state {
  text-align: center;
}

.empty-state__title {
  margin: 0;
  font-size: 16px;
}

.empty-state__desc {
  margin: 8px 0 0;
  color: var(--text-soft);
  font-size: 13px;
}

.ledger-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ledger-item__amount.is-in,
.accent-success {
  color: #95ffd8;
}

.ledger-item__amount.is-out,
.accent-danger {
  color: #ffb7bf;
}

.order-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.order-line {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
}

.step-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.step-card {
  padding: 12px 14px;
  border: 1px solid rgba(121, 158, 214, 0.12);
  border-radius: 16px;
  background: rgba(8, 16, 28, 0.64);
}

.profile-card {
  padding: 18px;
}

.profile-name {
  margin: 6px 0 0;
  font-size: 26px;
}

.quick-link {
  display: block;
}

.config-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
}

.switch-row__title {
  display: block;
  font-size: 14px;
  font-weight: 700;
}

.switch-row__desc {
  display: block;
  margin-top: 6px;
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.6;
}

.switch-input {
  width: 44px;
  height: 24px;
  accent-color: var(--primary-strong);
}

.quick-link__title {
  font-size: 15px;
  font-weight: 700;
}

.quick-link__desc {
  margin-top: 6px;
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.6;
}

.toast-container {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  left: 50%;
  transform: translateX(-50%);
  width: min(100% - 28px, 420px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 30;
  pointer-events: none;
}

.toast {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(6, 14, 26, 0.92);
  box-shadow: var(--shadow);
  font-size: 14px;
  line-height: 1.6;
  opacity: 0;
  transform: translateY(-8px);
  transition: all 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-success {
  border-color: rgba(47, 215, 161, 0.3);
}

.toast-danger {
  border-color: rgba(255, 109, 122, 0.28);
}

.toast-info {
  border-color: rgba(83, 182, 255, 0.24);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(calc(100% - 28px), 432px);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(126, 166, 225, 0.16);
  border-radius: 24px;
  background: rgba(7, 16, 29, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  z-index: 20;
}

.tab-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  border-radius: 18px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

.tab-link.is-active {
  background: linear-gradient(135deg, rgba(42, 137, 255, 0.34), rgba(67, 192, 255, 0.22));
  color: var(--text);
}

.login-shell {
  min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 28px);
  display: flex;
  align-items: center;
}

.login-card {
  width: 100%;
  padding: 22px;
}

.login-heading {
  margin: 16px 0 10px;
  font-size: 34px;
  line-height: 1.08;
}

.login-subtitle {
  margin: 0 0 22px;
  color: var(--text-soft);
  line-height: 1.8;
}

.helper-text {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.hidden {
  display: none !important;
}

@media (max-width: 360px) {
  .page-title {
    font-size: 24px;
  }

  .metric-grid,
  .detail-grid,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .btn-row {
    grid-template-columns: 1fr;
  }
}
