@import url("/assets/fonts/noto-sans-jp.css");

:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-alt: #eef2f3;
  --line: #d8e0e3;
  --text: #182225;
  --muted: #657377;
  --accent: #0f766e;
  --accent-dark: #0b5e58;
  --info: #2563eb;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b42318;
  --shadow: 0 14px 38px rgba(25, 36, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
margin: 0;
color: var(--text);
background: var(--bg);
font-family: "Noto Sans JP Variable", "Noto Sans JP", sans-serif;
}

.admin-host-block {
display: grid;
min-height: 100vh;
place-items: center;
padding: 24px;
}

.admin-host-block section {
display: grid;
gap: 12px;
width: min(520px, 100%);
border: 1px solid var(--line);
border-radius: 8px;
background: var(--surface);
box-shadow: var(--shadow);
padding: 24px;
}

.admin-host-block strong {
font-size: 20px;
}

.admin-host-block p {
margin: 0;
color: var(--muted);
line-height: 1.7;
}

.admin-host-block a {
color: var(--accent);
font-weight: 800;
}

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

button,
.file-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover,
.file-button:hover {
  border-color: var(--accent);
}

.primary-action {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.primary-action:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.secondary-action {
  background: var(--surface-alt);
}

.danger-action {
  color: var(--danger);
}

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

.app-shell.sidebar-closed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
  background: #fbfcfc;
  min-width: 320px;
  overflow: hidden;
  padding: 22px;
  transition: opacity 140ms ease, transform 180ms ease, visibility 180ms ease;
}

.sidebar-closed .sidebar {
  visibility: hidden;
  opacity: 0;
  transform: translateX(-100%);
  pointer-events: none;
}

.sidebar-backdrop {
  display: none;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.nav-tabs {
  display: grid;
  gap: 6px;
}

.nav-tabs button {
  justify-content: flex-start;
  text-align: left;
  background: transparent;
}

.nav-tabs button.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}

.document-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.portal-tool-link {
  display: grid;
  gap: 3px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  background: #eef6f5;
  color: var(--accent-dark);
  padding: 11px 12px;
  text-decoration: none;
}

.portal-tool-link span {
  font-size: 12px;
  font-weight: 800;
}

.portal-tool-link strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.portal-tool-link:hover {
  border-color: var(--accent);
  background: #e3f1ef;
}

.search-box,
label {
  display: grid;
  gap: 6px;
}

label span,
.search-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.document-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.document-row {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  text-align: left;
}

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

.document-row.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.document-row strong {
  font-size: 14px;
}

.document-row span {
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  min-width: 0;
}

.topbar {
position: sticky;
top: 0;
z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 247, 248, 0.95);
  backdrop-filter: blur(12px);
  padding: 14px 20px;
}

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

.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  font-weight: 800;
}

.sidebar-toggle > span[aria-hidden] {
  font-size: 18px;
  line-height: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.pdf-library-page {
  min-height: calc(100vh - 72px);
}

.pdf-metric-card {
  position: relative;
  overflow: hidden;
}

.pdf-metric-card::after {
  position: absolute;
  right: -24px;
  bottom: -34px;
  width: 92px;
  height: 92px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 9%, transparent);
  content: "";
}

.pdf-metric-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.pdf-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(150px, 220px) minmax(150px, 220px);
  gap: 14px;
  margin: 20px 20px 0;
  padding: 16px;
}

.pdf-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.pdf-toolbar input,
.pdf-toolbar select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 12px;
}

.pdf-library-layout {
  display: grid;
  grid-template-columns: minmax(330px, 0.8fr) minmax(500px, 1.2fr);
  gap: 20px;
  padding: 20px;
}

.pdf-list-panel,
.pdf-detail-panel {
  min-width: 0;
}

.section-kicker {
  color: var(--accent);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.15em;
}

.pdf-library-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 350px);
  overflow: auto;
  padding-right: 3px;
}

.pdf-library-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  height: auto;
  min-height: 0;
  border-color: transparent;
  background: #f8fafb;
  text-align: left;
  padding: 14px;
}

.pdf-library-card:hover,
.pdf-library-card.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 6%, white);
}

