:root {
  --brand: #1E8E4E;
  --brand-dark: #156B3A;
  --brand-soft: #E8F4EC;
  --ink: #1B1F24;
  --muted: #66717D;
  --line: #DCE1E6;
  --bg: #F3F5F7;
  --card: #FFFFFF;
  --danger: #B3261E;
  --warn-bg: #FFF6E0;
  --warn-ink: #7A5200;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", "Noto Sans SC", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 16px 0 8px; color: var(--muted); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #12261B; color: #D6E6DC; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.side .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; font-weight: 700; font-size: 15px; }
.side .brand img { width: 34px; height: 34px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.side nav a { display: flex; align-items: center; gap: 10px; color: #D6E6DC; padding: 9px 12px; border-radius: 8px; margin: 2px 0; }
.side nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.side nav a.on { background: var(--brand); color: #fff; }
.side nav .sep { height: 1px; background: rgba(255, 255, 255, .1); margin: 12px 8px; }
.side .who { margin-top: 18px; padding: 10px 12px; font-size: 12px; color: #9DB5A6; border-top: 1px solid rgba(255, 255, 255, .1); }
.side .who form { display: inline; }
.side .who button { background: none; border: 0; color: #CDE3D5; cursor: pointer; padding: 0; font-size: 12px; text-decoration: underline; }
.side .ver { padding: 8px 12px 0; font-size: 11px; color: #6F8F7C; }
.main { padding: 24px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; }
.hero .card { margin: 0; }
.big-action { border: 2px solid var(--brand); }
.big-action h2 { color: var(--brand-dark); font-size: 18px; }

/* forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 64px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(30, 142, 78, .25); border-color: var(--brand); }
.field { margin-bottom: 12px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 14px; }
.fields .wide { grid-column: 1 / -1; }
.hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); margin: 0 14px 0 0; cursor: pointer; }
.check input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px 4px; margin: 0 0 16px; }
legend { font-weight: 600; padding: 0 6px; color: var(--brand-dark); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #B9C2CB; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.lg { padding: 11px 18px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* tables */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 9px 10px; border-bottom: 1px solid #EEF1F4; vertical-align: middle; }
table.list tr:hover td { background: #FAFBFC; }
table.list .num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; background: #EEF1F4; color: var(--muted); }
.badge.ok { background: var(--brand-soft); color: var(--brand-dark); }
.badge.red { background: #FBE9EA; color: #9B1C22; }
.thumb { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; background: #EEF1F4; display: block; }

/* flash & notices */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; background: var(--brand-soft); color: var(--brand-dark); }
.flash.error { background: #FBE9EA; color: #8E1B20; }
.notice { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; font-size: 13px; }
.notice a { color: var(--warn-ink); text-decoration: underline; }
.ok-box { background: var(--brand-soft); color: var(--brand-dark); border-radius: 8px; padding: 10px 14px; font-size: 13px; }

/* editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 42%); gap: 16px; align-items: start; }
.editor.full { grid-template-columns: 1fr; }
.editor.full .preview { display: none; }
.preview { position: sticky; top: 12px; }
.preview iframe { width: 100%; height: calc(100vh - 120px); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.save-state { font-size: 12px; color: var(--muted); }
.price-grid { width: 100%; border-collapse: separate; border-spacing: 0; }
.price-grid th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; padding: 6px; border-bottom: 1px solid var(--line); vertical-align: bottom; background: #FAFBFC; position: sticky; top: 0; }
.price-grid td { padding: 6px; border-bottom: 1px solid #EEF1F4; vertical-align: top; }
.price-grid .pname { min-width: 180px; }
.price-grid .pname b { display: block; }
.price-grid input.price { width: 92px; text-align: right; font-size: 15px; font-weight: 600; padding: 6px 8px; }
.price-grid input.small-in { width: 64px; padding: 5px 6px; }
.price-grid input.note-in { width: 140px; padding: 5px 6px; font-size: 12px; }
.prev { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.up { color: #B3261E; }
.down { color: var(--brand-dark); }
.col-head { min-width: 110px; }
.col-head input { padding: 4px 6px; font-size: 12px; margin-bottom: 3px; }
.col-head .inc { width: 64px; font-weight: 700; }
.row-tools { white-space: nowrap; }
.row-tools button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px 4px; font-size: 14px; }
.row-tools button:hover { color: var(--ink); }
.adder { display: flex; gap: 8px; margin-top: 12px; align-items: center; flex-wrap: wrap; }
.adder select { max-width: 360px; }
.scroll-x { overflow-x: auto; }
.lines-table input { padding: 5px 6px; font-size: 13px; }
.lines-table .w60 { width: 60px; } .lines-table .w80 { width: 80px; } .lines-table .w100 { width: 100px; } .lines-table .w140 { width: 140px; }
.totals { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 12px; padding: 10px 14px; background: var(--brand-soft); border-radius: 8px; }
.totals div { font-size: 12px; color: var(--muted); }
.totals b { display: block; font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.checks { margin: 0; padding-left: 18px; color: var(--warn-ink); font-size: 13px; }
.gen-box { border: 2px solid var(--brand); }
.doc-pick { display: flex; flex-wrap: wrap; gap: 6px 0; margin: 8px 0 12px; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; flex-wrap: wrap; }
.tabs button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 12px; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }

/* settings assets */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.asset { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.asset .img { height: 150px; display: flex; align-items: center; justify-content: center; border-radius: 8px; margin-bottom: 10px;
  background-color: #fff; background-image: linear-gradient(45deg, #F0F2F4 25%, transparent 25%), linear-gradient(-45deg, #F0F2F4 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #F0F2F4 75%), linear-gradient(-45deg, transparent 75%, #F0F2F4 75%);
  background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0; }
.asset .img img { max-width: 100%; max-height: 140px; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #12261B 0%, #1E8E4E 100%); padding: 16px; }
.login { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 30px 28px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.login img { height: 46px; display: block; margin: 0 auto 14px; }
.login h1 { text-align: center; font-size: 18px; margin-bottom: 20px; }

@media (max-width: 1100px) {
  .editor { grid-template-columns: 1fr; }
  .preview iframe { height: 70vh; }
  .hero, .grid2, .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; }
  .side nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .side nav .sep { display: none; }
  .main { padding: 16px; }
}
