:root {
  --ink: #171715;
  --muted: #716d66;
  --paper: #f5f3ef;
  --panel: #fffefb;
  --line: #ddd8cf;
  --brown: #493625;
  --brown-dark: #261c14;
  --gold: #e1b850;
  --teal: #168674;
  --red: #de4038;
  --shadow: 0 18px 50px rgba(40, 30, 22, .10);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(225,184,80,.12), transparent 30rem),
    var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

.app-header {
  min-height: 92px;
  padding: 20px clamp(20px, 4vw, 58px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: rgba(255, 254, 251, .9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

h1, h2, p { margin: 0; }
.app-header h1 { margin-top: 3px; font-size: clamp(22px, 3vw, 30px); letter-spacing: -.03em; }
.eyebrow, .step-label { color: #9a6f27; font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.header-actions, .panel-heading, .records-heading, .preview-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.header-actions form { margin: 0; }
.save-status { color: var(--teal); font-size: 13px; font-weight: 700; }
.save-status.dirty { color: #b97610; }

.workspace {
  width: min(1580px, calc(100% - 40px));
  margin: 28px auto 56px;
  display: grid;
  grid-template-columns: minmax(680px, 1.25fr) minmax(460px, .75fr);
  gap: 28px;
  align-items: start;
}

.editor-panel, .preview-panel {
  background: var(--panel);
  border: 1px solid rgba(71,54,37,.12);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.editor-panel { padding: clamp(22px, 3vw, 34px); }
.preview-panel { padding: 24px; position: sticky; top: 120px; overflow: hidden; }
.panel-heading h2, .records-heading h2, .preview-toolbar h2 { margin-top: 5px; font-size: 20px; }

.primary-button, .secondary-button, .ghost-button, .export-button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 800;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.primary-button { color: white; background: var(--brown); box-shadow: 0 8px 20px rgba(73,54,37,.2); }
.primary-button:hover, .export-button:hover { transform: translateY(-1px); }
.secondary-button { color: var(--brown); background: #f4ead9; border-color: #ead6b7; }
.ghost-button { min-height: 36px; color: var(--brown); background: white; border-color: var(--line); }
.export-button { color: #2c2218; background: var(--gold); box-shadow: 0 8px 20px rgba(225,184,80,.25); }

.base-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 24px 0 38px;
}
label { color: var(--muted); font-size: 13px; font-weight: 700; }
input, select {
  width: 100%;
  min-height: 42px;
  margin-top: 7px;
  padding: 8px 10px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input:focus, select:focus { border-color: #a87a33; box-shadow: 0 0 0 3px rgba(168,122,51,.12); }

.table-scroll { width: 100%; margin-top: 18px; overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.editor-table { width: 100%; min-width: 790px; border-collapse: collapse; }
.editor-table th { padding: 11px 8px; color: #706b62; background: #f3f0ea; font-size: 12px; text-align: left; white-space: nowrap; }
.editor-table td { padding: 8px; border-top: 1px solid #ebe7df; }
.editor-table input, .editor-table select { min-width: 92px; min-height: 38px; margin: 0; }
.editor-table td:first-child input { min-width: 136px; }
.sort-buttons { white-space: nowrap; }
.sort-buttons button, .delete-button { width: 31px; height: 31px; margin: 0 2px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: white; }
.delete-button { color: var(--red); font-size: 20px; }
.editor-tip { margin-top: 14px; color: #8a8378; font-size: 12px; line-height: 1.6; }

.phone-shell {
  margin-top: 22px;
  padding: 14px;
  background: #29241f;
  border-radius: 28px;
  overflow: auto;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.07);
}
.phone-preview {
  width: 440px;
  margin: 0 auto;
  overflow: hidden;
  color: #171717;
  background: white;
  border-radius: 15px;
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
}
.browser-bar { height: 58px; padding: 0 22px; display: flex; align-items: center; gap: 13px; background: #fafafa; color: #242424; font-size: 19px; }
.shield { color: #8d969c; font-size: 26px; }
.browser-icons { margin-left: auto; color: #788087; font-size: 21px; letter-spacing: 1px; }
.sports-nav { height: 68px; padding: 0 18px; display: flex; align-items: center; gap: 24px; overflow: hidden; color: #e8ded4; background: var(--brown); font-size: 14px; font-weight: 700; white-space: nowrap; }
.sports-nav .home-icon { font-size: 25px; }
.sports-nav .hot { color: #f4c5a7; }
.date-search { padding: 16px 18px; display: grid; grid-template-columns: 1fr 1fr 46px; gap: 10px; background: #fff; }
.date-box { height: 54px; padding: 7px 12px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: 17px 1fr; border: 1px solid #d5d5d5; border-radius: 5px; }
.date-box small { grid-column: 1 / -1; font-size: 12px; }
.date-box strong { font-size: 15px; }
.date-box span { grid-column: 2; grid-row: 1 / -1; align-self: center; font-size: 20px; }
.date-search button { border: 0; border-radius: 5px; color: white; background: #777; font-size: 28px; }
.preview-head, .preview-row { display: grid; grid-template-columns: 1.1fr 1fr 1fr 1.12fr; align-items: center; text-align: center; }
.preview-head { height: 66px; color: white; background: linear-gradient(90deg, #2e2219, #493625); font-size: 14px; }
.preview-row { min-height: 67px; background: #fff; font-size: 14px; }
.preview-row.striped { background: linear-gradient(90deg, #f2f2f2, #e7e7e7, #f0f0f0); }
.preview-row > span { padding: 7px 3px; white-space: nowrap; }
.date-cell { display: flex; flex-direction: column; line-height: 1.15; }
.date-cell strong { font-size: 16px; }
.date-cell b { margin-top: 2px; font-size: 14px; }
.preview-row .profit { color: var(--teal); }
.preview-row .loss { color: var(--red); }
.bottom-nav { height: 72px; display: grid; grid-template-columns: repeat(5, 1fr); color: #eee5dd; background: linear-gradient(90deg, #503c2c, #2d2118, #55402f); }
.bottom-nav > div { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; }
.bottom-nav b { font-size: 16px; }
.bottom-nav .active { color: var(--gold); background: rgba(0,0,0,.15); }
.bottom-nav > div:last-child span { color: #3ec5ac; font-size: 13px; font-weight: 800; }
.demo-strip { padding: 6px 10px; color: #766c62; background: #f7f4ee; border-top: 1px solid #ded7cf; font-size: 9px; text-align: center; letter-spacing: .08em; }

.toast { position: fixed; left: 50%; bottom: 30px; z-index: 99; padding: 12px 18px; color: white; background: #20241f; border-radius: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.2); opacity: 0; transform: translate(-50%, 15px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #a92f2a; }

.login-body { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 42px; background: rgba(255,254,251,.96); border: 1px solid rgba(71,54,37,.12); border-radius: 26px; box-shadow: var(--shadow); }
.brand-mark { width: 52px; height: 52px; margin-bottom: 24px; display: grid; place-items: center; color: white; background: var(--brown); border-radius: 16px; font: 800 24px Georgia, serif; }
.login-card h1 { margin-top: 7px; font-size: 30px; }
.login-note { margin-top: 12px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.login-error { margin-top: 18px; padding: 11px 13px; color: #9a2e28; background: #fff0ef; border: 1px solid #ffd5d2; border-radius: 10px; font-size: 13px; }
.login-form { margin-top: 24px; display: grid; gap: 17px; }
.login-form .primary-button { margin-top: 5px; min-height: 48px; }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
}
@media (max-width: 720px) {
  .app-header { min-height: 76px; padding: 14px 16px; }
  .save-status { display: none; }
  .workspace { width: calc(100% - 20px); margin-top: 10px; gap: 14px; }
  .editor-panel, .preview-panel { padding: 17px; border-radius: 18px; }
  .panel-heading, .records-heading, .preview-toolbar { align-items: flex-start; }
  .panel-heading { flex-direction: column; }
  .panel-heading .primary-button { width: 100%; }
  .base-fields { grid-template-columns: 1fr; margin-bottom: 30px; }
  .phone-shell { margin-inline: -8px; padding: 8px; border-radius: 18px; }
  .phone-preview { margin: 0; }
  .login-card { padding: 30px 24px; }
}
