:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --text: #18201f;
  --muted: #66736f;
  --line: #d9e0dc;
  --primary: #2f6f62;
  --primary-strong: #23544a;
  --accent: #b66a2c;
  --danger: #b84a4a;
  --warning: #a77a18;
  --blue: #356e9f;
  --shadow: 0 14px 28px rgba(28, 39, 35, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 208px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px;
  background: #17211f;
  color: #f7faf7;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  color: #17211f;
  background: #d7eee5;
}

.sidebar nav {
  display: grid;
  gap: 4px;
}

.sidebar a {
  color: #d9e8e4;
  padding: 10px 12px;
  border-radius: 6px;
}

.sidebar a.active,
.sidebar a:hover {
  background: #243532;
  color: #ffffff;
  text-decoration: none;
}

.logout {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 8px 0;
  color: #c2cfcb;
}

.content {
  padding: 22px;
  min-width: 0;
}

.content-centered {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
p { color: var(--muted); margin: 6px 0 0; }

.panel,
.login-panel,
.metric,
.conflict-band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel { padding: 18px; margin-bottom: 18px; overflow-x: auto; }
.panel-title { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 12px; color: var(--muted); }

.collapsible-panel {
  overflow-x: auto;
}

.collapsible-summary {
  cursor: pointer;
  list-style: none;
  margin-bottom: 0;
}

.collapsible-summary::-webkit-details-marker {
  display: none;
}

.collapsible-panel[open] .collapsible-summary {
  margin-bottom: 12px;
}

.login-panel {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.dashboard-workspace {
  margin-bottom: 18px;
}

.dashboard-kpi-grid .metric {
  min-height: 112px;
  padding: 15px 16px;
  align-content: start;
  box-shadow: 0 8px 20px rgba(28, 39, 35, 0.06);
}

.dashboard-kpi-grid .metric small {
  color: var(--muted);
  font-size: 12px;
}

.dashboard-kpi-grid .metric.needs-attention {
  border-left: 3px solid var(--accent);
}

.dashboard-summary-title {
  align-items: flex-start;
}

.dashboard-summary-title p {
  margin-top: 4px;
}

.summary-table-wrap,
.plan-table-wrap {
  overflow-x: auto;
}

.dashboard-chain-row td,
.plan-chain-row td {
  padding: 14px 8px 7px;
  background: var(--surface);
  border-bottom: 0;
}

.dashboard-store-cell {
  min-width: 220px;
}

.dashboard-store-cell strong,
.dashboard-store-cell > span:not(.badge) {
  display: block;
}

.dashboard-store-cell > span:not(.badge) {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.amount-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  padding: 18px;
  display: grid;
  gap: 8px;
}

.metric span { color: var(--muted); }
.metric strong { font-size: 24px; line-height: 1.2; overflow-wrap: anywhere; }

.invoice-live-card {
  border-color: var(--line);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.invoice-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.invoice-live-card em {
  display: inline-flex;
  padding: 1px 7px;
  border-radius: 999px;
  background: #dff0e9;
  color: #23614f;
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.invoice-live-card em[hidden] {
  display: none !important;
}

.invoice-live-card.matched {
  border-color: #77b99f;
  background: #f5fbf8;
}

.invoice-live-card.over-target {
  border-color: #e0b572;
  background: #fff9ec;
}

.invoice-card-target {
  display: grid;
  gap: 5px;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--line);
}

.invoice-card-target span,
.invoice-card-stats span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.invoice-card-target strong {
  color: var(--text);
  font-size: 26px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.invoice-card-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.invoice-card-stats span {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f3f8f6;
}

.invoice-card-stats strong {
  color: var(--primary-strong);
  font-size: 19px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.invoice-live-card.over-target .invoice-card-stats span:last-child strong {
  color: var(--warning);
}

.amount-form {
  margin: 0;
  display: grid;
  gap: 10px;
}

.invoice-workflow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
  gap: 1px;
}

.workflow-step {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 9px 12px;
  color: var(--muted);
  background: var(--surface);
  font-weight: 700;
}

.workflow-step b {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 12px;
}

.workflow-step.is-active {
  color: var(--primary-strong);
  background: #e8f2ee;
}

.workflow-step.is-done {
  color: var(--text);
}

.workflow-step.is-done b {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.invoice-plan-overview {
  margin-bottom: 18px;
}

.invoice-plan-context {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 220px) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 14px 16px;
  box-shadow: none;
}

.invoice-plan-context p {
  margin-top: 3px;
}

.invoice-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.invoice-summary-grid .metric {
  min-height: 170px;
  box-shadow: 0 8px 20px rgba(28, 39, 35, 0.06);
}

.form-grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.upload-box {
  display: grid;
  gap: 12px;
}

.stack-form,
.entry-grid {
  display: grid;
  gap: 14px;
}

.entry-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.invoice-section {
  padding: 0;
  overflow: hidden;
}

.invoice-section form {
  padding: 16px;
}

.invoice-section-title {
  align-items: flex-start;
}

.invoice-section-title > div:first-child {
  display: grid;
  gap: 4px;
}

.invoice-section-heading {
  min-width: 280px;
}

.section-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 8px;
  margin-top: 4px;
}

.section-summary-total,
.section-summary-pair span {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5faf8;
}

.section-summary-total {
  display: grid;
  min-width: 150px;
  padding: 6px 10px;
}

.section-summary-total span,
.section-summary-pair > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.section-summary-total strong {
  color: var(--text);
  font-size: 18px;
  line-height: 1.1;
}

.section-summary-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(95px, 1fr));
  gap: 8px;
}

.section-summary-pair span {
  display: grid;
  gap: 3px;
  padding: 6px 10px;
}

.section-summary-pair strong {
  color: var(--primary-strong);
  font-size: 17px;
  line-height: 1.1;
}

.section-summary.over-target .section-summary-pair span:last-child strong {
  color: var(--warning);
}

.section-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(160px, 220px) 1fr;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

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

.line-table {
  table-layout: fixed;
  min-width: 985px;
}

.line-table th,
.line-table td {
  padding: 7px;
  vertical-align: top;
}

.line-table th:nth-child(1),
.line-table td:nth-child(1) { width: 165px; }
.line-table th:nth-child(2),
.line-table td:nth-child(2) { width: 175px; }
.line-table th:nth-child(3),
.line-table td:nth-child(3) { width: 125px; }
.line-table th:nth-child(4),
.line-table td:nth-child(4) { width: 60px; }
.line-table th:nth-child(5),
.line-table td:nth-child(5) { width: 68px; }
.line-table th:nth-child(6),
.line-table td:nth-child(6) { width: 68px; }
.line-table th:nth-child(7),
.line-table td:nth-child(7) { width: 78px; }
.line-table th:nth-child(8),
.line-table td:nth-child(8) { width: 98px; }
.line-table th:nth-child(9),
.line-table td:nth-child(9) { width: 78px; }
.line-table th:nth-child(10),
.line-table td:nth-child(10) { width: 70px; }

.line-table input,
.line-table select {
  min-height: 34px;
  padding: 6px 8px;
  width: 100%;
}

.select-filter-input {
  margin-bottom: 6px;
  min-height: 32px;
  padding: 5px 8px;
  font-size: 13px;
}

.line-table [data-line-total] {
  font-weight: 700;
  color: var(--primary-strong);
}

.line-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.line-row-actions .icon-button {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  border-radius: 6px;
  font-size: 17px;
  line-height: 1;
}

.line-add-button {
  color: var(--primary-strong);
}

.line-table tr.copy-warning {
  background: #fdeaea;
}

.line-table tr.copy-warning input,
.line-table tr.copy-warning select {
  border-color: #d57b7b;
}

.line-warning-text {
  margin-top: 5px;
  color: #9b3434;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

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

.detail-grid > div,
.detail-grid > label {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7fbf9;
}

.detail-grid span,
.detail-grid label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-grid label input,
.detail-grid label select {
  margin-top: 6px;
}

.store-detail-form {
  display: grid;
  gap: 14px;
}

.store-detail-notes {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
}

.store-detail-notes > div,
.store-detail-notes label {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7fbf9;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.store-detail-notes p {
  margin: 0;
  color: var(--text);
  font-weight: 700;
  white-space: pre-wrap;
}

.store-detail-notes textarea {
  min-height: 104px;
  resize: vertical;
}

.store-active-check {
  align-content: center;
  min-height: 76px;
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.summary-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #edf3f1;
  color: #31504a;
  font-size: 13px;
  font-weight: 700;
}

.candidate-line {
  margin: 3px 0;
  line-height: 1.45;
}

.invoice-section-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 2px solid var(--text);
}

.section-stage-status {
  display: inline-flex;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.invoice-section[data-staged="1"] .section-stage-status {
  color: var(--primary-strong);
}

.staged-draft-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-color: #93c6b5;
  background: #f5fbf8;
}

.staged-draft-panel[hidden] {
  display: none !important;
}

.staged-draft-panel p {
  margin: 6px 0 0;
}

.invoice-plan-drafts {
  border-color: #c8d8d2;
}

.plan-work-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 8px 20px rgba(28, 39, 35, 0.05);
}

.plan-work-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  min-width: 0;
  padding: 13px 15px;
  color: var(--text);
  border-right: 1px solid var(--line);
}

