:root {
  --bg: #fff7ed;
  --panel: #fffdf8;
  --ink: #243044;
  --muted: #7b8495;
  --line: #f0dac8;
  --primary: #ff7f8f;
  --primary-dark: #e95673;
  --mint: #5cc7b2;
  --honey: #ffc857;
  --lavender: #9f8cff;
  --danger: #d94b64;
  --shadow: 0 16px 34px rgba(123, 84, 63, 0.14);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 248, 230, .92), rgba(255, 231, 237, .9) 48%, rgba(232, 248, 244, .94)),
    var(--bg);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 18px 18px, rgba(255, 200, 87, .22) 0 2px, transparent 2px),
    radial-gradient(circle at 52px 46px, rgba(92, 199, 178, .18) 0 2px, transparent 2px);
  background-size: 72px 72px;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.topbar,
.page {
  position: relative;
  width: min(1080px, calc(100% - 28px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 0 12px;
}

.topbar > div,
.topbar nav,
.hero-panel,
.auth-card,
.panel,
dialog {
  border: 2px solid rgba(255, 255, 255, .9);
  background: rgba(255, 253, 248, .92);
  box-shadow: var(--shadow);
}

.topbar > div {
  border-radius: 18px;
  padding: 11px 14px;
}

.topbar h1,
.hero-panel h2,
.section-head h2,
.auth-title h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 22px;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-radius: 18px;
  padding: 8px;
}

.topbar nav a,
.secondary-btn,
.danger-btn,
.mini-badge {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.topbar nav a:hover,
.secondary-btn:hover,
.module-card:hover {
  transform: translateY(-1px);
}

.topbar nav span {
  border-radius: 999px;
  background: #fff5df;
  color: #8a612c;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 900;
}

.page {
  display: grid;
  gap: 14px;
  padding-bottom: 40px;
}

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

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 16px;
}

.hero-panel,
.auth-card,
.panel,
dialog {
  border-radius: 22px;
}

.hero-panel {
  position: relative;
  display: grid;
  min-height: 320px;
  align-content: center;
  overflow: hidden;
  padding: 30px;
}

.hero-panel::before {
  content: "";
  position: absolute;
  right: 28px;
  top: 26px;
  width: 96px;
  height: 64px;
  border: 3px solid rgba(255, 127, 143, .45);
  border-radius: 50% 50% 44% 44%;
  background: #fff;
  transform: rotate(7deg);
}

.hero-panel::after {
  content: "";
  position: absolute;
  right: 58px;
  top: 50px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 28px 0 0 var(--primary), 14px 20px 0 -3px var(--honey);
}

.hero-panel h2 {
  position: relative;
  max-width: 520px;
  font-size: 34px;
}

.hero-panel p {
  position: relative;
  max-width: 520px;
  color: var(--muted);
  line-height: 1.75;
}

.auth-card,
.editor-card {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.auth-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-title h3 {
  font-size: 20px;
}

.mini-badge {
  border-color: rgba(255, 127, 143, .3);
  background: #fff1f4;
  color: var(--primary-dark);
}

label {
  display: grid;
  gap: 6px;
  color: #374151;
  font-size: 13px;
  font-weight: 900;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 8px 11px;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(255, 127, 143, .72);
  box-shadow: 0 0 0 4px rgba(255, 127, 143, .16);
}

.primary-btn {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--lavender));
  color: #fff;
  padding: 9px 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 9px 18px rgba(255, 127, 143, .26);
}