.pdf-library-card.active {
  box-shadow: inset 3px 0 var(--accent);
}

.pdf-file-icon {
  display: grid;
  width: 46px;
  height: 54px;
  place-items: center;
  border-radius: 6px;
  background: #b42318;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
}

.pdf-card-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.pdf-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pdf-card-topline strong,
.pdf-card-subject,
.pdf-card-meta,
.pdf-card-date {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-card-subject { font-size: 13px; font-weight: 700; }
.pdf-card-meta, .pdf-card-date { color: var(--muted); font-size: 11px; }

.pdf-detail-panel {
  align-content: start;
}

.pdf-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.pdf-detail-header h2 { margin: 3px 0; }
.pdf-detail-header p { margin: 0; color: var(--muted); }

.pdf-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.pdf-detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.pdf-detail-meta div { min-width: 0; background: var(--surface); padding: 10px 12px; }
.pdf-detail-meta dt { color: var(--muted); font-size: 10px; font-weight: 700; }
.pdf-detail-meta dd { overflow: hidden; margin: 3px 0 0; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }

.pdf-preview-frame-wrap {
  overflow: hidden;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #e9edef;
}

.pdf-preview-frame { display: block; width: 100%; min-height: 680px; border: 0; }

.pdf-empty-state,
.pdf-detail-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-height: 220px;
  place-content: center;
  color: var(--muted);
  text-align: center;
}

.pdf-empty-state span,
.pdf-detail-empty p { margin: 0; font-size: 12px; }
.pdf-empty-illustration { display: grid; width: 74px; height: 88px; place-items: center; border-radius: 10px; background: #fbe9e8; color: var(--danger); font-weight: 900; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 20px 20px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.board-layout,
.masters-layout,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 20px;
  padding: 20px;
}

.board-layout > *,
.masters-layout > *,
.settings-grid > * {
  min-width: 0;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 10px;
  overflow-x: auto;
}

.pipeline-column {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 10px;
}

.pipeline-column h3 {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.pipeline-column button,
.activity-list button,
.master-list button,
.project-list button {
  display: grid;
  gap: 4px;
  width: 100%;
  height: auto;
  min-height: 0;
  text-align: left;
  padding: 10px;
}

.pipeline-column strong,
.activity-list strong,
.master-list strong,
.project-list strong {
  font-size: 13px;
}

.pipeline-column span,
.pipeline-column em,
.activity-list span,
.master-list span,
.project-list span {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.activity-list,
.master-list,
.project-list {
  display: grid;
  gap: 8px;
}

.share-access-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.access-summary-card {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 9px 10px;
}

.access-summary-card span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.access-summary-card strong {
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.3;
}

.access-summary-card.success {
  border-color: rgba(13, 121, 82, 0.25);
  background: #f0fdf4;
  color: var(--success);
}

.access-summary-card.danger {
  border-color: rgba(180, 35, 24, 0.25);
  background: #fef2f2;
  color: var(--danger);
}

.project-row.needs-followup {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}

.project-title {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.internal-id {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.project-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.project-list .billing-amount {
  color: var(--danger);
  font-size: 12px;
}

.activity-entry {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.activity-entry span,
.activity-entry p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.backup-restore-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.backup-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.backup-entry {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 9px 10px;
}

.backup-entry strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.backup-entry span {
  color: var(--muted);
  font-size: 12px;
}

.master-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 270px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.segmented-control button {
  border: 0;
  border-radius: 0;
  background: transparent;
  min-width: 0;
  padding-inline: 10px;
  white-space: nowrap;
}

.segmented-control button.active {
  background: var(--accent);
  color: #fff;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.more-actions {
  position: relative;
}

.more-actions summary {
  display: grid;
  place-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  list-style: none;
}

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

.more-actions-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 6px;
  width: 220px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16);
}

.more-actions-menu button,
.more-actions-menu .file-button {
  width: 100%;
  justify-content: start;
  text-align: left;
}

.file-button {
  display: inline-grid;
  place-items: center;
  position: relative;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.92fr) minmax(520px, 1.08fr);
  gap: 20px;
  padding: 20px;
}

.input-panel {
  display: grid;
  align-content: start;
  gap: 16px;
}

.project-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 8px;
  background: #eef6f5;
}

.project-identity span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.project-identity code {
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
}

.panel-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.full-span {
  grid-column: 1 / -1;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 16px;
}

.items-editor {
  display: grid;
  gap: 10px;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.5fr) 74px 66px 88px 90px 40px 40px;
  gap: 8px;
  align-items: end;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
  color: var(--danger);
}