.plan-work-item:last-child {
  border-right: 0;
}

.plan-work-item:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.plan-work-item span,
.plan-work-item strong {
  align-self: center;
}

.plan-work-item strong {
  font-size: 20px;
  line-height: 1;
}

.plan-work-item small {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

.plan-work-item.needs-attention {
  box-shadow: inset 3px 0 0 var(--accent);
}

.monthly-customer-panel > .collapsible-summary {
  min-height: 42px;
}

.plan-table-title {
  align-items: flex-start;
}

.plan-table-title p {
  margin-top: 4px;
}

.plan-main-table {
  min-width: 980px;
  table-layout: fixed;
}

.plan-main-table th:nth-child(1) { width: 220px; }
.plan-main-table th:nth-child(2) { width: 72px; }
.plan-main-table th:nth-child(3) { width: 175px; }
.plan-main-table th:nth-child(4) { width: 100px; }
.plan-main-table th:nth-child(5),
.plan-main-table th:nth-child(6) { width: 100px; }
.plan-main-table th:nth-child(7) { width: 213px; }

.plan-data-row > td {
  vertical-align: top;
}

.plan-data-row.is-no-invoice {
  background: #f7f8f5;
}

.plan-customer-cell strong,
.plan-customer-cell span,
.plan-customer-cell small,
.plan-profile-cell span,
.plan-profile-cell small {
  display: block;
}

.plan-customer-cell span,
.plan-customer-cell small,
.plan-profile-cell small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.plan-profile-cell {
  vertical-align: top;
}

.plan-profile-cell > div {
  min-width: 0;
}

.plan-profile-cell > div + div {
  margin-top: 9px;
}

.plan-profile-cell span {
  overflow-wrap: anywhere;
}

.plan-profile-cell input,
.plan-type-cell input {
  width: 100%;
  min-width: 0;
}

.plan-status-cell,
.plan-type-cell {
  vertical-align: top;
}

.plan-status-cell > *,
.plan-type-cell > * {
  display: block;
}

.plan-status-cell > * + *,
.plan-type-cell > * + * {
  margin-top: 5px;
}

.plan-type-cell > span {
  color: var(--muted);
  font-size: 12px;
}

.plan-type-cell > strong {
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.plan-row-actions {
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
}

.plan-row-actions .primary-button,
.plan-row-actions .secondary-button {
  white-space: nowrap;
}

.plan-delete-note {
  flex-basis: 100%;
  font-size: 12px;
}

.invoice-draft-list {
  display: grid;
  gap: 12px;
}

.invoice-draft-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.invoice-draft-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.invoice-draft-card h3 {
  margin: 0;
  font-size: 16px;
}

.invoice-draft-card p {
  margin-top: 4px;
}

.invoice-draft-time {
  color: var(--muted);
  white-space: nowrap;
}

.invoice-draft-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.invoice-draft-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #eef3f1;
  color: #3d5550;
  font-size: 13px;
  font-weight: 700;
}

.invoice-draft-meta span.is-staged {
  background: #e4f3ed;
  color: var(--primary-strong);
}

.invoice-draft-details {
  margin: 4px 0 12px;
}

.invoice-draft-details summary {
  cursor: pointer;
  color: var(--primary-strong);
  font-weight: 700;
}

.invoice-draft-details table {
  margin-top: 10px;
  font-size: 13px;
}

.invoice-save-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.invoice-save-panel h2 {
  margin: 0 0 6px;
}

.invoice-save-panel p {
  margin: 0;
  color: var(--muted);
}

.target-save-status {
  min-height: 20px;
  color: var(--primary-strong);
  font-size: 13px;
  font-weight: 700;
}

.copy-store-panel[hidden] {
  display: none !important;
}

.form-panel {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.tax-option-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 12px;
}

.tax-option-form {
  align-items: end;
}

.table-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.table-toolbar label {
  width: min(360px, 100%);
}

.inline-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: end;
}

