:root {
  color-scheme: light;
  --ink: #202426;
  --muted: #667071;
  --subtle: #edf0ee;
  --line: #dfe4e7;
  --paper: #ffffff;
  --canvas: #eef2f5;
  --accent: #00796b;
  --accent-dark: #005f55;
  --accent-soft: #dff1ec;
  --link: #4388bf;
  --blue: #438bd2;
  --warn: #b86d00;
  --danger: #bd3d32;
  --shadow: 0 18px 50px rgba(32, 36, 38, 0.12);
  --radius: 8px;
  font-family: Inter, "Noto Sans JP", "Hiragino Sans", "Yu Gothic", Meiryo, system-ui,sans-serif;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

[hidden] {
  display: none !important;
}

a {
  color: var(--accent-dark);
}

body.auth-loading .app-shell,
body.auth-required .app-shell,
body.auth-ok .login-screen {
  display: none;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-card h1 {
  margin: 0;
  font-size: 1.4rem;
}

.login-message {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: #fbfbf8;
  padding: 26px 18px;
}

.drawer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawer-close,
.mobile-menu-button,
.mobile-drawer-backdrop,
.mobile-panel-export {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand h1,
.topbar h2,
.dialog-head h3 {
  margin: 0;
  letter-spacing: 0;
}

.brand h1 {
  font-size: 1.1rem;
}

.main-nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  text-align: left;
}

.nav-item:hover {
  background: var(--subtle);
}

.nav-item.active {
  border-color: #b8d5cf;
  background: var(--accent-soft);
  color: #073c37;
  font-weight: 700;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  font-size: 16px;
  line-height: 1;
}

.sidebar-note {
  margin-top: auto;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--muted);
  font-size: 0.85rem;
}

.sidebar-note strong {
  color: var(--ink);
}

.workspace {
  min-width: 0;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
  min-width: 0;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar h2 {
  font-size: 1.45rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.search-box {
  display: grid;
  grid-template-columns: 22px minmax(120px, 240px);
  align-items: center;
  width: min(292px, 100%);
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 0 10px;
}

.search-box span {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}

.search-box input {
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
}

.button,
.icon-button,
.segment {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}

.button {
  min-height: 32px;
  padding: 0 12px;
  font-weight: 700;
  white-space: nowrap;
  font-size: 0.88rem;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--paper);
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.secondary {
  background: #fdfdfb;
}

.button.ghost {
  background: transparent;
}

.button.danger {
  border-color: #e7c6c2;
  color: var(--danger);
}

.button.full {
  width: 100%;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  font-size: 1.4rem;
  line-height: 1;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  display: grid;
  gap: 4px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 10px 12px;
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric strong {
  font-size: 1.25rem;
}

.panel {
  min-width: 0;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: 0 1px 0 rgba(32, 36, 38, 0.03);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.panel-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
}

.panel-copy,
.result-count {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.panel-toolbar-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

#home-view .panel-toolbar {
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 6px;
  padding: 6px 10px;
}

#home-view .panel-copy {
  flex: 1 0 100%;
}

#home-view .toolbar-controls {
  flex: 0 1 auto;
  align-items: end;
  justify-content: flex-start;
  gap: 6px;
}

#home-view .compact-control {
  grid-template-columns: 1fr;
  gap: 3px;
}

#home-year {
  width: 76px;
}

#home-month {
  width: 136px;
}

.compact-control {
  grid-template-columns: auto minmax(116px, 150px);
  align-items: center;
  gap: 6px;
}

.compact-control input {
  min-height: 30px;
}