.primary-btn:hover {
  background: linear-gradient(135deg, var(--primary-dark), #8370f8);
}

.danger-btn {
  border-color: rgba(217, 75, 100, .28);
  background: #fff1f4;
  color: var(--danger);
}

.compact-btn {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.icon-btn {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255, 127, 143, .28);
  border-radius: 50%;
  background: #fff1f4;
  color: var(--primary-dark);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.back-btn {
  border-color: rgba(92, 199, 178, .35);
  background: #effcf8;
  color: #267966;
}

.text-link {
  color: var(--primary-dark);
  font-weight: 900;
}

.panel {
  padding: 18px;
}

.section-head,
.toolbar,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toolbar {
  margin-bottom: 12px;
  border-radius: 16px;
  background: rgba(255, 246, 231, .72);
  padding: 10px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.module-card {
  position: relative;
  display: grid;
  gap: 8px;
  min-height: 140px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 16px;
  box-shadow: 0 8px 22px rgba(35, 55, 86, .08);
}

.module-card::after {
  content: "";
  position: absolute;
  right: -14px;
  top: -14px;
  width: 70px;
  height: 70px;
  border: 10px solid rgba(255, 200, 87, .36);
  border-radius: 22px;
  transform: rotate(18deg);
}

.module-card span {
  color: var(--mint);
  font-size: 12px;
  font-weight: 900;
}

.module-card strong {
  font-size: 19px;
}

.module-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid #f1e2d5;
  padding: 9px 10px;
  text-align: left;
}

th {
  background: #fff8ec;
  color: #8a612c;
  font-size: 12px;
}

.pill {
  display: inline-flex;
  border-radius: 999px;
  background: #f4f0ff;
  color: #6852cf;
  padding: 4px 8px;
  font-weight: 900;
}

.pill.success {
  color: #197348;
  background: #dcfce7;
}

.pill.muted {
  color: var(--muted);
  background: #edf2f7;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.flash-stack {
  display: grid;
  gap: 8px;
}

.flash {
  border-radius: 16px;
  padding: 10px 12px;
  font-weight: 900;
}

.flash.error {
  background: #ffe5e9;
  color: var(--danger);
}

.flash.success {
  background: #dcfce7;
  color: #197348;
}

dialog {
  width: min(440px, calc(100% - 28px));
  padding: 0;
}

dialog::backdrop {
  background: rgba(17, 24, 39, .28);
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(36, 48, 68, .34);
}

.detail-modal {
  width: min(860px, 100%);
  max-height: min(84vh, 760px);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, .92);
  border-radius: 24px;
  background: rgba(255, 253, 248, .98);
  box-shadow: 0 22px 54px rgba(80, 54, 44, .24);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #fff3d5, #ffeaf0 54%, #ecfff9);
  padding: 16px 18px;
}

.modal-head h3,
.detail-section h4 {
  margin: 0;
  letter-spacing: 0;
}

.modal-body {
  display: grid;
  max-height: calc(84vh - 96px);
  gap: 12px;
  overflow: auto;
  padding: 16px;
}

.detail-section {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 12px;
}

.detail-section h4 {
  margin-bottom: 10px;
  color: #8a612c;
  font-size: 15px;
}

.formula-section {
  background: linear-gradient(135deg, #fff7df, #effcf8);
}

.formula-card {
  border: 1px dashed rgba(92, 199, 178, .56);
  border-radius: 16px;
  background: #fff;
  padding: 12px;
}

.formula-card strong {
  color: #267966;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.detail-tile {
  display: grid;
  gap: 4px;
  min-height: 58px;
  border: 1px solid #f1e2d5;
  border-radius: 14px;
  background: #fffaf1;
  padding: 9px 10px;
}

.detail-tile span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.detail-tile strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}

.compact-empty {
  margin: 2px 0;
  font-size: 13px;
}

.editor-card h3 {
  margin: 0;
}

@media (max-width: 760px) {
  body {
    background: #f7f8fb;
  }

  body::before {
    display: none;
  }

  .topbar,
  .page {
    width: min(430px, calc(100% - 14px));
  }

  .topbar {
    position: sticky;
    top: 4px;
    z-index: 10;
    align-items: center;
    flex-direction: row;
    gap: 6px;
    padding: 5px 0 7px;
  }

  .topbar > div {
    display: grid;
    min-width: 86px;
    gap: 0;
    padding: 7px 9px;
    border-radius: 12px;
  }

  .topbar h1 {
    font-size: 15px;
  }

  .topbar .eyebrow {
    display: none;
  }

  .topbar nav {
    display: flex;
    flex: 1;
    justify-content: flex-start;
    overflow-x: auto;
    gap: 5px;
    padding: 5px;
    border-radius: 12px;
  }

  .topbar nav a,
  .topbar nav span {
    min-height: 32px;
    flex: 0 0 auto;
    padding: 6px 9px;
    font-size: 12px;
  }

  .page {
    padding-bottom: 16px;
  }

  .auth-layout {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .hero-panel {
    min-height: 0;
    padding: 12px;
    border-radius: 14px;
    color: var(--ink);
    background: rgba(255, 253, 248, .94);
  }

  .hero-panel::before,
  .hero-panel::after {
    display: none;
  }

  .hero-panel h2 {
    max-width: 260px;
    font-size: 20px;
    line-height: 1.15;
  }

  .hero-panel p,
  .hero-panel .eyebrow {
    color: var(--muted);
  }

  .hero-panel p {
    margin: 5px 0 0;
    line-height: 1.45;
  }

  .auth-card {
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
  }

  .auth-title h3 {
    font-size: 20px;
  }

  label {
    font-size: 14px;
  }

  input,
  select,
  .primary-btn {
    min-height: 40px;
    border-radius: 10px;
    font-size: 16px;
  }

  .primary-btn {
    margin-top: 4px;
  }

  .text-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

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

  .module-grid {
    grid-template-columns: 1fr;
  }

  .module-card {
    min-height: 92px;
    border-radius: 14px;
    padding: 12px;
  }

  .module-card strong {
    font-size: 18px;
  }

  .module-card p {
    margin: 2px 0 0;
    line-height: 1.4;
  }

  .section-head,
  .row-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .row-actions > * {
    width: 100%;
  }

  .toolbar {
    display: grid;
    gap: 7px;
    padding: 8px;
    border-radius: 12px;
  }

  .toolbar label,
  .toolbar button {
    width: 100%;
  }

  .secondary-btn,
  .danger-btn {
    min-height: 36px;
    border-radius: 10px;
  }

  dialog {
    width: 100%;
    max-width: none;
    margin: auto 0 0;
    border: 0;
    border-radius: 24px 24px 0 0;
  }

  dialog::backdrop {
    background: rgba(17, 24, 39, .38);
    backdrop-filter: blur(8px);
  }

  .editor-card {
    border-radius: 16px 16px 0 0;
    padding: 14px 12px 16px;
  }

  .modal-backdrop {
    align-items: end;
    padding: 10px;
  }

  .detail-modal {
    width: 100%;
    max-height: 86vh;
    border-radius: 16px 16px 12px 12px;
  }

  .modal-head {
    padding: 10px 12px;
  }

  .modal-body {
    max-height: calc(86vh - 84px);
    padding: 10px;
  }
}

@media (max-width: 760px) {
  .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 7px;
  }

  .topbar > div,
  .topbar nav,
  .panel,
  .auth-card,
  .hero-panel {
    border-radius: 20px;
    box-shadow: 0 8px 18px rgba(35, 55, 86, .07);
  }

  .topbar > div {
    min-width: 72px;
    padding: 7px 10px;
  }

  .topbar nav {
    min-width: 0;
    flex-wrap: nowrap;
  }

  .topbar nav span,
  .topbar nav a {
    min-height: 31px;
    padding: 6px 9px;
    border-radius: 999px;
    white-space: nowrap;
  }

  .page {
    display: grid;
    gap: 8px;
  }

  .panel {
    padding: 10px;
  }

  .section-head {
    gap: 6px;
    margin-bottom: 8px;
  }

  .section-head h2 {
    font-size: 18px;
  }

  .toolbar {
    grid-template-columns: 1fr auto;
  }

  .toolbar label {
    grid-column: 1 / -1;
  }

  .toolbar button {
    width: auto;
  }

}

@media (max-width: 760px) {
  :root {
    --mobile-bg: #f5f7fb;
    --mobile-surface: rgba(255, 255, 255, 0.66);
    --mobile-line: rgba(134, 151, 178, 0.2);
  }

  body {
    color: #172033;
    background:
      linear-gradient(180deg, #f7fbff 0%, #f5f7fb 42%, #f3f7f4 100%);
  }

  .topbar,
  .page {
    width: min(430px, calc(100% - 18px));
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 12;
    grid-template-columns: minmax(0, auto) minmax(0, 1fr);
    gap: 6px;
    padding: max(6px, env(safe-area-inset-top)) 0 6px;
    background: rgba(245, 247, 251, 0.92);
    backdrop-filter: blur(18px);
  }

  .topbar > div,
  .topbar nav,
  .panel,
  .hero-panel,
  .auth-card {
    border: 0;
    box-shadow: none;
  }

  .topbar > div {
    min-width: 0;
    padding: 4px 0;
    background: transparent;
  }

  .topbar h1 {
    font-size: 16px;
    line-height: 1.1;
    white-space: nowrap;
  }

  .topbar nav {
    min-width: 0;
    justify-content: flex-end;
    gap: 4px;
    padding: 0;
    background: transparent;
    overflow-x: auto;
  }

  .topbar nav span,
  .topbar nav a {
    min-height: 28px;
    padding: 5px 8px;
    border: 1px solid var(--mobile-line);
    background: rgba(255, 255, 255, 0.72);
    font-size: 11px;
    line-height: 1;
  }

  .topbar nav span {
    max-width: 96px;
    overflow: hidden;
    color: #42526b;
    text-overflow: ellipsis;
  }

  .page {
    gap: 6px;
    padding: 4px 0 14px;
  }

  .panel,
  .auth-card,
  .hero-panel {
    padding: 6px 2px;
    border-radius: 0;
    background: transparent;
  }

  .flash {
    padding: 7px 10px;
    border-radius: 14px;
    font-size: 12px;
  }

  .section-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    margin: 0 0 6px;
  }

  .section-head h2 {
    font-size: 17px;
    line-height: 1.2;
  }

  .section-head .eyebrow,
  .hero-panel .eyebrow {
    display: none;
  }

  .back-btn,
  .section-head .secondary-btn {
    width: auto;
    min-height: 30px;
    padding: 5px 9px;
    font-size: 12px;
  }

  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin: 0 0 7px;
    padding: 7px;
    border: 1px solid var(--mobile-line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.52);
  }

  .toolbar label {
    grid-column: auto;
    gap: 3px;
    font-size: 11px;
  }

  .toolbar label:has(input[type="search"]) {
    grid-column: 1 / -1;
  }

  .toolbar button {
    min-height: 32px;
    padding: 5px 9px;
    font-size: 12px;
  }

  label {
    gap: 3px;
    font-size: 12px;
  }

  input,
  select {
    min-height: 32px;
    padding: 5px 9px;
    border-radius: 14px;
    font-size: 15px;
  }

  .primary-btn,
  .secondary-btn,
  .danger-btn {
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
  }

  .module-grid {
    gap: 4px;
    margin-top: 4px;
  }

  .module-card {
    min-height: 62px;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 3px 8px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--mobile-line);
    border-radius: 0;
    background: transparent;
  }

  .module-card::after {
    display: none;
  }

  .module-card span {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(92, 199, 178, 0.12);
    color: #237b68;
    font-size: 11px;
  }

  .module-card strong {
    min-width: 0;
    font-size: 16px;
    line-height: 1.15;
  }

  .module-card p {
    overflow: hidden;
    margin: 0;
    color: #667085;
    font-size: 12px;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .auth-layout {
    gap: 6px;
  }

  .hero-panel {
    min-height: 0;
    padding-top: 8px;
  }

  .hero-panel h2 {
    max-width: none;
    font-size: 22px;
  }

  .hero-panel p {
    margin-top: 4px;
    font-size: 13px;
    line-height: 1.35;
  }

  .auth-card {
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--mobile-line);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.58);
  }

  .detail-modal {
    border: 0;
    border-radius: 22px 22px 0 0;
    background: rgba(248, 250, 252, 0.98);
  }

  .modal-head {
    padding: 9px 11px;
    background: rgba(255, 255, 255, 0.74);
  }

  .modal-body {
    gap: 7px;
    padding: 8px;
  }

  .detail-section,
  .formula-card,
  .detail-tile {
    border-radius: 14px;
    padding: 7px 8px;
    background: rgba(255, 255, 255, 0.66);
  }

  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .detail-tile {
    min-height: 0;
  }

  .detail-tile span {
    font-size: 10px;
  }

  .detail-tile strong {
    font-size: 12px;
    line-height: 1.25;
  }
}
