:root {
  color-scheme: light;
  --ink: #1c2326;
  --muted: #677176;
  --line: #d9dfe1;
  --surface: #ffffff;
  --canvas: #f3f5f4;
  --accent: #d94b3d;
  --accent-dark: #b9362b;
  --teal: #16796f;
  --warning: #a35d12;
  --danger: #b92f35;
  --focus: #2077b4;
  --sidebar-width: 184px;
  font-family: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: #e9edeb;
}

.login-panel {
  width: min(400px, 100%);
  padding: 36px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 44px rgba(26, 35, 37, 0.1);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 21px;
  font-weight: 800;
}

.brand-mark.small { width: 38px; height: 38px; font-size: 16px; }
.product-name { margin: 20px 0 3px; color: var(--muted); font-weight: 650; }
.login-panel h1 { margin: 0 0 26px; font-size: 25px; }
.login-form { display: grid; gap: 18px; }

label { display: grid; gap: 7px; color: #40494d; font-size: 13px; font-weight: 650; }

input, select, textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid #bbc4c7;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

input:hover, select:hover, textarea:hover { border-color: #899599; }

.primary-button, .secondary-button, .icon-button {
  min-height: 38px;
  border-radius: 5px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button { padding: 0 17px; background: var(--accent); color: #fff; }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { cursor: wait; opacity: 0.58; }
.secondary-button { padding: 0 14px; background: #fff; border-color: #b9c2c5; color: #30383b; }
.secondary-button:hover { background: #f1f3f2; }

.icon-button {
  width: 38px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: #3b4549;
  font-size: 22px;
}

.icon-button:hover { background: #e9edeb; }
.form-error { margin: 0; color: var(--danger); font-size: 13px; }

.app-shell { min-height: 100vh; }
.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.brand-lockup, .operator-actions { display: flex; align-items: center; gap: 12px; }
.brand-lockup div { display: grid; gap: 2px; }
.brand-lockup strong { font-size: 16px; }
.brand-lockup span { color: var(--muted); font-size: 12px; }
.product-switcher { display: flex; align-items: center; gap: 8px; }
.product-switcher > span { color: var(--muted); font-size: 12px; }
.product-switcher select { width: 112px; min-height: 36px; padding: 6px 30px 6px 9px; }
.operator-name { color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.workspace { min-height: calc(100vh - 64px); display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.sidebar { padding: 18px 12px; background: #222a2d; }
.nav-item {
  width: 100%;
  height: 42px;
  margin-bottom: 6px;
  padding: 0 14px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #cbd2d3;
  text-align: left;
  font-weight: 650;
}
.nav-item:hover { background: #30393c; color: #fff; }
.nav-item.active { background: #3b3331; border-left-color: #ed6657; color: #fff; }

.content-area { min-width: 0; padding: 28px clamp(20px, 3vw, 44px) 52px; }
.view-section { width: min(1240px, 100%); margin: 0 auto; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 5px; color: var(--accent); font-size: 11px; font-weight: 800; }
.section-heading h1 { margin: 0; font-size: 25px; line-height: 1.2; }
.status-label { padding: 5px 8px; border-radius: 4px; font-size: 12px; font-weight: 750; }
.status-label.neutral { background: #e2e6e6; color: #556064; }
.status-label.active { background: #dcefeb; color: #0f675f; }
.status-label.disabled { background: #f3e4e2; color: #9b342e; }

.campaign-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.form-panel, .price-preview, .table-frame {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.form-panel { padding: 24px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 19px 20px; }
.field-span-2 { grid-column: span 2; }
.field-grid.compact { margin-top: 20px; }
.toggle-field { align-content: end; }
.toggle-control { min-height: 40px; display: flex; align-items: center; gap: 9px; }
.toggle-control input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.toggle-control span {
  width: 42px; height: 23px; position: relative; border-radius: 12px; background: #9da7aa; transition: background 140ms ease;
}
.toggle-control span::after {
  content: ""; width: 17px; height: 17px; position: absolute; top: 3px; left: 3px; border-radius: 50%; background: #fff; transition: transform 140ms ease;
}
.toggle-control input:checked + span { background: var(--teal); }
.toggle-control input:checked + span::after { transform: translateX(19px); }
.toggle-control b { font-size: 13px; }
.input-suffix { position: relative; display: block; }
.input-suffix input { padding-right: 34px; }
.input-suffix > span { position: absolute; right: 11px; top: 11px; color: var(--muted); font-weight: 500; }
.form-actions, .dialog-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.saved-state { margin-right: auto; color: var(--teal); font-size: 13px; }
.config-note { display: grid; gap: 5px; margin-bottom: 22px; padding: 13px 15px; border-left: 3px solid var(--focus); background: #eef5f8; color: #3e555d; line-height: 1.55; }
.config-note strong { color: #23414b; }
.component-heading { margin: 30px 0 14px; padding-top: 22px; border-top: 1px solid #e5e9ea; }
.component-heading h2 { margin: 0; font-size: 17px; }
.component-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.android-components { display: grid; gap: 12px; }
.android-component-card { padding: 16px; border: 1px solid #d9dfe1; border-radius: 6px; background: #f8faf9; }
.android-component-title { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.android-component-title strong { font-size: 14px; }
.android-component-title span { color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.android-app-flags { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.android-app-flags label { display: inline-flex; align-items: center; gap: 6px; }
.android-app-flags input { accent-color: var(--accent); }
.android-app-remove { margin-left: auto; }
.android-icon-details { margin-top: 14px; border-top: 1px solid #e1e6e6; padding-top: 12px; }
.android-icon-details summary { cursor: pointer; color: #3e555d; font-size: 13px; font-weight: 700; }
.android-icon-details[open] summary { margin-bottom: 13px; }
.android-icon-fields { gap: 14px 16px; }
.android-icon-fields input, .android-icon-fields select { min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
.component-requirement { color: var(--muted); font-size: 12px; }
.component-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 14px; }

.price-preview { padding: 22px; }
.price-preview > p { margin: 0 0 17px; color: var(--muted); font-size: 12px; font-weight: 750; }
.price-preview dl { margin: 0; }
.price-preview dl div { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #e8ebec; }
.price-preview dt { color: var(--muted); }
.price-preview dd { margin: 0; font-weight: 750; }
.price-preview .preview-total { border-bottom: 0; padding: 18px 0 6px; }
.preview-total dd { color: var(--accent); font-size: 24px; }
.minimum-note { display: block; margin-top: 11px; padding: 8px; border-radius: 4px; background: #fff1db; color: var(--warning); font-size: 12px; }

.table-toolbar { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 13px; }
.table-toolbar label { min-width: 160px; }
.table-toolbar select { min-height: 36px; }
.result-count { margin-left: auto; padding-bottom: 9px; color: var(--muted); }
.table-frame { min-height: 210px; overflow-x: auto; }
table { width: 100%; min-width: 960px; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 13px 14px; border-bottom: 1px solid #e5e9ea; text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
th { background: #f7f8f8; color: #596367; font-size: 12px; }
td { font-size: 13px; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #faf5f4; }
tbody tr:last-child td { border-bottom: 0; }
th:nth-child(1) { width: 14%; }
th:nth-child(2), th:nth-child(3) { width: 9%; }
th:nth-child(4) { width: 18%; }
th:nth-child(5) { width: 22%; }
th:nth-child(6) { width: 11%; }
th:nth-child(7) { width: 17%; }
.code-value { font-family: "SFMono-Regular", Consolas, monospace; font-weight: 750; color: #263236; }
.row-status { display: inline-block; padding: 4px 6px; border-radius: 4px; background: #e5e9ea; color: #4f5a5e; font-size: 12px; font-weight: 750; }
.row-status.available { background: #dcefeb; color: #12675f; }
.row-status.reserved { background: #fff0d9; color: #96550e; }
.row-status.consumed { background: #e7e4ef; color: #594d79; }
.empty-state { padding: 54px 20px; color: var(--muted); text-align: center; }

.modal-dialog {
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 20px 64px rgba(20, 30, 33, 0.2);
}
.modal-dialog::backdrop { background: rgba(25, 32, 35, 0.46); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.dialog-heading h2 { margin: 0; font-size: 20px; }
.dialog-heading p { margin: 5px 0 0; color: var(--muted); }
.result-dialog textarea { min-height: 270px; margin-top: 18px; resize: vertical; font-family: "SFMono-Regular", Consolas, monospace; line-height: 1.6; }
.detail-list { display: grid; grid-template-columns: 150px minmax(0, 1fr); margin: 20px 0 0; }
.detail-list dt, .detail-list dd { margin: 0; padding: 11px 0; border-bottom: 1px solid #e6eaeb; }
.detail-list dt { color: var(--muted); }
.detail-list dd { overflow-wrap: anywhere; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 10; max-width: min(360px, calc(100vw - 44px)); padding: 11px 14px; border-radius: 5px; background: #263034; color: #fff; box-shadow: 0 8px 30px rgba(20, 28, 31, 0.2); }

@media (max-width: 900px) {
  :root { --sidebar-width: 142px; }
  .campaign-layout { grid-template-columns: 1fr; }
  .price-preview { width: 100%; }
}

@media (max-width: 680px) {
  .topbar { height: auto; min-height: 64px; padding: 10px 14px; }
  .brand-lockup div { display: none; }
  .operator-actions { min-width: 0; margin-left: auto; }
  .product-switcher > span { display: none; }
  .product-switcher select { width: 104px; }
  .operator-name { display: none; }
  .workspace { display: block; }
  .sidebar { display: flex; gap: 8px; padding: 10px 14px; }
  .nav-item { margin: 0; text-align: center; border-left: 0; border-bottom: 3px solid transparent; }
  .nav-item.active { border-bottom-color: #ed6657; }
  .content-area { padding: 22px 14px 40px; }
  .section-heading { align-items: center; }
  .field-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .component-fields { grid-template-columns: 1fr; }
  .android-component-title { align-items: flex-start; flex-direction: column; gap: 4px; }
  .table-toolbar { align-items: stretch; flex-direction: column; }
  .table-toolbar label { min-width: 0; }
  .result-count { margin: 0; padding: 0; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list dt { padding-bottom: 2px; border-bottom: 0; }
  .detail-list dd { padding-top: 2px; }
}