.preview-panel {
  min-width: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  padding: 3px 8px;
  background: #eef2f3;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.badge.info {
  background: #eff6ff;
  color: var(--info);
}

.badge.success {
  background: #f0fdf4;
  color: var(--success);
}

.badge.warning {
  background: #fffbeb;
  color: var(--warning);
}

.badge.danger {
  background: #fef2f2;
  color: var(--danger);
}

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

.check-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.check-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.check-item.ok span {
  color: var(--success);
}

.check-item.warn span {
  color: var(--warning);
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.operation-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 40px));
  border: 1px solid #9fc8c1;
  border-radius: 6px;
  padding: 12px 16px;
  color: #123f38;
  background: #eef8f6;
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.18);
  font-size: 13px;
  font-weight: 700;
}

.operation-toast[data-tone="error"] {
  border-color: #e6aaaa;
  color: #7f1d1d;
  background: #fff1f1;
}

.operation-toast[data-tone="progress"] {
  border-color: #b8c5cc;
  color: #34454d;
  background: #f5f8f9;
}

.save-status {
  min-width: 108px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.save-status[data-state="dirty"] { color: #9a6700; }
.save-status[data-state="saving"] { color: #52646d; }
.save-status[data-state="saved"] { color: #0f6b5f; }
.save-status[data-state="local"] { color: #a32828; }

.document-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.progress-billing-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border: 1px solid #c9ddd7;
  border-radius: 12px;
  background: #f1f7f5;
}

.progress-billing-summary[hidden],
.progress-billing-fields[hidden],
#progressBillingSequenceField[hidden] {
  display: none;
}

.progress-billing-summary div {
  min-width: 0;
}

.progress-billing-summary span,
.progress-billing-summary strong {
  display: block;
}

.progress-billing-summary span {
  color: #64736f;
  font-size: 12px;
}

.progress-billing-summary strong {
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.progress-billing-error {
  grid-column: 1 / -1;
  margin: 0;
  color: #a33a32;
}

.progress-project-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  background: #f1f7f5;
}

.progress-project-summary > span {
  min-width: 0;
}

.progress-project-summary small,
.progress-project-summary strong {
  display: block;
}

.progress-project-summary small {
  color: #64736f;
}

.progress-project-summary strong {
  overflow-wrap: anywhere;
}

.progress-control-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
  padding: 24px 26px;
  border: 1px solid #d8e4e1;
  border-radius: 18px;
  background: linear-gradient(135deg, #f7fbfa 0%, #edf7f4 100%);
}

.progress-control-header .eyebrow {
  color: #2f766c;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .14em;
}

.progress-control-header h2 {
  margin: 5px 0 6px;
  font-size: clamp(24px, 3vw, 34px);
}

.progress-control-header p {
  margin: 0;
  color: var(--muted);
}

.progress-filter {
  min-width: 180px;
}

.progress-filter span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

#progressView .dashboard-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.progress-portfolio-list {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}

.progress-portfolio-card {
  overflow: hidden;
  border: 1px solid #d9e3e0;
  border-left: 5px solid #4f8f84;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(38, 65, 59, .07);
}

.progress-portfolio-card.complete { border-left-color: #3e8b65; }
.progress-portfolio-card.over { border-left-color: #c74b45; }
.progress-portfolio-card.needs_setup { border-left-color: #c48b2b; }

.progress-portfolio-card > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
}

.progress-card-client {
  color: #62736f;
  font-size: 12px;
  font-weight: 700;
}

.progress-portfolio-card h3 {
  margin: 4px 0 6px;
  font-size: 20px;
}

.progress-portfolio-card code {
  color: #61706c;
  font-size: 11px;
}

.progress-money-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-block: 1px solid #edf1f0;
  background: #fbfcfc;
}

.progress-money-grid div {
  min-width: 0;
  padding: 16px 22px;
  border-right: 1px solid #edf1f0;
}

.progress-money-grid div:last-child { border-right: 0; }

.progress-money-grid span,
.progress-money-grid strong {
  display: block;
}

.progress-money-grid span {
  color: #6c7a77;
  font-size: 12px;
}

.progress-money-grid strong {
  margin-top: 5px;
  font-size: 19px;
  overflow-wrap: anywhere;
}

.progress-money-grid .negative {
  color: #a8322d;
  background: #fff4f3;
}

.progress-bar-row {
  padding: 18px 22px;
}

.progress-bar-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
}

.progress-track {
  overflow: hidden;
  height: 12px;
  border-radius: 999px;
  background: #e6ecea;
}

.progress-track > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2d746a, #65aa98);
}

.progress-portfolio-card.over .progress-track > span {
  background: #c74b45;
}

.progress-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 10px;
  color: #63726f;
  font-size: 11px;
}

.progress-breakdown i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 50%;
}

