:root {
  --ink: #252b27;
  --muted: #7d837d;
  --line: #e7e8e3;
  --paper: #f5f2eb;
  --surface: #fffefb;
  --green: #6f895b;
  --green-dark: #263129;
  --green-soft: #e6ede0;
  --rose: #b85d68;
  --shadow: 0 18px 55px rgba(38, 49, 41, .09);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 7% 6%, rgba(166, 185, 151, .27), transparent 25rem),
    var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  color: #fff; font-weight: 900; background: linear-gradient(145deg, #9aaf88, #627852);
  box-shadow: 0 8px 20px rgba(99, 123, 81, .25);
}
.brand b, .brand small { display: block; }
.brand b { letter-spacing: .19em; font-size: 14px; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.eyebrow {
  color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .18em;
  text-transform: uppercase;
}

.login-view {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr);
  align-items: center; gap: 7vw; padding: clamp(26px, 6vw, 88px);
}
.login-copy { max-width: 680px; }
.login-copy h1 { font-size: clamp(37px, 5.3vw, 72px); line-height: 1.08; letter-spacing: -.05em; margin: 20px 0; }
.login-copy > p { max-width: 560px; color: #626a63; font-size: 17px; line-height: 1.85; }
.feature-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 30px; }
.feature-row span {
  border: 1px solid rgba(111, 137, 91, .24); color: #556548; background: rgba(255, 255, 255, .54);
  padding: 9px 13px; border-radius: 999px; font-size: 12px;
}
.login-card {
  width: 100%; max-width: 470px; justify-self: end; background: rgba(255, 254, 251, .94);
  border: 1px solid rgba(255, 255, 255, .82); border-radius: 28px; padding: 38px;
  box-shadow: var(--shadow); backdrop-filter: blur(18px);
}
.login-card > div:nth-child(2) { margin: 38px 0 26px; }
.login-card h2 { margin: 0; font-size: 25px; }
.login-card > div p { color: var(--muted); font-size: 13px; margin: 8px 0 0; }
.login-card form, .form-grid { display: grid; gap: 16px; }
label { color: #555d56; font-size: 12px; font-weight: 650; }
input, select, textarea {
  width: 100%; min-height: 46px; margin-top: 7px; border: 1px solid var(--line);
  border-radius: 12px; background: #fbfbf8; color: var(--ink); padding: 0 13px; outline: 0;
}
textarea { min-height: 132px; padding-top: 12px; resize: vertical; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: #9bb28a; box-shadow: 0 0 0 3px rgba(111, 137, 91, .12); }
.primary, .secondary, .text-button {
  border: 0; border-radius: 12px; min-height: 43px; padding: 0 17px; font-weight: 750;
}
.primary { color: #fff; background: var(--green); box-shadow: 0 8px 17px rgba(111, 137, 91, .22); }
.primary:hover { background: #60784e; }
.primary:disabled { opacity: .55; cursor: wait; }
.wide { width: 100%; margin-top: 5px; }
.secondary { color: #596257; background: #f0f1ec; }
.text-button { min-height: 36px; color: var(--muted); background: transparent; }
.security-note { display: block; color: #9a9f99; font-size: 10px; line-height: 1.6; text-align: center; margin-top: 22px; }
.form-error { min-height: 19px; margin: 9px 0 0; color: var(--rose); font-size: 11px; }

.admin-view { min-height: 100vh; }
.topbar {
  height: 74px; position: sticky; top: 0; z-index: 10; display: flex; align-items: center;
  justify-content: space-between; padding: 0 28px; background: rgba(255, 254, 251, .9);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(18px);
}
.top-actions { display: flex; align-items: center; gap: 15px; }
.company-filter { display: flex; align-items: center; gap: 9px; font-size: 11px; }
.company-filter select { width: auto; min-height: 36px; margin: 0; padding-right: 34px; }
.company-filter select:disabled { color: #43543a; opacity: 1; cursor: not-allowed; background: var(--green-soft); }
.company-filter em {
  padding: 5px 8px; border-radius: 999px; color: #5b714e; background: var(--green-soft);
  font-size: 9px; font-style: normal; font-weight: 800; white-space: nowrap;
}
.account { display: flex; align-items: center; gap: 9px; padding-left: 15px; border-left: 1px solid var(--line); }
.account > span {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px;
  color: #526344; background: var(--green-soft); font-weight: 850;
}
.account b, .account small { display: block; }
.account b { font-size: 12px; }
.account small { color: var(--muted); font-size: 9px; margin-top: 3px; }
.workspace { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 74px); }
.sidebar {
  display: flex; flex-direction: column; justify-content: space-between; padding: 28px 18px;
  background: #2a302b; color: #fff; overflow-y: auto;
}
nav { display: grid; gap: 7px; }
.nav-divider {
  margin: 15px 10px 2px; color: #929b93; font-size: 9px; font-weight: 700;
  letter-spacing: .12em;
}
.nav-divider:first-child { margin-top: 0; }
nav button {
  display: flex; align-items: center; gap: 12px; border: 0; border-radius: 13px;
  padding: 11px 12px; color: #c9cec9; background: transparent; text-align: left;
}
nav button span {
  width: 29px; height: 29px; display: grid; place-items: center; border-radius: 9px;
  color: #c8d5bd; background: rgba(255, 255, 255, .07); font-size: 11px;
}
nav button.active { color: #fff; background: rgba(255, 255, 255, .1); }
nav button.active span { background: var(--green); color: #fff; }
.sync-card { padding: 16px; border-radius: 16px; background: rgba(255, 255, 255, .06); }
.sync-card i { display: block; width: 8px; height: 8px; margin-bottom: 11px; border-radius: 50%; background: #93bf77; box-shadow: 0 0 0 5px rgba(147, 191, 119, .12); }
.sync-card b { font-size: 11px; }
.sync-card p { margin: 6px 0 0; color: #aeb6af; font-size: 9px; line-height: 1.6; }
.content { min-width: 0; padding: 34px clamp(20px, 4vw, 55px) 60px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.heading-actions { display: flex; align-items: center; gap: 9px; }
.page-heading h1 { margin: 8px 0 5px; font-size: clamp(28px, 3vw, 40px); letter-spacing: -.04em; }
.page-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.overview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.overview article { padding: 19px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.overview span, .overview strong, .overview small { display: block; }
.overview span, .overview small { color: var(--muted); font-size: 10px; }
.overview strong { margin: 7px 0 4px; font-size: 27px; }
.data-panel { border: 1px solid var(--line); border-radius: 20px; background: var(--surface); overflow: hidden; }
.panel-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 15px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1; }
.search span { position: absolute; left: 14px; top: 23px; color: #8e958e; }
.search input { margin: 0; padding-left: 36px; }
.panel-tools select { width: 155px; margin: 0; }
.month-filter { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.month-filter input { width: 145px; min-height: 43px; margin: 0; }
.data-list article {
  display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(120px, .7fr) minmax(130px, .75fr) minmax(110px, .6fr) auto;
  align-items: center; gap: 18px; padding: 17px 20px; border-bottom: 1px solid var(--line);
}
.data-list article:last-child { border-bottom: 0; }
.identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar, .product-thumb {
  width: 43px; height: 43px; flex: none; display: grid; place-items: center; overflow: hidden;
  border-radius: 13px; color: #5c6f50; background: var(--green-soft); font-weight: 850;
}
.product-thumb img { width: 100%; height: 100%; object-fit: cover; }
.identity b, .identity span, .cell b, .cell span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.identity b, .cell b { font-size: 12px; }
.identity span, .cell span { margin-top: 5px; color: var(--muted); font-size: 9px; }
.status { justify-self: start; padding: 6px 9px; border-radius: 999px; color: #398153; background: #e9f5ec; font-size: 9px; }
.status.off { color: #9a6066; background: #f7e9eb; }
.edit-button { border: 0; border-radius: 10px; padding: 8px 11px; color: #5a6d4e; background: var(--green-soft); font-size: 10px; }
.rule-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.rule-summary em {
  padding: 4px 7px; border-radius: 999px; color: #5d704f; background: var(--green-soft);
  font-size: 9px; font-style: normal;
}
.report-list { display: block; }
.report-section + .report-section { border-top: 12px solid var(--paper); }
.report-section h3 { margin: 0; padding: 15px; font-size: 13px; }
.report-table-wrap { width: 100%; overflow: auto; }
.report-table { width: 100%; min-width: 920px; border-collapse: collapse; font-size: 11px; }
.report-table th {
  position: sticky; top: 0; z-index: 1; padding: 12px 14px; color: #697168;
  background: #f3f4ef; text-align: left; white-space: nowrap;
}
.report-table td { padding: 13px 14px; border-top: 1px solid var(--line); white-space: nowrap; }
.report-table td.money { color: #536a45; font-weight: 800; }
.report-table td.danger { color: var(--rose); }
.report-table .subtle { color: var(--muted); }
.report-note { padding: 12px 15px; color: var(--muted); background: #fbfbf8; font-size: 10px; line-height: 1.6; }
.list-notice {
  padding: 13px 16px; color: var(--muted); background: #fbfbf8;
  border-top: 1px solid var(--line); font-size: 10px; line-height: 1.6;
}
.inline-filter {
  display: flex; align-items: end; justify-content: space-between; gap: 18px;
  padding: 16px; border-bottom: 1px solid var(--line); background: #fbfbf8;
}
.inline-filter label { width: 210px; }
.inline-filter small { color: var(--muted); font-size: 10px; line-height: 1.6; }
.tool-panel { padding: clamp(20px, 4vw, 42px); }
.tool-copy { max-width: 720px; }
.tool-copy h2, .code-panel h2 { margin: 7px 0 9px; font-size: 24px; }
.tool-copy p, .code-panel p {
  margin: 0; color: var(--muted); font-size: 12px; line-height: 1.75;
}
.file-drop.compact { min-height: 126px; margin: 24px 0 0; }
.file-drop.compact b { margin-top: 8px; font-size: 13px; }
.tool-actions { display: flex; gap: 10px; margin-top: 15px; }
.tool-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; margin: 22px 0 14px;
}
.tool-summary article {
  padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fbfbf8;
}
.tool-summary span, .tool-summary strong { display: block; }
.tool-summary span { color: var(--muted); font-size: 9px; }
.tool-summary strong { margin-top: 6px; font-size: 22px; }
.code-panel { max-width: 700px; margin: 0 auto; padding: 55px 24px; text-align: center; }
.code-panel > strong {
  display: block; margin: 28px 0 13px; color: var(--green-dark);
  font-size: clamp(54px, 9vw, 92px); letter-spacing: .16em;
}
.code-panel .primary { margin: 24px auto 15px; }
.code-panel > small {
  display: block; max-width: 520px; margin: 0 auto; color: var(--muted);
  font-size: 10px; line-height: 1.7;
}
.empty-state { padding: 60px 20px; text-align: center; }
.empty-state span { font-weight: 800; }
.empty-state p { color: var(--muted); font-size: 11px; }

dialog {
  width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 34px); overflow: auto;
  border: 0; border-radius: 24px; padding: 0; background: var(--surface); box-shadow: 0 25px 80px rgba(23, 31, 25, .22);
}
dialog::backdrop { background: rgba(28, 35, 29, .52); backdrop-filter: blur(3px); }
#record-form, #import-form { padding: 28px; }
.dialog-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 23px; }
.dialog-heading h2 { margin: 6px 0 0; font-size: 23px; }
.close-button { width: 36px; height: 36px; border: 0; border-radius: 11px; color: #717771; background: #f0f1ec; font-size: 21px; }
.form-grid { grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.switch-label { display: flex; align-items: center; justify-content: space-between; min-height: 46px; margin-top: 7px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: #fbfbf8; }
.switch-label input { width: 18px; min-height: 18px; margin: 0; accent-color: var(--green); }
.image-preview { width: 100%; height: 145px; margin-top: 8px; border-radius: 14px; object-fit: cover; background: #f0f1ec; }
.import-guide { padding: 16px; border-radius: 16px; background: var(--green-soft); }
.import-guide b { font-size: 12px; }
.import-guide p { margin: 7px 0 13px; color: #65715f; font-size: 10px; line-height: 1.65; }
.file-drop {
  display: grid; place-items: center; min-height: 150px; margin-top: 16px; padding: 20px;
  border: 1px dashed #b9c7af; border-radius: 16px; background: #fbfbf8; text-align: center;
}
.file-drop input { width: min(360px, 100%); margin: 13px auto 6px; padding: 10px; background: #fff; }
.file-drop span { color: var(--muted); font-size: 9px; }
.import-preview { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.import-preview article { padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.import-preview span, .import-preview strong { display: block; }
.import-preview span { color: var(--muted); font-size: 9px; }
.import-preview strong { margin-top: 5px; font-size: 20px; }
.import-errors { grid-column: 1 / -1; max-height: 150px; overflow: auto; padding: 11px 13px; border-radius: 12px; color: #95515b; background: #fbebed; font-size: 10px; line-height: 1.7; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: min(360px, calc(100vw - 30px));
  padding: 12px 16px; border-radius: 12px; color: #fff; background: #283129; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s ease; font-size: 11px;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .login-view { grid-template-columns: 1fr; gap: 35px; }
  .login-card { justify-self: start; }
  .workspace { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { padding: 22px 8px; }
  .nav-divider, nav button:not(.active) { font-size: 0; }
  nav button { justify-content: center; padding: 10px; font-size: 0; }
  nav button span { font-size: 11px; }
  .sync-card { display: none; }
  .data-list article { grid-template-columns: minmax(180px, 1fr) minmax(110px, .6fr) auto; }
  .data-list article .cell:nth-of-type(2), .data-list article .cell:nth-of-type(3) { display: none; }
}

@media (max-width: 640px) {
  .login-view { display: block; padding: 23px 16px; }
  .login-copy { padding: 25px 6px 36px; }
  .login-copy h1 { font-size: 39px; }
  .login-copy > p { font-size: 14px; }
  .login-card { padding: 26px 20px; border-radius: 22px; }
  .topbar { height: auto; min-height: 68px; padding: 10px 13px; }
  .brand small, .account div, .text-button, .company-filter > span { display: none; }
  .top-actions { gap: 8px; }
  .company-filter select { max-width: 125px; }
  .company-filter em { display: none; }
  .workspace { display: block; }
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: 66px;
    display: block; padding: 7px 8px; border-top: 1px solid rgba(255, 255, 255, .12);
    overflow: hidden;
  }
  .sidebar nav { display: flex; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav button, .sidebar nav button:not(.active) { min-width: 98px; color: #d5dad5; font-size: 10px; }
  .sidebar .nav-divider { display: none; }
  .content { padding: 25px 13px 90px; }
  .page-heading { align-items: start; }
  .heading-actions { align-items: stretch; flex-direction: column-reverse; }
  .page-heading #create-button { min-width: 44px; width: 44px; padding: 0; font-size: 0; align-self: end; }
  .page-heading #create-button::first-letter { font-size: 18px; }
  .page-heading #import-button { padding: 0 11px; font-size: 10px; }
  .overview { gap: 7px; }
  .overview article { padding: 13px 11px; }
  .overview strong { font-size: 22px; }
  .panel-tools { display: grid; grid-template-columns: 1fr auto; }
  .search { grid-column: 1 / -1; }
  .panel-tools select { width: 100%; }
  .month-filter { grid-column: 1 / -1; justify-content: space-between; }
  .month-filter input { flex: 1; width: auto; }
  #export-button { grid-column: 1 / -1; }
  .data-list article { grid-template-columns: 1fr auto; gap: 10px; padding: 15px; }
  .data-list article .cell, .data-list article .status { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  #record-form, #import-form { padding: 22px 17px; }
  .import-preview { grid-template-columns: 1fr 1fr; }
  .tool-summary { grid-template-columns: 1fr 1fr; }
  .inline-filter { align-items: stretch; flex-direction: column; }
  .inline-filter label { width: 100%; }
  .tool-actions { align-items: stretch; flex-direction: column; }
  .code-panel > strong { letter-spacing: .08em; }
}