.muted {
  color: var(--muted);
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.segment {
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.segment.active {
  border-color: #9dc8c1;
  background: var(--accent-soft);
  color: #073c37;
  font-weight: 700;
}

.segment-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.data-table {
  min-width: 920px;
}

.orders-table {
  min-width: 920px;
  table-layout: fixed;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #ffffff;
  color: #343a3d;
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.25;
}

.data-table th:not(.check-column)::after {
  content: "";
}

td {
  font-size: 0.82rem;
  font-weight: 520;
  line-height: 1.35;
}

.orders-table tbody tr {
  cursor: pointer;
}

.orders-table th:nth-child(1),
.orders-table td:nth-child(1) {
  width: 112px;
}

.orders-table th:nth-child(2),
.orders-table td:nth-child(2) {
  width: 160px;
}

.orders-table th:nth-child(3),
.orders-table td:nth-child(3) {
  width: 150px;
}

.orders-table th:nth-child(5),
.orders-table td:nth-child(5) {
  width: 82px;
}

.orders-table th:nth-child(6),
.orders-table td:nth-child(6) {
  width: 82px;
}

.orders-table th:nth-child(7),
.orders-table td:nth-child(7) {
  width: 64px;
}

.orders-table th:nth-child(8),
.orders-table td:nth-child(8) {
  width: 110px;
}

.orders-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font: inherit;
  font-weight: 800;
}

.sort-button::after {
  content: "↕";
  color: #8fa0a8;
  font-size: 0.72rem;
  line-height: 1;
}

.sort-button.active::after {
  content: "▲";
  color: var(--link);
}

.sort-button.active[data-direction="desc"]::after {
  content: "▼";
}

tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:nth-child(even) {
  background: #f6f6f6;
}

.data-table tbody tr:hover {
  background: #eef6fb;
}

.check-column {
  width: 34px;
  text-align: center;
}

.check-column input {
  width: 14px;
  min-height: 14px;
  padding: 0;
}

.client-link {
  color: var(--link);
  font-weight: 650;
  text-decoration: none;
}

.numeric {
  text-align: right;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

.cell-main {
  display: grid;
  gap: 2px;
}

.cell-main strong {
  font-size: 0.84rem;
}

.cell-main small {
  color: var(--muted);
  line-height: 1.45;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0 10px;
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-active,
.status-in_progress {
  border-color: #e2c178;
  background: #fff7df;
  color: #674200;
}

.status-delivered {
  border-color: #a8d5d0;
  background: #e7f5f1;
  color: #0c5048;
}

.status-unbilled {
  border-color: #9fc3df;
  background: #eef7ff;
  color: #235b83;
}

.status-invoiced {
  border-color: #d7dadd;
  background: #f0f2f1;
  color: #4c5556;
}

.status-unpaid {
  border-color: #9fc3df;
  background: #eef7ff;
  color: #235b83;
}

.status-paid {
  border-color: #a8d5d0;
  background: #e7f5f1;
  color: #0c5048;
}

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

.row-actions .button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 0.78rem;
}

.url-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  min-height: 24px;
  border: 1px solid #bad5d0;
  border-radius: var(--radius);
  background: #f1faf7;
  padding: 0 8px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.78rem;
}

.text-link {
  border: 0;
  background: transparent;
  color: var(--link);
  font-weight: 800;
  padding: 0;
}

.grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  padding: 14px;
}

.master-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.master-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.master-card h3 {
  margin: 0;
  font-size: 1rem;
}

.master-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.meta-list {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

.scope-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 22px;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0 9px;
  font-size: 0.74rem;
  font-weight: 800;
}

.client-scope {
  border-color: #9fc3df;
  background: #eef7ff;
  color: #235b83;
}

.default-scope {
  border-color: #d7dadd;
  background: #f0f2f1;
  color: #4c5556;
}

.service-tabs {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
}

.services-table {
  min-width: 940px;
  table-layout: fixed;
}

.services-table th:nth-child(1),
.services-table td:nth-child(1) {
  width: 112px;
}

.services-table th:nth-child(2),
.services-table td:nth-child(2) {
  width: 180px;
}

.services-table th:nth-child(5),
.services-table td:nth-child(5),
.services-table th:nth-child(6),
.services-table td:nth-child(6) {
  width: 96px;
}

.services-table th:nth-child(7),
.services-table td:nth-child(7) {
  width: 76px;
}

.services-table td:nth-child(3),
.services-table td:nth-child(4) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.clients-table {
  min-width: 1240px;
  table-layout: fixed;
}

.clients-table th:nth-child(1),
.clients-table td:nth-child(1) {
  width: 210px;
}

.clients-table th:nth-child(2),
.clients-table td:nth-child(2),
.clients-table th:nth-child(4),
.clients-table td:nth-child(4) {
  width: 132px;
}

.clients-table th:nth-child(3),
.clients-table td:nth-child(3) {
  width: 190px;
}

.clients-table th:nth-child(7),
.clients-table td:nth-child(7) {
  width: 170px;
}

.clients-table th:nth-child(8),
.clients-table td:nth-child(8) {
  width: 76px;
}

.clients-table td:nth-child(1),
.clients-table td:nth-child(3),
.clients-table td:nth-child(5),
.clients-table td:nth-child(6),
.clients-table td:nth-child(7) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.settings-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  padding: 14px;
}

.settings-card h3 {
  margin: 0 0 6px;
  font-size: 0.98rem;
}

.settings-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 120px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.home-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.75fr);
  gap: 10px;
  padding: 10px;
}

.dashboard-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  padding: 12px;
}

.dashboard-card.wide {
  grid-column: 1 / -1;
}

.dashboard-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-card-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.dashboard-card-head span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

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

.summary-grid article,
.summary-list div {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcfc;
  padding: 10px;
}

.summary-grid span,
.summary-list span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.summary-grid strong,
.summary-list strong {
  font-size: 1.1rem;
}

.summary-list {
  display: grid;
  gap: 8px;
}

.bar-chart,
.status-breakdown {
  display: grid;
  gap: 7px;
}

.bar-row,
.breakdown-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 74px;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
}

.breakdown-row {
  grid-template-columns: 70px minmax(0, 1fr) 54px;
}