.progress-breakdown .paid { background: #37845f; }
.progress-breakdown .issued { background: #d08a27; }
.progress-breakdown .draft { background: #9ba6a3; }

.progress-invoice-history {
  padding: 0 22px 18px;
}

.progress-invoice-history h4 {
  margin: 0 0 9px;
  font-size: 13px;
}

.progress-invoice-history > div {
  display: grid;
  gap: 6px;
}

.progress-invoice-history button {
  display: grid;
  grid-template-columns: 64px minmax(140px, 1fr) minmax(100px, auto) auto minmax(130px, auto);
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e3e9e7;
  border-radius: 9px;
  color: var(--text);
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.progress-invoice-history button:hover {
  border-color: #8fb8ae;
  background: #f7fbfa;
}

.progress-invoice-history .sequence {
  font-weight: 800;
}

.progress-invoice-history .invoice-number,
.progress-invoice-history .invoice-date {
  color: #687773;
  font-size: 12px;
}

.progress-portfolio-card > footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 22px;
  border-top: 1px solid #edf1f0;
  background: #fbfcfc;
}

.progress-empty-state {
  display: grid;
  gap: 6px;
  padding: 44px 24px;
  border: 1px dashed #b9cbc6;
  border-radius: 14px;
  color: #60716d;
  text-align: center;
  background: #f8fbfa;
}

.document-preview {
  width: min(100%, 860px);
  min-height: 1110px;
  margin: 0 auto;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 48px;
}

.paper-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 3px solid var(--text);
  padding-bottom: 18px;
}

.paper-logo {
  display: block;
  max-width: 180px;
  max-height: 64px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 14px;
}

.paper-title {
  margin: 0;
  font-size: 32px;
  letter-spacing: 0;
}

.paper-meta {
  text-align: right;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.paper-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  margin: 32px 0;
}

.order-header {
  align-items: start;
}

.order-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
  margin: 30px 0 22px;
}

.order-party {
  position: relative;
  min-height: 118px;
  border: 1px solid var(--line);
  padding: 14px 16px;
}

.order-party h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
}

.order-party strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

.order-customer {
  padding-right: 94px;
}

.order-electronic-stamp {
  position: absolute;
  top: 18px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border: 2px solid rgba(185, 28, 28, 0.78);
  color: rgba(185, 28, 28, 0.9);
  background: rgba(255, 255, 255, 0.7);
  font-weight: 800;
  text-align: center;
  line-height: 1.15;
}

.order-electronic-stamp span {
  display: block;
  font-size: 12px;
}

.order-electronic-stamp strong {
  margin: 0;
  font-size: 11px;
  overflow-wrap: anywhere;
}

.order-lead {
  margin: 18px 0 12px;
}

.order-meta-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 20px;
  font-size: 13px;
}

.order-meta-table th,
.order-meta-table td {
  border: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
}

.order-meta-table th {
  width: 118px;
  background: #edf4f3;
}

.order-total {
  margin: 20px 0 18px;
}

.electronic-approval {
  clear: both;
  margin: 22px 0 0;
  border: 1px solid var(--line);
  padding: 12px 14px;
  background: #f8faf9;
  break-inside: avoid;
  page-break-inside: avoid;
}