.inline-form.wide > * { min-width: 170px; flex: 1 1 170px; }

.customer-tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.customer-tool {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-2);
}

.customer-tool h3 {
  margin: 0;
  font-size: 15px;
}

.customer-tool p {
  margin-bottom: 12px;
}

.customer-tool-accent {
  border-color: #b8d6ca;
  background: #e7f2ee;
}

label {
  display: grid;
  gap: 6px;
  color: #33423f;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #c9d4d0;
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid rgba(47, 111, 98, 0.22);
  border-color: var(--primary);
}

.password-input-wrap {
  position: relative;
  display: block;
}

.password-input-wrap input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 34px;
  min-width: 34px;
  min-height: 32px;
  padding: 0;
  transform: translateY(-50%);
  color: var(--muted);
  background: transparent;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--primary);
  background: var(--surface-2);
  outline: 2px solid rgba(47, 111, 98, 0.18);
}

.password-eye {
  position: relative;
  width: 18px;
  height: 12px;
  border: 2px solid currentColor;
  border-radius: 70% 20%;
  transform: rotate(45deg);
}

.password-eye::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.password-toggle.is-visible::after {
  content: "";
  position: absolute;
  width: 22px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transform: rotate(-42deg);
}

.login-links {
  margin-top: 16px;
  text-align: center;
}

