/* PIM Finance: shared semantic colors keep every workspace in sync. */
:root {
  color-scheme: light;
  --ink: #1b352d;
  --muted: #5c7368;
  --green: #126b50;
  --green-hover: #0c5941;
  --on-green: #fff;
  --line: #dce5df;
  --line-soft: #eaf0ec;
  --paper: #fff;
  --surface: #fff;
  --surface-soft: #f4f8f5;
  --surface-hover: #edf5ef;
  --bg: #f3f6f3;
  --nav: #102f25;
  --nav-active: #215440;
  --nav-hover: #1a4435;
  --nav-text: #bed2c6;
  --nav-muted: #91b2a1;
  --input: #fff;
  --input-border: #b8cbbf;
  --focus: #087650;
  --accent-soft: #e6f3eb;
  --accent-border: #b0d7c1;
  --warning-bg: #fff7e5;
  --warning-ink: #795615;
  --warning-border: #ead5a6;
  --danger: #a6382d;
  --danger-bg: #fff0ed;
  --danger-border: #efc2b9;
  --success-bg: #edf7ef;
  --success-ink: #286342;
  --success-border: #b9dcc6;
  --shadow: 0 3px 14px #16382305;
  --modal-shadow: 0 20px 70px #061f2633;
  --overlay: #071e29a3;
  --auth-bg: linear-gradient(130deg, #113629 0%, #1c5140 62%, #26775b 100%);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e5efe8;
  --muted: #a5b9ad;
  --green: #80d8ad;
  --green-hover: #a0e7c1;
  --on-green: #102d20;
  --line: #30493b;
  --line-soft: #283d31;
  --surface: #182c21;
  --surface-soft: #1e3327;
  --surface-hover: #263f30;
  --bg: #102018;
  --nav: #0d1b15;
  --nav-active: #284e39;
  --nav-hover: #1d3628;
  --nav-text: #b8cebe;
  --nav-muted: #8fac98;
  --input: #14271c;
  --input-border: #4e6c58;
  --focus: #a1ebc5;
  --accent-soft: #264b35;
  --accent-border: #4a815f;
  --warning-bg: #362f1d;
  --warning-ink: #ebcc8b;
  --warning-border: #655533;
  --danger: #ffafa0;
  --danger-bg: #3c2522;
  --danger-border: #76453c;
  --success-bg: #213e2a;
  --success-ink: #a1dbb2;
  --success-border: #446a4c;
  --shadow: 0 3px 18px #00000012;
  --modal-shadow: 0 22px 80px #00000066;
  --overlay: #020a08bd;
  --auth-bg: linear-gradient(130deg, #0b1912 0%, #122c1c 62%, #1d4b30 100%);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; }
button, input, textarea, select { font: inherit; }
a { color: var(--green); text-underline-offset: 3px; }
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 10px 15px;
  min-height: 40px;
  border-radius: 8px;
  line-height: 1.4;
  transition: background-color .15s, border-color .15s, box-shadow .15s;
  touch-action: manipulation;
}
button:hover { background: var(--surface-hover); border-color: var(--accent-border); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
.primary { background: var(--green); color: var(--on-green); border-color: var(--green); font-weight: 600; }
.primary:hover { background: var(--green-hover); border-color: var(--green-hover); }
.ghost { background: transparent; border-color: transparent; color: inherit; }
.danger { color: var(--danger); }
.small { padding: 6px 10px; font-size: 12px; min-height: 34px; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 7px;
  padding: 10px;
  background: var(--input);
  min-width: 0;
  color: var(--ink);
  line-height: 1.5;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
input:disabled, textarea:disabled, select:disabled { background: var(--surface-soft); opacity: .7; cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--green); vertical-align: middle; }
input[type="color"] { height: 44px; padding: 5px; }
input[type="file"]::file-selector-button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); color: var(--ink); margin-right: 10px; cursor: pointer; }
textarea { resize: vertical; line-height: 1.6; }
label { display: block; color: var(--muted); font-size: 12px; margin: 0 0 6px; line-height: 1.5; }
summary { cursor: pointer; line-height: 1.6; color: var(--ink); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 25px; letter-spacing: -.5px; margin-bottom: 7px; line-height: 1.35; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { line-height: 1.65; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.layout { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--nav);
  color: var(--nav-text);
  position: fixed;
  inset: 0 auto 0 0;
  width: 228px;
  padding: 30px 18px;
  display: flex;
  flex-direction: column;
  z-index: 20;
  overflow-y: auto;
  scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; letter-spacing: .3px; font-size: 20px; margin-bottom: 36px; white-space: nowrap; }
.brand span { background: #267a54; border: 1px solid #78b99966; border-radius: 10px; padding: 8px 11px; color: #fff; font-size: 17px; }
.navlabel { font-size: 10px; letter-spacing: 1.6px; color: var(--nav-muted); margin: 20px 14px 8px; }
.navbutton { display: flex; align-items: center; gap: 12px; width: 100%; background: transparent; color: inherit; border: 1px solid transparent; text-align: left; margin: 3px 0; padding: 12px 14px; }
.navbutton.active { background: var(--nav-active); border-color: #6ba18345; color: #fff; font-weight: 600; }
.navbutton:hover { background: var(--nav-hover); border-color: transparent; }
.navbutton.active:hover { background: var(--nav-active); border-color: #6ba18345; }
.sidebar button:focus-visible { outline-color: #9fe5bc; }
.navicon { width: 19px; text-align: center; font-size: 16px; }
.sidebarfoot { margin-top: auto; border-top: 1px solid #4f76644d; padding: 18px 12px 0; font-size: 12px; line-height: 1.8; }
.content { grid-column: 2; min-width: 0; }
.topbar { min-height: 76px; border-bottom: 1px solid var(--line); background: var(--surface); display: flex; justify-content: space-between; align-items: center; padding: 16px 34px; gap: 16px; }
.company { max-width: 220px; width: auto; min-width: 120px; border-color: transparent; font-weight: 600; background: var(--surface-soft); }
.topright { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.avatar { width: 33px; height: 33px; background: var(--accent-soft); color: var(--green); border-radius: 50%; display: grid; place-items: center; font-weight: 600; }
.testtag { background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning-ink); font-size: 11px; padding: 5px 9px; border-radius: 5px; white-space: nowrap; }
.main { padding: 32px 34px 48px; max-width: 1800px; margin: auto; }
.pagehead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; gap: 18px; }
.pagehead > div:first-child { min-width: 0; }
.pagehead p { margin: 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions > button { flex-shrink: 0; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin: 24px 0; }
.card, .panel { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 23px; box-shadow: var(--shadow); }
.card .metric { font-size: 28px; font-weight: 650; letter-spacing: -.8px; margin: 14px 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.card .eyebrow { font-size: 12px; color: var(--muted); }
.card .foot { font-size: 11px; color: var(--muted); line-height: 1.5; }
.card .dot { float: right; color: var(--green); font-size: 18px; }
.panel { margin-bottom: 22px; }
.panelhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.panelhead h2, .panelhead h3 { margin: 0; }
.notice { border: 1px solid var(--warning-border); background: var(--warning-bg); color: var(--warning-ink); padding: 12px 16px; border-radius: 8px; font-size: 12px; line-height: 1.7; margin-bottom: 22px; overflow-wrap: anywhere; }
.notice.good { background: var(--success-bg); color: var(--success-ink); border-color: var(--success-border); }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 22px; }
.tablewrap { overflow-x: auto; max-width: 100%; overscroll-behavior-x: contain; scrollbar-width: thin; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th { font-size: 11px; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 12px 10px; background: var(--surface-soft); }
td { padding: 15px 10px; border-bottom: 1px solid var(--line-soft); font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.docname { font-weight: 600; color: var(--green); }
.badge { display: inline-block; border-radius: 5px; padding: 4px 8px; background: var(--surface-soft); color: var(--muted); font-size: 11px; line-height: 1.5; }
.badge.green { background: var(--accent-soft); color: var(--green); }
.badge.amber { background: var(--warning-bg); color: var(--warning-ink); }
.number { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); line-height: 1.7; }
.empty strong { display: block; color: var(--ink); font-weight: 500; margin-bottom: 10px; }
.connector { padding: 15px 0; border-bottom: 1px solid var(--line-soft); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.connector:last-child { border: 0; }
.connector > div { min-width: 0; }
.connector strong { display: block; font-size: 13px; margin-bottom: 5px; }
.connector p { margin: 0; font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
.connector .badge { flex-shrink: 0; }
.formgrid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.field { margin-bottom: 14px; min-width: 0; }
.wide { grid-column: 1 / -1; }
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .85fr); align-items: start; gap: 24px; }
.editor > * { min-width: 0; }
.editor .panel { padding: 22px; }
.previewwrap { position: sticky; top: 20px; min-width: 0; }
.previewlabel { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; color: var(--muted); font-size: 11px; gap: 8px; }
/* A document preview is always white, just like the exported/printed document. */
.paper { color-scheme: light; background: #fff; border: 1px solid #d5dfd9; box-shadow: 0 7px 28px #051e1b14; padding: 35px 35px 26px; min-height: 680px; font-family: Arial, sans-serif; color: #263b32; overflow-wrap: anywhere; }
.paper .letterbrand { font-size: 24px; font-weight: bold; margin-bottom: 10px; }
.paper .letteraddress { font-size: 9px; white-space: pre-line; line-height: 1.6; color: #607366; min-height: 35px; }
.paper .recipient { margin: 23px 0; font-size: 11px; line-height: 1.6; white-space: pre-line; }
.paper h2 { font-size: 22px; margin: 22px 0 13px; }
.paper .meta { font-size: 9px; margin-bottom: 22px; }
.paper p { font-size: 10px; white-space: pre-line; }
.paper table { white-space: normal; font-size: 9px; }
.paper th { font-size: 8px; color: #fff; padding: 8px 6px; background: transparent; border-color: #dce5df; }
.paper td { font-size: 9px; padding: 10px 6px; vertical-align: top; word-break: break-word; border-color: #e7ece8; }
.paper .muted { color: #607366; }
.paper .totals { margin: 22px 0 25px; text-align: right; font-size: 10px; line-height: 1.9; }
.paper .grand { font-size: 15px; font-weight: bold; margin-top: 5px; }
.paper .paperfooter { margin-top: 40px; font-size: 8px; color: #607366; border-top: 1px solid #dce5df; padding-top: 13px; }
.paper .watermark { font-size: 8px; color: #8a692b; margin-top: 20px; text-align: center; }
.lines { display: grid; gap: 12px; }
.linecard { background: var(--surface-soft); border: 1px solid var(--line); padding: 13px; border-radius: 8px; }
.linerow { display: grid; grid-template-columns: 2fr .65fr .9fr .65fr 34px; gap: 8px; margin-top: 8px; align-items: end; }
.linerow > * { min-width: 0; }
.linerow label { font-size: 10px; }
.linecard input, .linecard select { font-size: 12px; padding: 8px; }
.linecard .linetop { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-bottom: 7px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px; }
.tabs button.active { background: var(--accent-soft); color: var(--green); border-color: var(--accent-border); font-weight: 600; }
.stack { display: grid; gap: 8px; }
.block { padding: 15px; border: 1px solid var(--input-border); border-radius: 7px; cursor: grab; background: var(--surface-soft); display: flex; justify-content: space-between; gap: 12px; }
.block.dragging { opacity: .4; }
.statsbar { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 10px 0; border-top: 1px solid var(--line); }
.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; background: var(--auth-bg); padding: 24px; }
.authbox { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; width: 500px; max-width: 100%; padding: 40px; box-shadow: var(--modal-shadow); }
.authhead { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 30px; }
.authbox .brand { color: var(--ink); margin-bottom: 32px; }
.authhead .brand { margin-bottom: 0; }
.authbox h1 { font-size: 22px; }
.authbox p { color: var(--muted); font-size: 13px; }
.authbox form button { width: 100%; margin-top: 16px; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; font-size: 12px; padding: 8px 11px; min-height: 38px; flex-shrink: 0; background: var(--surface-soft); }
.theme-toggle svg { flex-shrink: 0; }
.loading { padding: 80px 24px; text-align: center; color: var(--muted); line-height: 1.6; }
#toast { display: none; position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%); background: #163e2c; color: #fff; border: 1px solid #7ea58d; border-radius: 10px; padding: 13px 22px; max-width: min(90vw, 640px); z-index: 100; box-shadow: var(--modal-shadow); line-height: 1.6; overflow-wrap: anywhere; }
.divider { height: 1px; background: var(--line); margin: 22px 0; }
.mobilebrand { display: none; }
.activity { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 12px; display: flex; justify-content: space-between; gap: 15px; }
.activity > div { min-width: 0; overflow-wrap: anywhere; }
.search { max-width: 270px; }
.statusrow { display: flex; align-items: center; gap: 9px; margin-bottom: 22px; flex-wrap: wrap; }
.statusrow span { font-size: 12px; }
.pagehead .titlemeta { display: flex; align-items: center; gap: 12px; }
.templatepreview { min-height: 540px; }
.attachnote { color: var(--muted); font-size: 11px; }
.kbd { font-size: 11px; padding: 2px 5px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); }
.dangerbox { background: var(--danger-bg); border: 1px solid var(--danger-border); padding: 12px; border-radius: 7px; color: var(--danger); font-size: 12px; line-height: 1.6; overflow-wrap: anywhere; }
.modalshade { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 70; padding: 20px; }
.modal { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; width: 510px; max-width: 100%; max-height: 90vh; max-height: 90dvh; overflow: auto; overscroll-behavior: contain; padding: 28px; box-shadow: var(--modal-shadow); }
.modal h2 { margin-bottom: 20px; }
.fileinput { padding: 8px; font-size: 12px; }
@media (max-width: 1200px) {
  .editor { grid-template-columns: minmax(0, 1fr); }
  .previewwrap { position: static; max-width: 650px; margin: auto; width: 100%; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .main { padding: 26px 24px; }
  .sidebar { width: 200px; padding-inline: 12px; }
  .sidebar .brand { font-size: 18px; gap: 8px; }
  .layout { grid-template-columns: 200px minmax(0, 1fr); }
  .topbar { padding: 16px 24px; }
  .topright { gap: 10px; }
  .pagehead { flex-wrap: wrap; }
}
@media (max-width: 900px) {
  .topright .tiny, .topright .avatar { display: none; }
  .topbar { padding-inline: 20px; }
}
@media (max-width: 700px) {
  .layout { display: block; }
  .sidebar { position: static; width: 100%; padding: 10px 14px; display: block; }
  .sidebar .brand, .navlabel, .sidebarfoot { display: none; }
  .sidebar nav { display: flex; overflow-x: auto; gap: 4px; scrollbar-width: thin; overscroll-behavior-x: contain; padding: 3px; }
  .navbutton { width: auto; white-space: nowrap; padding: 10px; font-size: 12px; flex-shrink: 0; min-height: 44px; }
  .navicon { display: none; }
  .content { display: block; }
  .topbar { min-height: 64px; padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .company { max-width: 220px; min-width: 0; flex: 1; }
  .topright { gap: 8px; }
  .topright .theme-toggle-label { display: none; }
  .topright .theme-toggle { min-width: 44px; padding: 10px; }
  .main { padding: 22px 14px; }
  .pagehead { align-items: flex-start; gap: 14px; }
  .pagehead h1 { font-size: 22px; }
  .pagehead .actions { width: 100%; justify-content: flex-start; }
  .cards { gap: 10px; }
  .card { padding: 17px; }
  .card .metric { font-size: 22px; }
  .card .foot { font-size: 11px; }
  .panel { padding: 17px; }
  .panelhead { flex-wrap: wrap; }
  .formgrid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .wide { grid-column: 1; }
  .editor { display: block; }
  .editor .panel { padding: 17px; }
  .linerow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .linerow > button { justify-self: end; grid-column: 2; min-width: 44px; }
  .linecard input, .linecard select { font-size: 16px; }
  .linecard .linetop { grid-template-columns: minmax(0, 1fr); }
  .paper { padding: 25px 20px; min-height: 620px; }
  .testtag { font-size: 10px; }
  .auth { padding: 18px; }
  .authbox { padding: 28px; }
  .authhead { gap: 10px; }
  .authhead .brand { font-size: 18px; }
  .authhead .theme-toggle-label { display: none; }
  .authhead .theme-toggle { min-width: 44px; }
  .search { max-width: 100%; }
  .previewlabel { margin-top: 20px; }
  button, .small { min-height: 44px; }
  input, textarea, select { font-size: 16px; }
  .modalshade { padding: 12px; }
  .modal { padding: 22px; }
  #toast { bottom: max(18px, env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .topright .testtag { display: none; }
  .authbox { padding: 24px 20px; }
  .card { padding: 14px; }
  .card .metric { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
@media (forced-colors: active) {
  button, input, textarea, select, .card, .panel, .badge, .notice { border: 1px solid ButtonText; }
  .navbutton.active { outline: 2px solid Highlight; outline-offset: -2px; }
}
@media print {
  :root, :root[data-theme="dark"] {
    color-scheme: light !important;
    --ink: #172e23;
    --muted: #4d6456;
    --green: #126b50;
    --green-hover: #0c5941;
    --on-green: #fff;
    --line: #d7e0d9;
    --line-soft: #e7ece8;
    --surface: #fff;
    --surface-soft: #f5f8f5;
    --surface-hover: #edf5ef;
    --bg: #fff;
    --input: #fff;
    --input-border: #a6b9ac;
    --accent-soft: #e6f3eb;
    --accent-border: #b0d7c1;
    --warning-bg: #fff7e5;
    --warning-ink: #795615;
    --warning-border: #ead5a6;
    --danger: #a6382d;
    --danger-bg: #fff0ed;
    --danger-border: #efc2b9;
    --success-bg: #edf7ef;
    --success-ink: #286342;
    --success-border: #b9dcc6;
  }
  body, .auth { color: #172e23; background: #fff; min-height: auto; }
  .sidebar, .topbar, .theme-toggle, .actions, .tabs, #toast, .modalshade, .previewlabel { display: none !important; }
  .layout, .content, .editor { display: block; }
  .main { padding: 0; max-width: none; }
  .card, .panel, .paper, .authbox { box-shadow: none; }
  .paper { border: 0; width: 100%; min-height: auto; padding: 0; }
  .previewwrap { position: static; max-width: none; }
  .editor > div { display: none; }
  .tablewrap { overflow: visible; }
  table { white-space: normal; }
  .paper th { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .paper thead { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .panel, .card, tr { break-inside: avoid; }
}