.electronic-approval h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.electronic-approval p {
  margin: 0 0 10px;
  font-size: 12px;
}

.electronic-approval dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 14px;
  margin: 0;
}

.electronic-approval div {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 8px;
  font-size: 12px;
}

.electronic-approval dt {
  color: var(--muted);
  font-weight: 800;
}

.electronic-approval dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.electronic-approval small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.share-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  margin: 16px 0 0;
  border: 1px solid var(--line);
  padding: 12px 14px;
  break-inside: avoid;
  page-break-inside: avoid;
}

.share-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.share-card p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.share-card dl {
  margin: 0;
}

.share-card div div {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 8px;
  font-size: 11px;
}

.share-card dt {
  color: var(--muted);
  font-weight: 800;
}

.share-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.share-qr {
  width: 92px;
  height: 92px;
  object-fit: contain;
}

.client-name {
  border-bottom: 1px solid var(--line);
  font-size: 20px;
  font-weight: 800;
  padding-bottom: 8px;
}

.multiline {
  white-space: pre-wrap;
  line-height: 1.7;
}

.issuer-block {
  text-align: right;
}

.issuer-stamp-wrap {
  position: relative;
  display: block;
  min-height: 96px;
}

.issuer-details {
  padding-right: 44px;
}

.stamp-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 74px;
  height: 74px;
  border: 3px double rgba(185, 28, 28, 0.82);
  border-radius: 50%;
  color: rgba(185, 28, 28, 0.86);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0;
  transform: rotate(-8deg);
}

.stamp-mark span {
  display: block;
}

.stamp-image {
  display: block;
  position: absolute;
  top: -5px;
  right: 0;
  width: 82px;
  height: 82px;
  object-fit: contain;
  opacity: 0.86;
}

.stamp-image-wrap {
  position: absolute;
  top: -5px;
  right: 0;
  width: 82px;
  height: 82px;
}

.stamp-image-wrap .stamp-image {
  position: static;
}

.stamp-image-error {
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  border: 3px double rgba(185, 28, 28, 0.82);
  border-radius: 50%;
  color: rgba(185, 28, 28, 0.86);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 14px;
  font-weight: 800;
  transform: rotate(-8deg);
}

.stamp-image-error[hidden] { display: none; }

.asset-control {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.asset-control span {
display: block;
color: var(--muted);
font-size: 12px;
font-weight: 700;
margin-bottom: 6px;
}

.final-pdf-control {
display: grid;
grid-template-columns: minmax(180px, 1fr) auto;
gap: 12px;
align-items: center;
padding: 12px;
border: 1px solid var(--line);
border-radius: 8px;
background: #f8faf9;
}

.final-pdf-control span {
display: block;
color: var(--muted);
font-size: 12px;
font-weight: 700;
margin-bottom: 6px;
}

.final-pdf-control strong {
display: block;
overflow-wrap: anywhere;
}

.final-pdf-control small {
display: block;
margin-top: 4px;
color: var(--muted);
line-height: 1.5;
overflow-wrap: anywhere;
}

.asset-preview {
  display: grid;
  place-items: center start;
  min-height: 72px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.asset-preview img {
  max-width: 220px;
  max-height: 60px;
  object-fit: contain;
}

.asset-preview .asset-stamp-preview {
  max-width: 92px;
  max-height: 92px;
}

.asset-preview span {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.total-box {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 2px solid var(--text);
  margin: 26px 0;
  padding: 14px 18px;
}

.total-box span {
  font-size: 14px;
}

.total-box strong {
  font-size: 28px;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
  font-size: 13px;
}

.items-table th,
.items-table td {
  border: 1px solid var(--line);
  padding: 9px;
}

.items-table th {
  background: #edf4f3;
  text-align: left;
}

.items-table .number {
  text-align: right;
  white-space: nowrap;
}

.summary-table {
  width: 320px;
  margin: 10px 0 0 auto;
  border-collapse: collapse;
  font-size: 13px;
}

.summary-table th,
.summary-table td {
  border-bottom: 1px solid var(--line);
  padding: 4px 0;
  line-height: 1.25;
}

.summary-table th {
  color: var(--muted);
  font-weight: 700;
  text-align: left;
}

.summary-table td {
  text-align: right;
}

.paper-footer {
  display: grid;
  gap: 16px;
  margin-top: 30px;
  color: #2f3b3f;
  font-size: 13px;
}

.paper-footer h3 {
  margin: 0 0 6px;
  font-size: 13px;
}

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

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: min(320px, calc(100vw - 48px));
    min-width: 0;
    height: 100dvh;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 18px 0 48px rgba(24, 34, 37, 0.18);
  }

  .app-shell:not(.sidebar-closed) .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
    background: rgba(24, 34, 37, 0.34);
    padding: 0;
  }

  .app-shell.sidebar-closed {
    grid-template-columns: 1fr;
  }

.backend-warning {
display: grid;
grid-template-columns: auto 1fr auto;
gap: 10px;
align-items: center;
margin: 12px 0;
padding: 12px;
border: 1px solid #f59e0b;
border-radius: 8px;
background: #fffbeb;
color: #78350f;
}

.backend-warning span {
line-height: 1.5;
}

.backend-warning button {
border: 1px solid #92400e;
border-radius: 6px;
background: #fff;
color: #78350f;
font-weight: 800;
padding: 8px 12px;
cursor: pointer;
}

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

  .dashboard-grid,
  .board-layout,
  .masters-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .pdf-library-layout {
    grid-template-columns: 1fr;
  }

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

  .pdf-library-list {
    max-height: 520px;
  }

  .pipeline {
    grid-template-columns: repeat(3, minmax(170px, 1fr));
  }
}