.login-links a {
  color: var(--primary);
  font-weight: 700;
}

.auth-panel {
  width: min(100%, 440px);
}

.auth-primary-link {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.security-account-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.security-account-summary > div {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
}

.security-account-summary span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 720px) {
  .security-account-summary {
    grid-template-columns: 1fr;
  }
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}
.check-row input { width: auto; min-height: auto; }

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

button,
.primary-button,
.secondary-button,
.ghost-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 8px 13px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.primary-button,
button.primary-button {
  background: var(--primary);
  color: #fff;
}

.primary-button:hover { background: var(--primary-strong); text-decoration: none; }

.secondary-button {
  background: #e8f0ed;
  color: var(--primary-strong);
}

.ghost-button {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--line);
}

.icon-button {
  width: 34px;
  min-width: 34px;
  padding: 0;
  font-size: 18px;
}

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

.summary-table {
  min-width: 960px;
  table-layout: fixed;
}

.summary-table th:nth-child(1) { width: 250px; }
.summary-table th:nth-child(2) { width: 165px; }
.summary-table th:nth-child(3),
.summary-table th:nth-child(4),
.summary-table th:nth-child(5) { width: 182px; }

.summary-table th,
.summary-table td {
  padding: 9px 10px;
}

.summary-table .identity-col {
  vertical-align: middle;
}

.summary-table .tax-col {
  white-space: nowrap;
  overflow-wrap: normal;
}

.summary-table .invoice-group-header {
  text-align: center;
  color: var(--primary-strong);
  background: #e5f0ec;
  border-left: 1px solid #cfdbd6;
  border-right: 1px solid #cfdbd6;
  font-size: 14px;
}

.summary-table .invoice-group-header.total {
  background: #edf0e7;
}

.summary-table .amount-subhead th {
  text-align: right;
  background: #f2f6f4;
  color: var(--muted);
}

.summary-table .amount-value {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.summary-table .amount-target {
  color: #40524e;
}

.summary-table .amount-over {
  color: var(--warning);
}

.summary-table .status {
  margin-left: 6px;
  vertical-align: middle;
}

.invoice-summary-cell {
  position: relative;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.amount-triplet-labels,
.amount-triplet-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  text-align: right;
}

.amount-triplet-labels {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.amount-triplet-values strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.invoice-summary-cell > .status {
  margin: 6px 0 0;
  float: right;
}

th, td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-2);
  color: #40524e;
  font-size: 13px;
  white-space: nowrap;
}