.bar-row > span,
.breakdown-row > span {
  color: var(--muted);
  font-weight: 800;
}

.bar-row strong,
.breakdown-row strong {
  text-align: right;
  white-space: nowrap;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f2;
}

.bar-track i {
  display: block;
  width: var(--bar-width);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #00796b, #438bd2);
}

.company-form {
  padding: 10px;
}

.company-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 10px;
}

.form-block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

.form-block-body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.section-head.compact {
  min-height: 44px;
  padding: 8px 12px;
}

.form-save-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.save-status {
  min-height: 1em;
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.seal-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px auto;
  align-items: end;
  gap: 10px;
}

.seal-editor-preview {
  display: grid;
  place-items: center;
  width: 86px;
  height: 64px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.seal-editor-preview img,
.company-seal {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.company-preview {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcfc;
  padding: 14px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.company-preview strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.company-preview-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.company-preview-head.has-seal {
  grid-template-columns: minmax(0, 1fr) 78px;
}

.company-preview-head > div,
.invoice-company > div {
  display: grid;
  gap: 3px;
}

.company-seal {
  width: 78px;
  height: 78px;
}

.company-preview hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 8px 0;
}

.invoice-workflow {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.invoice-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  padding: 8px;
}

.invoice-tab {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  padding: 0 12px;
  font-size: 0.84rem;
  font-weight: 800;
}

.invoice-tab.active {
  border-color: #9dc8c1;
  background: var(--accent-soft);
  color: #073c37;
}

.invoice-tab-panel {
  display: none;
}

.invoice-tab-panel.active {
  display: grid;
  gap: 10px;
}

.invoice-issue-panel,
.invoice-section,
.invoice-preview-shell {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
}

.section-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.section-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.invoice-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  align-items: end;
  padding: 10px 12px 12px;
}

.invoice-mode-switch {
  margin: 10px 12px 0;
}

.invoice-mode-panel {
  display: none;
}

.invoice-mode-panel.active {
  display: block;
}

.invoice-control-wide {
  grid-column: span 2;
}

.invoice-controls textarea {
  min-height: 32px;
}

.bulk-invoice-summary {
  border-top: 1px solid var(--line);
  padding: 8px 12px 10px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

label,
.field-block {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  min-width: 0;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.copy-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.order-copy-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

.button.compact {
  min-height: 26px;
  padding: 0 9px;
  font-size: 0.75rem;
}

.copy-status {
  min-width: 9em;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: right;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  padding: 5px 8px;
  font-size: 0.86rem;
  font-weight: 600;
}

input[type="date"],
input[type="month"] {
  cursor: pointer;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

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

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

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

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

.invoice-order-list {
  display: block;
}

.issued-invoices {
  display: block;
}

.invoice-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 820px;
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

.invoice-list-toolbar .button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 0.78rem;
}

.invoice-table {
  min-width: 820px;
}

#issued-invoices .invoice-table,
#unpaid-invoices .invoice-table,
#paid-invoices .invoice-table {
  min-width: 1120px;
  table-layout: fixed;
}

#issued-invoices .invoice-table th:nth-child(1),
#issued-invoices .invoice-table td:nth-child(1),
#unpaid-invoices .invoice-table th:nth-child(1),
#unpaid-invoices .invoice-table td:nth-child(1),
#paid-invoices .invoice-table th:nth-child(1),
#paid-invoices .invoice-table td:nth-child(1) {
  width: 34px;
}

#issued-invoices .invoice-table th:nth-child(2),
#issued-invoices .invoice-table td:nth-child(2),
#unpaid-invoices .invoice-table th:nth-child(2),
#unpaid-invoices .invoice-table td:nth-child(2),
#paid-invoices .invoice-table th:nth-child(2),
#paid-invoices .invoice-table td:nth-child(2) {
  width: 142px;
}

#issued-invoices .invoice-table th:nth-child(8),
#issued-invoices .invoice-table td:nth-child(8),
#unpaid-invoices .invoice-table th:nth-child(8),
#unpaid-invoices .invoice-table td:nth-child(8),
#paid-invoices .invoice-table th:nth-child(8),
#paid-invoices .invoice-table td:nth-child(8) {
  width: 96px;
}

#issued-invoices .invoice-table th:nth-child(9),
#issued-invoices .invoice-table td:nth-child(9),
#unpaid-invoices .invoice-table th:nth-child(9),
#unpaid-invoices .invoice-table td:nth-child(9),
#paid-invoices .invoice-table th:nth-child(9),
#paid-invoices .invoice-table td:nth-child(9) {
  width: 230px;
}

#invoice-order-list .invoice-table {
  min-width: 620px;
  table-layout: fixed;
}

.manual-invoice-table {
  min-width: 760px;
  table-layout: fixed;
}