@media (max-width: 720px) {
.progress-billing-summary,
.progress-project-summary {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.progress-control-header {
  display: grid;
  align-items: stretch;
  padding: 20px;
}

.progress-filter { min-width: 0; }

#progressView .dashboard-grid,
.progress-money-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.progress-money-grid div:nth-child(2) { border-right: 0; }
.progress-money-grid div:nth-child(-n + 2) { border-bottom: 1px solid #edf1f0; }

.progress-invoice-history button {
  grid-template-columns: auto 1fr auto;
}

.progress-invoice-history .invoice-number,
.progress-invoice-history .invoice-date {
  grid-column: span 3;
}

.progress-portfolio-card > footer {
  display: grid;
}

.backend-warning {
  grid-template-columns: 1fr;
}

.topbar,
.paper-header,
.paper-parties,
.order-parties {
  display: grid;
}

  .paper-parties,
  .order-parties {
    grid-template-columns: minmax(0, 1fr);
  }

  .segmented-control {
    width: 100%;
  }

  .topbar-leading {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .sidebar-toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .editor-layout {
    padding: 12px;
  }

  .two-col,
  .item-row {
    grid-template-columns: 1fr;
  }

  .dashboard-grid,
  .checklist,
  .backup-restore-grid {
    grid-template-columns: 1fr;
  }

  .pdf-toolbar {
    grid-template-columns: 1fr;
    margin: 12px 12px 0;
  }

  .pdf-library-layout {
    gap: 12px;
    padding: 12px;
  }

  .pdf-detail-actions > button {
    flex: 1 1 calc(50% - 8px);
  }

  .pdf-detail-meta {
    grid-template-columns: 1fr;
  }

  .pdf-preview-frame {
    min-height: 520px;
  }

  .document-preview {
    min-height: 0;
    padding: 26px 18px;
  }

  .issuer-block,
  .paper-meta {
    text-align: left;
  }

  .issuer-stamp-wrap,
  .asset-control {
    display: grid;
    justify-content: start;
  }

.items-table {
  font-size: 12px;
}

.electronic-approval dl {
  grid-template-columns: 1fr;
}

.share-card {
  grid-template-columns: 1fr;
}
}

@media print {
  body[data-backend]::after {
    display: none;
  }

  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .view:not(#documentsView),
  .input-panel {
    display: none;
  }

  .app-shell,
  .workspace,
  .editor-layout,
  .preview-panel {
    display: block;
    min-height: 0;
    padding: 0;
  }

  .document-preview {
    width: 100%;
    min-height: 0;
    margin: 0;
    box-shadow: none;
    padding: 18mm;
  }
}