td { overflow-wrap: anywhere; }

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

.status,
.tag,
.badge,
.saved-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  background: #e8eceb;
  color: #40524e;
}

.status.confirmed { background: #dff0e9; color: #23614f; }
.status.void { background: #f1dddd; color: #8e3333; }
.tag.initial { background: #fff1d8; color: #925b0f; }
.tag.warning { background: #fff4d8; color: #8a5d09; }
.badge.neutral { background: #eef4f2; color: #36534b; }
.badge.no-invoice { background: #fff4d8; color: #8a5d09; margin-left: 6px; }
.saved-pill { background: #dce8e5; color: #2f5f52; }
.muted-text { color: var(--muted); font-size: 12px; }
.mono-id {
  display: inline-block;
  min-width: 64px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
  color: var(--primary-strong);
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.actions form { margin: 0; }

.export-actions {
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.export-price-form {
  display: grid;
  gap: 6px;
}

.export-price-form > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.segmented-control {
  display: inline-flex;
  min-height: 36px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef4f2;
}

.segmented-control label {
  display: inline-flex;
  align-items: center;
  min-width: 86px;
  cursor: pointer;
  font-weight: 800;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  width: 100%;
  height: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  color: var(--primary-strong);
}

.segmented-control input:checked + span {
  background: var(--primary);
  color: #fff;
}

.table-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.table-actions form { margin: 0; }

.compact-form {
  display: inline-flex;
}

.compact-table {
  font-size: 13px;
}

.compact-table th,
.compact-table td {
  padding: 8px 9px;
}

.saved-invoice-panel {
  background: #f7faf9;
}

.saved-invoice-list {
  display: grid;
  gap: 12px;
}

.saved-invoice-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f0f5f3;
  padding: 12px;
  color: #40524e;
}

.saved-invoice-card-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 10px;
}

.saved-invoice-card-head h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.saved-invoice-card-head p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.saved-invoice-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.completed-invoice-section {
  background: #f7fbf9;
  border-color: #c7ded5;
}

.no-invoice-panel,
tr.is-no-invoice {
  background: #fffaf0;
}

.no-invoice-panel {
  border-color: #efcf88;
}

.completed-total {
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef6f3;
  color: #40524e;
  font-weight: 800;
}

.previous-invoice-list {
  display: grid;
  gap: 14px;
}

.previous-invoice-group {
  display: grid;
  gap: 10px;
}

.previous-invoice-group h3 {
  margin: 0;
  color: var(--text);
}

.previous-invoice-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f7fbf9;
}

.row-save-status {
  min-width: 48px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.row-save-status[data-status-kind="success"] {
  color: var(--primary-strong);
}

.row-save-status[data-status-kind="error"] {
  color: var(--danger);
}

.danger-text {
  color: var(--danger);
  font-weight: 800;
}

.mini-edit-button {
  min-height: 26px;
  padding: 0 8px;
  margin-left: 6px;
  font-size: 12px;
}

.table-input {
  min-width: 120px;
}

.table-checkbox {
  width: auto;
  min-height: auto;
}

tr.is-editing {
  background: #f7fbf9;
}

[data-tax-rate-save][hidden],
[data-tax-rate-cancel][hidden],
[data-tax-rate-control][hidden],
[data-edit-save][hidden],
[data-edit-cancel][hidden],
[data-edit-control][hidden] {
  display: none !important;
}

/* Dashboard workspace: matches the approved top-navigation concept without
   changing the shared management pages or their interaction contracts. */
body.dashboard-page {
  background: #ffffff;
}

.dashboard-page .app-shell {
  display: block;
  min-height: 100vh;
}

.dashboard-page .sidebar {
  display: none;
}

.dashboard-page .content {
  width: min(100%, 1600px);
  margin: 0 auto;
  padding: 20px 42px 54px;
}

.dashboard-page .alert {
  box-shadow: none;
}

.dashboard-top-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 46px;
  margin-bottom: 34px;
}

.dashboard-nav-link,
.dashboard-manage-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid #d9dce1;
  border-radius: 8px;
  background: #ffffff;
  color: #202124;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
}

.dashboard-nav-link:hover,
.dashboard-manage-button:hover {
  border-color: #b9bec6;
  background: #f6f7f8;
  text-decoration: none;
}

.dashboard-nav-link.active {
  border-color: #318ff0;
  background: #318ff0;
  color: #ffffff;
}

.dashboard-nav-link svg,
.dashboard-manage-button svg,
.dashboard-more-nav summary svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.dashboard-more-nav {
  position: relative;
  margin-left: auto;
}

.dashboard-more-nav summary {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #6f7378;
  cursor: pointer;
  list-style: none;
}

.dashboard-more-nav summary::-webkit-details-marker {
  display: none;
}

.dashboard-more-nav summary:hover,
.dashboard-more-nav[open] summary {
  background: #f0f2f4;
}

.dashboard-more-menu {
  position: absolute;
  z-index: 30;
  top: 48px;
  right: 0;
  width: 174px;
  padding: 8px;
  border: 1px solid #dedfe2;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(25, 28, 31, 0.12);
}

.dashboard-more-menu a {
  display: block;
  padding: 9px 10px;
  border-radius: 6px;
  color: #2d3033;
  font-weight: 700;
}

.dashboard-more-menu a:hover {
  background: #f2f4f6;
  text-decoration: none;
}

.dashboard-page .dashboard-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  align-items: start;
  gap: 36px;
  margin-bottom: 30px;
}

.dashboard-page .dashboard-header h1 {
  font-size: 34px;
  font-weight: 800;
}

.dashboard-page .dashboard-header p {
  margin-top: 3px;
  color: #8a8d91;
  font-size: 17px;
}

.dashboard-month-form {
  display: grid;
  gap: 10px;
}

.dashboard-month-form label {
  display: grid;
  gap: 7px;
  color: #202124;
  font-size: 14px;
  font-weight: 800;
}

.dashboard-month-form input {
  min-height: 44px;
  border-color: #d9dce1;
  border-radius: 8px;
  background: #ffffff;
  font-size: 17px;
}

.dashboard-query-button {
  justify-self: end;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: #202124;
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
}

.dashboard-query-button:hover {
  background: #000000;
}

.dashboard-page .dashboard-workspace {
  margin-bottom: 34px;
}

.dashboard-page .dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 18px;
  margin: 0;
}

.dashboard-kpi {
  position: relative;
  min-height: 128px;
  padding: 24px 22px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f4f4f5;
}

.dashboard-kpi.needs-attention::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #f28a3b;
  content: "";
}

.dashboard-kpi span,
.dashboard-kpi strong {
  display: block;
}

.dashboard-kpi span {
  color: #85888c;
  font-size: 18px;
  font-weight: 700;
}

.dashboard-kpi strong {
  margin-top: 4px;
  color: #1f2123;
  font-size: 34px;
  line-height: 1.15;
}

.dashboard-summary-panel {
  margin: 0;
  padding: 0;
  overflow: visible;
  background: transparent;
}

.dashboard-page .dashboard-summary-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.dashboard-page .dashboard-summary-title h2 {
  color: #202124;
  font-size: 28px;
}

.dashboard-page .dashboard-summary-title p {
  margin-top: 2px;
  color: #8a8d91;
  font-size: 16px;
}

.dashboard-manage-button {
  min-height: 40px;
  font-size: 15px;
}

.dashboard-table-wrap {
  overflow-x: auto;
}

.dashboard-summary-table {
  min-width: 900px;
  table-layout: fixed;
}

.dashboard-summary-table th,
.dashboard-summary-table td {
  border-bottom: 1px solid #e4e5e7;
}

.dashboard-summary-table th {
  padding: 14px 8px;
  background: transparent;
  color: #878a8e;
  font-size: 17px;
  font-weight: 800;
}

.dashboard-summary-table th:first-child {
  width: 40%;
  text-align: left;
}

.dashboard-summary-table th:not(:first-child) {
  width: 20%;
  text-align: left;
}

.dashboard-summary-table .dashboard-chain-row td {
  padding: 20px 8px 8px;
  border-bottom: 0;
  background: transparent;
}

.dashboard-chain-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 3px 12px;
  border-radius: 999px;
  background: #e6f2ff;
  color: #2583dc;
  font-size: 14px;
  font-weight: 800;
}

.dashboard-store-row td {
  height: 92px;
  padding: 16px 8px;
}

.dashboard-page .dashboard-store-cell {
  min-width: 260px;
}

.dashboard-page .dashboard-store-cell strong {
  color: #222426;
  font-size: 17px;
}

.dashboard-page .dashboard-store-cell > span:not(.badge) {
  margin-top: 4px;
  color: #96999d;
  font-size: 15px;
}

.dashboard-amount-cell {
  position: relative;
  font-variant-numeric: tabular-nums;
}

.dashboard-amount-main {
  color: #202124;
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}

.dashboard-amount-detail {
  display: flex;
  gap: 5px;
  margin-top: 7px;
  color: #96999d;
  font-size: 15px;
  white-space: nowrap;
}

.dashboard-amount-detail .amount-over {
  color: #b36b1d;
}

.dashboard-complete-mark {
  display: inline-flex;
  margin-top: 7px;
  color: #247158;
  font-size: 12px;
  font-weight: 800;
}

.alert {
  padding: 11px 13px;
  border-radius: 7px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}

.alert.success { color: #205b4b; background: #e1f2eb; border-color: #b8dbcf; }
.alert.danger { color: #8d2d2d; background: #fde7e7; border-color: #efbcbc; }
.alert.warning { color: #7a570d; background: #fff4d8; border-color: #e8cd82; }

.conflict-band {
  padding: 18px;
  margin-bottom: 18px;
  border-color: #e7bd77;
  background: #fffaf0;
}

.conflict-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.conflict-option {
  display: grid;
  gap: 8px;
  padding: 14px;
  background: #fff;
  border: 1px solid #ead3a5;
  border-radius: 8px;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .sidebar nav { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .content { padding: 18px; }
  .kpi-grid, .amount-grid, .form-grid.two, .conflict-grid { grid-template-columns: 1fr 1fr; }
  .plan-work-strip { grid-template-columns: 1fr 1fr; }
  .plan-work-item:nth-child(2) { border-right: 0; }
  .plan-work-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .invoice-plan-context { grid-template-columns: 1fr 1fr; }
  .invoice-plan-context > div:first-child { grid-column: 1 / -1; }
  .store-detail-notes { grid-template-columns: 1fr; }
  .entry-grid { grid-template-columns: 1fr 1fr; }
  .section-toolbar { grid-template-columns: 1fr; }
  .dashboard-page .content { padding: 18px 24px 42px; }
  .dashboard-page .dashboard-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .sidebar nav { grid-template-columns: 1fr 1fr; }
  .page-header { display: grid; }
  .kpi-grid, .amount-grid, .form-grid.two, .conflict-grid, .entry-grid, .invoice-summary-grid { grid-template-columns: 1fr; }
  .dashboard-kpi-grid { grid-template-columns: 1fr 1fr; }
  .plan-work-strip,
  .invoice-plan-context { grid-template-columns: 1fr; }
  .plan-work-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .plan-work-item:last-child { border-bottom: 0; }
  .invoice-workflow { grid-template-columns: 1fr 1fr; }
  .workflow-step { min-height: 42px; }
  .invoice-plan-context > div:first-child { grid-column: auto; }
  .invoice-section-title { display: grid; }
  .invoice-section-title .actions { justify-content: flex-start; }
  .metric strong { font-size: 20px; }
  .dashboard-top-nav {
    gap: 8px;
    margin-bottom: 24px;
    overflow-x: auto;
  }
  .dashboard-nav-link {
    min-height: 40px;
    padding: 0 11px;
    font-size: 14px;
    white-space: nowrap;
  }
  .dashboard-more-nav { margin-left: 0; }
  .dashboard-page .dashboard-header {
    grid-template-columns: 1fr;
    gap: 18px;
  }
  .dashboard-month-form { width: min(100%, 280px); }
  .dashboard-page .dashboard-kpi-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-kpi { min-height: 104px; padding: 18px 16px; }
  .dashboard-kpi span { font-size: 15px; }
  .dashboard-kpi strong { font-size: 28px; }
  .dashboard-page .dashboard-summary-title { align-items: flex-start; }
}

@media (max-width: 420px) {
  .dashboard-kpi-grid,
  .invoice-workflow { grid-template-columns: 1fr; }
}