.manual-invoice-table th:nth-child(1),
.manual-invoice-table td:nth-child(1) {
  width: 25%;
}

.manual-invoice-table th:nth-child(2),
.manual-invoice-table td:nth-child(2) {
  width: auto;
}

.manual-invoice-table th:nth-child(3),
.manual-invoice-table td:nth-child(3) {
  width: 90px;
}

.manual-invoice-table th:nth-child(4),
.manual-invoice-table td:nth-child(4),
.manual-invoice-table th:nth-child(5),
.manual-invoice-table td:nth-child(5) {
  width: 120px;
}

.manual-invoice-table th:nth-child(6),
.manual-invoice-table td:nth-child(6) {
  width: 70px;
}

.manual-invoice-table input {
  min-height: 30px;
}

.manual-invoice-table .button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 0.76rem;
}

#invoice-order-list .invoice-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#invoice-order-list .invoice-table th:nth-child(1),
#invoice-order-list .invoice-table td:nth-child(1) {
  width: 34px;
}

#invoice-order-list .invoice-table th:nth-child(2),
#invoice-order-list .invoice-table td:nth-child(2) {
  width: 112px;
}

#invoice-order-list .invoice-table th:nth-child(4),
#invoice-order-list .invoice-table td:nth-child(4) {
  width: auto;
}

#invoice-order-list .invoice-table th:nth-child(5),
#invoice-order-list .invoice-table td:nth-child(5) {
  width: 64px;
}

#invoice-order-list .invoice-table th:nth-child(6),
#invoice-order-list .invoice-table td:nth-child(6) {
  width: 110px;
}

.invoice-table input[type="checkbox"] {
  width: 14px;
  min-height: 14px;
  padding: 0;
}

.invoice-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.invoice-actions .button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 0.78rem;
}

.status-canceled {
  border-color: #efc5bf;
  background: #fff1ef;
  color: #8b2d25;
}

.invoice-preview-shell {
  min-width: 0;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  border-bottom: 1px solid var(--line);
  padding: 8px 12px;
}

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

.invoice-preview {
  box-sizing: border-box;
  width: min(794px, calc(100% - 28px));
  min-height: 1123px;
  margin: 14px auto;
  border: 1px solid #ccd3d0;
  background: #fff;
  padding: 34px;
  color: var(--ink);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.invoice-title-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 330px);
  gap: 24px;
  align-items: start;
  border-bottom: 3px solid var(--ink);
  padding-bottom: 18px;
}

.invoice-title-row h3 {
  margin: 0;
  font-size: 1.75rem;
}

.invoice-meta {
  display: grid;
  gap: 4px;
  text-align: right;
  color: var(--muted);
  font-size: 0.86rem;
}

.invoice-address {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 24px;
  margin: 24px 0 16px;
}

.invoice-address h4,
.invoice-total h4,
.invoice-bank h4 {
  margin: 0 0 8px;
}

.invoice-client-name {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.invoice-client-name h4 {
  margin: 0;
}

.invoice-address p {
  margin: 0 0 8px;
}

.invoice-company {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.invoice-company.has-seal {
  grid-template-columns: minmax(0, 1fr) 76px;
}

.invoice-company strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.invoice-seal {
  width: 76px;
  height: 76px;
}

.invoice-total-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 18px;
}

.invoice-info-lines {
  display: grid;
  gap: 6px;
  margin: -4px 0 18px;
  color: var(--ink);
  font-size: 0.85rem;
}

.invoice-info-lines p {
  display: grid;
  grid-template-columns: 3.5em minmax(0, 1fr);
  gap: 10px;
  margin: 0;
}

.invoice-info-lines strong {
  color: var(--muted);
}

.invoice-bank {
  border: 1px solid var(--line);
  padding: 12px 14px;
  color: var(--muted);
  font-size: 0.82rem;
}

.invoice-bank p {
  margin: 0;
  line-height: 1.55;
}

.invoice-bank p + p {
  margin-top: 4px;
}

.invoice-total {
  border: 1px solid var(--ink);
  padding: 16px;
}

.invoice-total strong {
  display: block;
  font-size: 1.55rem;
}

.invoice-preview table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  margin-top: 22px;
}

.invoice-preview th:nth-child(1),
.invoice-preview td:nth-child(1) {
  width: 56%;
}

.invoice-preview th:nth-child(2),
.invoice-preview td:nth-child(2) {
  width: 12%;
  text-align: right;
}

.invoice-preview th:nth-child(3),
.invoice-preview td:nth-child(3),
.invoice-preview th:nth-child(4),
.invoice-preview td:nth-child(4) {
  width: 16%;
  text-align: right;
}

.invoice-preview th,
.invoice-preview td {
  padding: 10px 8px;
}

.invoice-preview .amount {
  text-align: right;
}

.invoice-note {
  margin-top: 28px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.7;
}

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
}

#entry-dialog.order-entry-dialog {
  width: min(480px, calc(100vw - 28px));
}

dialog::backdrop {
  background: rgba(32, 36, 38, 0.42);
}

.dialog-card {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-actions > div {
  display: flex;
  gap: 8px;
}

.invoice-dialog {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
}

.invoice-dialog-card {
  gap: 0;
  padding: 0;
}

.invoice-dialog .dialog-head {
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.invoice-dialog-toolbar {
  border-bottom: 1px solid var(--line);
}

.invoice-dialog-body {
  max-height: calc(100vh - 170px);
  overflow: auto;
  background: #eef2f3;
  padding: 12px 0;
}

.invoice-dialog-body .invoice-preview {
  margin-top: 0;
  margin-bottom: 0;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 120px;
  color: var(--muted);
  text-align: center;
  font-size: 0.86rem;
}

.empty-state strong {
  color: var(--ink);
}

.print-only {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  body.drawer-open {
    overflow: hidden;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(292px, 86vw);
    gap: 18px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: var(--shadow);
    padding: 18px;
    overflow-y: auto;
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.drawer-open .sidebar {
    transform: translateX(0);
  }

  .mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 39;
    display: block;
    border: 0;
    background: rgba(32, 36, 38, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.drawer-open .mobile-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .drawer-close,
  .mobile-menu-button {
    display: grid;
  }

  .main-nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .nav-item {
    grid-template-columns: 28px 1fr;
    justify-items: stretch;
    min-height: 48px;
    padding: 9px 11px;
    text-align: left;
    font-size: 15px;
    font-weight: 800;
  }

  .nav-icon {
    display: grid;
    font-size: 18px;
  }

  .sidebar-note {
    display: grid;
    font-size: 0.92rem;
  }

  .workspace {
    padding: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr auto auto;
    width: 100%;
  }

  .search-box {
    width: 100%;
    grid-template-columns: 22px minmax(0, 1fr);
  }

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

  .home-dashboard,
  .company-layout {
    grid-template-columns: 1fr;
  }

  .company-preview {
    grid-column: auto;
    grid-row: auto;
  }

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

  .invoice-controls {
    grid-template-columns: 1fr;
  }

  .invoice-control-wide {
    grid-column: auto;
  }
}

@media (min-width: 769px) {
  .app-shell {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  body.drawer-open {
    overflow: auto;
  }

  .sidebar,
  body.drawer-open .sidebar {
    position: static;
    inset: auto;
    z-index: auto;
    width: auto;
    box-shadow: none;
    overflow: visible;
    transform: none;
    transition: none;
  }

  .drawer-close,
  .mobile-menu-button,
  .mobile-drawer-backdrop {
    display: none !important;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
  }

  .topbar-actions {
    display: flex;
    width: auto;
  }

  .search-box {
    width: min(292px, 100%);
    grid-template-columns: 22px minmax(120px, 240px);
  }
}

@media (max-width: 640px) {
  :root {
    font-size: 13px;
  }

  input,
  select,
  textarea {
    min-height: 32px;
    padding: 4px 7px;
    font-size: 13px;
  }

  input[type="date"],
  input[type="month"] {
    min-inline-size: 0;
    max-width: 100%;
    text-align: left;
  }

  .invoice-controls input[type="date"] {
    -webkit-appearance: none;
    appearance: none;
    display: block;
    inline-size: 100%;
    min-inline-size: 0 !important;
    max-inline-size: 100%;
    height: 32px;
    padding: 4px 24px 4px 7px;
    overflow: hidden;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23202426' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2v4M16 2v4M3 10h18M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 7px center;
    background-size: 13px 13px;
    line-height: 1;
    white-space: nowrap;
  }

  .invoice-controls input[type="date"]::-webkit-date-and-time-value {
    min-width: 0;
    margin: 0;
    text-align: left;
  }

  .invoice-controls input[type="date"]::-webkit-calendar-picker-indicator {
    width: 18px;
    height: 18px;
    margin: 0 -19px 0 0;
    padding: 0;
    opacity: 0;
  }

  .workspace {
    padding: 10px;
  }

  #export-button {
    display: none;
  }

  .mobile-panel-export {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 58px;
    min-height: 28px;
    padding: 0 10px;
    font-size: 0.78rem;
  }

  .topbar {
    gap: 10px;
  }

  .topbar-title {
    width: 100%;
  }

  .topbar h2 {
    font-size: 1.35rem;
  }

  .topbar-actions {
    width: 100%;
  }

  .search-box {
    width: 100%;
    min-width: 0;
  }

  .topbar-actions,
  .form-grid,
  .form-grid.two,
  .form-grid.three,
  .invoice-address,
  .invoice-total-row {
    grid-template-columns: 1fr;
  }

  .toolbar-controls,
  .form-save-row,
  .seal-editor {
    align-items: stretch;
    flex-direction: column;
  }

  .seal-editor {
    grid-template-columns: 1fr;
  }

  .compact-control {
    grid-template-columns: 1fr;
  }

  #entry-dialog.order-entry-dialog .order-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  #entry-dialog.order-entry-dialog .order-form-dates label:nth-child(3),
  #entry-dialog.order-entry-dialog .order-form-money label:nth-child(3),
  #entry-dialog.order-entry-dialog .order-form-status label:nth-child(3),
  #entry-dialog.order-entry-dialog .order-form-status label:nth-child(4) {
    grid-column: 1 / -1;
  }

  #entry-dialog.order-entry-dialog textarea {
    min-height: 74px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-card {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .metric {
    min-height: 50px;
    padding: 7px 9px;
  }

  .metric span {
    font-size: 0.78rem;
  }

  .metric strong {
    font-size: 1rem;
  }

  .preview-toolbar,
  .section-head,
  .dialog-actions,
  .field-label-row,
  .order-copy-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-toolbar {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 0;
    padding: 6px;
  }

  .panel-toolbar > .segmented {
    flex: 1 1 min(100%, 240px);
  }

  .panel-toolbar > .panel-copy {
    flex: 1 1 100%;
  }

  .panel-toolbar-side {
    align-self: flex-start;
    gap: 6px;
    margin-left: auto;
  }

  .section-head.compact {
    align-items: flex-start;
    flex-direction: row;
  }

  .section-head.compact > div {
    flex: 1 1 auto;
    min-width: 0;
  }

  .section-head .mobile-panel-export {
    align-self: flex-start;
    margin-left: auto;
  }

  .toolbar-controls {
    flex: 1 1 100%;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: end;
    justify-content: flex-start;
    gap: 6px;
  }

  .toolbar-controls .compact-control {
    flex: 0 1 auto;
    min-width: 0;
    width: auto;
  }

  .toolbar-controls .compact-control input {
    width: auto;
    max-width: 100%;
  }

  #home-year {
    width: 78px;
  }

  #home-month {
    width: 136px;
  }

  .toolbar-controls input[type="month"] {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 24px;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23202426' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2v4M16 2v4M3 10h18M5 4h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 7px center;
    background-size: 13px 13px;
  }

  .toolbar-controls input[type="month"]::-webkit-date-and-time-value {
    min-width: 0;
    margin: 0;
    text-align: left;
  }

  .toolbar-controls input[type="month"]::-webkit-calendar-picker-indicator {
    width: 18px;
    height: 18px;
    margin: 0 -19px 0 0;
    padding: 0;
    opacity: 0;
  }

  .toolbar-controls .mobile-panel-export {
    align-self: end;
    margin-left: auto;
  }

  #home-view .toolbar-controls {
    flex: 0 1 auto;
    gap: 4px;
  }

  #home-view #home-year {
    width: 72px;
  }

  #home-view #home-month {
    width: 128px;
  }

  #home-view .toolbar-controls .mobile-panel-export {
    margin-left: 0;
  }

  .invoice-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 7px;
    row-gap: 8px;
    padding: 8px;
  }

  .invoice-controls label:first-child,
  .invoice-control-wide,
  .invoice-controls .button {
    grid-column: 1 / -1;
  }

  label,
  .field-block {
    gap: 3px;
    font-size: 0.8rem;
  }

  .button {
    min-height: 30px;
    font-size: 0.88rem;
  }

  .segmented,
  .status-segments {
    gap: 4px;
  }

  .segment {
    min-height: 28px;
    border-radius: 7px;
    padding: 0 6px;
    font-size: 0.78rem;
  }

  .segment-divider {
    height: 18px;
    margin: 0 1px;
  }

  .result-count {
    font-size: 0.78rem;
    line-height: 28px;
  }

  .data-table th,
  .data-table td {
    padding: 4px 5px;
  }

  .data-table th {
    font-size: 0.74rem;
  }

  .data-table td {
    font-size: 0.78rem;
    line-height: 1.18;
  }

  .orders-table {
    min-width: 640px;
  }

  .orders-table th:nth-child(1),
  .orders-table td:nth-child(1) {
    width: 80px;
  }

  .orders-table th:nth-child(2),
  .orders-table td:nth-child(2) {
    width: 100px;
  }

  .orders-table th:nth-child(3),
  .orders-table td:nth-child(3) {
    width: 100px;
  }

  .orders-table th:nth-child(5),
  .orders-table td:nth-child(5),
  .orders-table th:nth-child(6),
  .orders-table td:nth-child(6) {
    width: 62px;
  }

  .orders-table th:nth-child(7),
  .orders-table td:nth-child(7) {
    width: 42px;
  }

  .orders-table th:nth-child(8),
  .orders-table td:nth-child(8) {
    width: 84px;
  }

  .orders-table .status-pill {
    min-width: 52px;
    min-height: 20px;
    padding: 0 5px;
    font-size: 0.7rem;
  }

  .orders-table .sort-button {
    gap: 2px;
  }

  .services-table {
    min-width: 820px;
  }

  .clients-table {
    min-width: 1040px;
  }

  #issued-invoices .invoice-table,
  #unpaid-invoices .invoice-table,
  #paid-invoices .invoice-table {
    min-width: 0;
    display: block;
  }

  .invoice-list-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-width: 0;
    padding: 6px;
  }

  #issued-invoices .invoice-table thead,
  #unpaid-invoices .invoice-table thead,
  #paid-invoices .invoice-table thead,
  #invoice-order-list .invoice-table thead {
    display: none;
  }

  #issued-invoices .invoice-table tbody,
  #unpaid-invoices .invoice-table tbody,
  #paid-invoices .invoice-table tbody,
  #invoice-order-list .invoice-table tbody {
    display: grid;
    gap: 6px;
    padding: 6px;
  }

  #issued-invoices .invoice-table tr,
  #unpaid-invoices .invoice-table tr,
  #paid-invoices .invoice-table tr,
  #invoice-order-list .invoice-table tr {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 8px;
  }

  #issued-invoices .invoice-table td,
  #unpaid-invoices .invoice-table td,
  #paid-invoices .invoice-table td,
  #invoice-order-list .invoice-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 0;
    padding: 2px 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  #issued-invoices .invoice-table td:nth-child(n),
  #unpaid-invoices .invoice-table td:nth-child(n),
  #paid-invoices .invoice-table td:nth-child(n),
  #invoice-order-list .invoice-table td:nth-child(n) {
    width: auto;
  }

  #issued-invoices .invoice-table td::before,
  #unpaid-invoices .invoice-table td::before,
  #paid-invoices .invoice-table td::before,
  #invoice-order-list .invoice-table td::before {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
  }

  #issued-invoices .invoice-table td:nth-child(1),
  #unpaid-invoices .invoice-table td:nth-child(1),
  #paid-invoices .invoice-table td:nth-child(1),
  #invoice-order-list .invoice-table td:nth-child(1) {
    grid-row: 1 / span 2;
    align-self: start;
    padding-top: 2px;
  }

  #issued-invoices .invoice-table td:nth-child(n + 2),
  #unpaid-invoices .invoice-table td:nth-child(n + 2),
  #paid-invoices .invoice-table td:nth-child(n + 2),
  #invoice-order-list .invoice-table td:nth-child(n + 2) {
    grid-column: 2;
    min-width: 0;
  }

  #issued-invoices .invoice-table td:nth-child(2)::before,
  #unpaid-invoices .invoice-table td:nth-child(2)::before,
  #paid-invoices .invoice-table td:nth-child(2)::before {
    content: "番号";
  }

  #issued-invoices .invoice-table td:nth-child(3)::before,
  #unpaid-invoices .invoice-table td:nth-child(3)::before,
  #paid-invoices .invoice-table td:nth-child(3)::before {
    content: "発行日";
  }

  #issued-invoices .invoice-table td:nth-child(4)::before,
  #unpaid-invoices .invoice-table td:nth-child(4)::before,
  #paid-invoices .invoice-table td:nth-child(4)::before {
    content: "取引先";
  }

  #issued-invoices .invoice-table td:nth-child(5)::before,
  #unpaid-invoices .invoice-table td:nth-child(5)::before,
  #paid-invoices .invoice-table td:nth-child(5)::before {
    content: "期間";
  }

  #issued-invoices .invoice-table td:nth-child(6)::before,
  #unpaid-invoices .invoice-table td:nth-child(6)::before,
  #paid-invoices .invoice-table td:nth-child(6)::before {
    content: "件数";
  }

  #issued-invoices .invoice-table td:nth-child(7)::before,
  #unpaid-invoices .invoice-table td:nth-child(7)::before,
  #paid-invoices .invoice-table td:nth-child(7)::before {
    content: "金額";
  }

  #issued-invoices .invoice-table td:nth-child(8)::before,
  #unpaid-invoices .invoice-table td:nth-child(8)::before,
  #paid-invoices .invoice-table td:nth-child(8)::before {
    content: "入金";
  }

  #issued-invoices .invoice-table td:nth-child(9),
  #unpaid-invoices .invoice-table td:nth-child(9),
  #paid-invoices .invoice-table td:nth-child(9) {
    display: block;
    grid-column: 1 / -1;
    padding-top: 6px;
  }

  #issued-invoices .invoice-actions,
  #unpaid-invoices .invoice-actions,
  #paid-invoices .invoice-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
  }

  #issued-invoices .invoice-actions .button,
  #unpaid-invoices .invoice-actions .button,
  #paid-invoices .invoice-actions .button {
    min-height: 28px;
    padding: 0 5px;
    font-size: 0.72rem;
  }

  #invoice-order-list .invoice-table {
    min-width: 0;
    display: block;
  }

  #invoice-order-list .invoice-table td:nth-child(2)::before {
    content: "納品日";
  }

  #invoice-order-list .invoice-table td:nth-child(3)::before {
    content: "品名";
  }

  #invoice-order-list .invoice-table td:nth-child(4)::before {
    content: "詳細";
  }

  #invoice-order-list .invoice-table td:nth-child(5)::before {
    content: "数量";
  }

  #invoice-order-list .invoice-table td:nth-child(6)::before {
    content: "金額";
  }

  .manual-invoice-table {
    min-width: 0;
    display: block;
  }

  .manual-invoice-table thead {
    display: none;
  }

  .manual-invoice-table tbody {
    display: grid;
    gap: 6px;
    padding: 6px;
  }

  .manual-invoice-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 8px;
  }

  .manual-invoice-table td,
  .manual-invoice-table td:nth-child(n) {
    display: grid;
    gap: 3px;
    width: auto;
    border-bottom: 0;
    padding: 0;
  }

  .manual-invoice-table td::before {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 800;
  }

  .manual-invoice-table td:nth-child(1),
  .manual-invoice-table td:nth-child(2),
  .manual-invoice-table td:nth-child(6) {
    grid-column: 1 / -1;
  }

  .manual-invoice-table td:nth-child(1)::before {
    content: "品名";
  }

  .manual-invoice-table td:nth-child(2)::before {
    content: "詳細";
  }

  .manual-invoice-table td:nth-child(3)::before {
    content: "数量";
  }

  .manual-invoice-table td:nth-child(4)::before {
    content: "単価（税抜）";
  }

  .manual-invoice-table td:nth-child(5)::before {
    content: "金額（税込）";
  }

  .manual-invoice-table td:nth-child(6) .button {
    justify-self: end;
  }

  .copy-actions {
    justify-content: flex-start;
  }

  .preview-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .copy-status {
    min-width: 0;
    text-align: left;
  }

  .dialog-actions > div {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button {
    width: 100%;
  }

  .button.mobile-panel-export {
    width: auto;
  }

  .grid-list {
    grid-template-columns: 1fr;
  }

  .invoice-tabs {
    display: flex;
    gap: 4px;
  }

  .invoice-tab {
    width: auto;
    min-height: 28px;
    padding: 0 8px;
    font-size: 0.76rem;
  }

  .invoice-tabs .mobile-panel-export {
    margin-left: auto;
  }

  .invoice-preview {
    width: 794px;
    min-width: 794px;
    max-width: none;
    min-height: 1123px;
    margin: 8px 0;
    padding: 34px;
  }

  .invoice-title-row {
    grid-template-columns: minmax(220px, 1fr) minmax(240px, 330px);
    gap: 24px;
  }

  .invoice-meta {
    text-align: right;
  }

  .invoice-address {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  }

  .invoice-total-row {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  }

  .invoice-company.has-seal {
    grid-template-columns: minmax(0, 1fr) 76px;
  }

  .invoice-seal {
    width: 76px;
    height: 76px;
  }

  .invoice-preview th,
  .invoice-preview td {
    padding: 10px 8px;
    font-size: 0.82rem;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 16mm;
  }

  html,
  body {
    background: #fff;
    width: auto;
    min-height: 0;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  .sidebar,
  .topbar,
  .metrics,
  .invoice-tabs,
  .invoice-issue-panel,
  .invoice-section,
  .invoice-controls,
  .preview-toolbar,
  .panel:not(#invoices-view) {
    display: none !important;
  }

  .app-shell,
  .workspace,
  .invoice-workflow {
    display: block;
    padding: 0;
  }

  #invoices-view,
  .invoice-preview-shell,
  .invoice-preview {
    border: 0;
    box-shadow: none;
  }

  .invoice-preview {
    width: auto;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    page-break-after: auto;
    zoom: 1 !important;
  }

  .invoice-preview table {
    width: 100%;
  }

  .invoice-preview thead {
    display: table-header-group;
  }

  .invoice-preview tr,
  .invoice-title-row,
  .invoice-address,
  .invoice-info-lines,
  .invoice-total-row,
  .invoice-note {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  body.printing-invoice-modal .app-shell {
    display: none !important;
  }

  body.printing-invoice-modal #invoice-preview-dialog {
    display: block !important;
    position: static !important;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
  }

  body.printing-invoice-modal #invoice-preview-dialog::backdrop,
  body.printing-invoice-modal #invoice-preview-dialog .dialog-head,
  body.printing-invoice-modal #invoice-preview-dialog .preview-toolbar {
    display: none !important;
  }

  body.printing-invoice-modal .invoice-dialog-card,
  body.printing-invoice-modal .invoice-dialog-body {
    display: block !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
    background: #fff !important;
  }

  body.printing-invoice-modal #invoice-modal-preview {
    width: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    zoom: 1 !important;
  }
}
