:root {
  --navy: #182536;
  --navy-2: #22344a;
  --blue: #1557a0;
  --blue-dark: #0e437d;
  --blue-soft: #eaf2fb;
  --canvas: #f3f5f7;
  --surface: #ffffff;
  --line: #d8dee6;
  --line-dark: #b8c2cf;
  --ink: #17202b;
  --muted: #5f6c7b;
  --subtle: #8491a1;
  --green: #147d55;
  --green-soft: #e8f5ef;
  --amber: #996200;
  --amber-soft: #fff3d6;
  --red: #b42318;
  --red-soft: #fff0ef;
  --shadow: 0 1px 2px rgba(18, 32, 50, .07), 0 8px 24px rgba(18, 32, 50, .04);
  font-family: "Yu Gothic UI", "Noto Sans JP", "Meiryo", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
html { min-width: 1120px; background: var(--canvas); }
body { margin: 0; font-size: 14px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }

.app-shell { min-height: 100vh; }
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: 58px;
  z-index: 30;
  color: #fff;
  background: var(--navy);
  display: grid;
  grid-template-columns: 280px 1fr auto;
  align-items: center;
  box-shadow: 0 1px 0 rgba(255,255,255,.08);
}
.brand { height: 58px; display: flex; align-items: center; gap: 11px; padding: 0 20px; border-right: 1px solid rgba(255,255,255,.12); }
.brand-mark { width: 30px; height: 30px; border: 2px solid #76b7ff; color: #8cc3ff; display: grid; place-items: center; font-weight: 800; }
.brand div { display: flex; flex-direction: column; line-height: 1.18; }
.brand strong { font-size: 13px; letter-spacing: .1em; }
.brand span:last-child { font-size: 10px; color: #b6c3d1; margin-top: 3px; letter-spacing: .06em; }
.topbar-center { display: flex; align-items: center; gap: 16px; padding: 0 22px; }
.environment { border: 1px solid #d2a84c; color: #ffe2a0; font-size: 11px; padding: 2px 8px; border-radius: 3px; font-weight: 700; }
.business-date { color: #c9d3df; font-size: 12px; }
.topbar-actions { height: 100%; display: flex; align-items: center; }
.icon-button { position: relative; color: #c7d2de; width: 42px; height: 100%; border: 0; background: transparent; font-size: 8px; }
.notice-dot { position: absolute; top: 18px; right: 13px; width: 6px; height: 6px; border-radius: 50%; background: #f05a49; }
.division { color: #c9d3df; font-size: 12px; padding: 0 14px; border-left: 1px solid rgba(255,255,255,.12); }
.user-menu { height: 100%; display: flex; align-items: center; gap: 8px; color: #fff; background: transparent; border: 0; padding: 0 20px 0 8px; }
.avatar { width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center; color: var(--navy); background: #dae5f0; font-size: 12px; font-weight: 700; }

.sidebar { position: fixed; inset: 58px auto 0 0; z-index: 20; width: 220px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.sidebar nav { padding: 14px 10px; flex: 1; }
.nav-label { color: #929dab; font-size: 10px; font-weight: 700; letter-spacing: .1em; padding: 18px 12px 6px; }
.nav-item { width: 100%; height: 38px; border: 0; border-radius: 4px; background: transparent; display: flex; align-items: center; gap: 10px; padding: 0 12px; color: #455365; text-align: left; font-weight: 600; }
.nav-item:hover:not(:disabled) { background: #f2f5f8; }
.nav-item.active { background: var(--blue-soft); color: var(--blue); box-shadow: inset 3px 0 0 var(--blue); }
.nav-item:disabled { opacity: .62; }
.nav-icon { width: 18px; text-align: center; color: #6d7c8e; font-size: 15px; }
.nav-item.active .nav-icon { color: var(--blue); }
.sidebar-foot { border-top: 1px solid var(--line); padding: 11px 17px 15px; color: var(--subtle); font-size: 10px; display: flex; flex-direction: column; gap: 2px; }

.main { margin-left: 220px; padding: 58px 0 0; min-height: 100vh; }
.view { padding: 21px 28px 40px; max-width: 1560px; margin: 0 auto; }
.breadcrumb { height: 24px; display: flex; align-items: center; gap: 8px; color: var(--subtle); font-size: 12px; margin-bottom: 7px; }
.breadcrumb strong { color: var(--muted); font-weight: 600; }
.breadcrumb button { border: 0; padding: 0; background: none; color: var(--blue); }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; min-height: 61px; margin-bottom: 17px; }
h1, h2, p { margin-top: 0; }
.page-heading h1 { font-size: 24px; line-height: 1.2; margin-bottom: 5px; letter-spacing: .02em; }
.page-heading p { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.title-row { display: flex; align-items: center; gap: 12px; }
.title-row h1 { margin-bottom: 0; }
.status-tag { border-radius: 3px; padding: 3px 8px; font-size: 11px; font-weight: 700; }
.status-tag.draft { background: #e9edf2; color: #526171; }
.heading-actions { display: flex; gap: 8px; }

.button { min-height: 36px; border-radius: 4px; padding: 0 15px; border: 1px solid transparent; font-weight: 700; font-size: 13px; letter-spacing: .01em; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.button.primary { color: #fff; background: var(--blue); border-color: var(--blue); box-shadow: 0 1px 1px rgba(10,50,100,.15); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { background: #fff; color: var(--blue); border-color: #8eb2d8; }
.button.secondary:hover { background: #f2f7fc; }
.button.ghost { background: #fff; color: #344152; border-color: var(--line-dark); }
.button.ghost:hover { background: #f5f7f9; }
.text-button { border: 0; background: transparent; color: var(--blue); font-weight: 600; padding: 6px 4px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 5px; box-shadow: var(--shadow); }
.filter-panel { margin-bottom: 15px; padding: 17px 18px; }
.filter-grid { display: grid; grid-template-columns: minmax(280px, 1.4fr) 170px 170px 150px auto; align-items: end; gap: 12px; }
.field { display: flex; flex-direction: column; min-width: 0; }
.field > span { color: #3b4858; font-size: 12px; font-weight: 700; margin-bottom: 5px; }
.field.required > span::after { content: "必須"; color: var(--red); font-size: 9px; margin-left: 6px; vertical-align: 1px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line-dark); border-radius: 3px; background: #fff; color: var(--ink); padding: 8px 10px; outline: none; }
.field input, .field select { height: 36px; }
.field textarea { resize: vertical; min-height: 91px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(21,87,160,.12); }
.field input[readonly] { background: #f3f5f7; color: #39485a; }
.field input.invalid, .field select.invalid, .line-table input.invalid { border-color: var(--red); background: #fff9f8; }
.field small { color: var(--subtle); font-size: 10px; margin-top: 4px; line-height: 1.35; }
.field small.confirmed { color: var(--green); font-weight: 600; }
.filter-actions { display: flex; align-items: center; gap: 10px; }

.table-panel { overflow: hidden; }
.panel-head { height: 53px; padding: 0 17px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.panel-head strong { font-size: 14px; }
.count { color: var(--muted); margin-left: 10px; font-size: 12px; }
.table-tools { display: flex; gap: 7px; }
.table-tools .button { min-height: 31px; padding: 0 11px; font-size: 11px; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.data-table th { height: 39px; background: #f7f8fa; color: #566475; border-bottom: 1px solid var(--line); font-size: 11px; text-align: left; padding: 0 13px; white-space: nowrap; }
.data-table td { height: 49px; border-bottom: 1px solid #e7ebef; padding: 0 13px; color: #2f3c4c; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.data-table tbody tr:hover { background: #f7faff; }
.data-table a { color: var(--blue); font-weight: 700; text-decoration: none; }
.data-table .number, .line-table .number { text-align: right; }
.chip { display: inline-flex; align-items: center; min-width: 61px; justify-content: center; border-radius: 12px; padding: 3px 9px; font-size: 10px; font-weight: 700; }
.chip.waiting { color: var(--amber); background: var(--amber-soft); }
.chip.arranged { color: var(--blue); background: var(--blue-soft); }
.chip.shipped { color: var(--green); background: var(--green-soft); }
.table-foot { height: 48px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; color: var(--muted); font-size: 11px; }
.pager { display: flex; gap: 4px; }
.pager button { width: 28px; height: 28px; border: 1px solid var(--line); background: #fff; border-radius: 3px; color: var(--muted); }
.pager .current { background: var(--blue); color: #fff; border-color: var(--blue); }

.entry-heading { align-items: center; }
.form-section { margin-bottom: 15px; padding: 0 19px 20px; }
.section-head { min-height: 66px; margin: 0 -19px 18px; padding: 0 19px; display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.section-number { width: 25px; height: 25px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-2); color: #fff; font-size: 12px; font-weight: 700; }
.section-head h2 { margin: 0 0 2px; font-size: 16px; }
.section-head p { margin: 0; color: var(--muted); font-size: 11px; }
.required-mark { color: var(--red); font-weight: 700; }
.form-grid { display: grid; gap: 15px 18px; }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid.cols-2 { grid-template-columns: minmax(0, 1.4fr) minmax(330px, .6fr); align-items: start; }
.span-2 { grid-column: span 2; }
.input-with-button { display: flex; }
.input-with-button input { border-radius: 3px 0 0 3px; }
.lookup-button { width: 56px; border: 1px solid var(--line-dark); border-left: 0; border-radius: 0 3px 3px 0; background: #eef2f6; color: #39495b; font-size: 11px; font-weight: 700; }
.line-head .add-line { margin-left: auto; min-height: 33px; }
.line-section { padding-bottom: 0; }
.line-table-wrap { overflow-x: auto; margin: 0 -19px; }
.line-table { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 1220px; }
.line-table th { height: 37px; padding: 0 7px; background: #eef2f6; color: #4c5a6a; border: 1px solid #cfd6de; font-size: 10px; text-align: left; white-space: nowrap; }
.line-table th span { color: var(--red); }
.line-table td { padding: 7px; border: 1px solid #d9dfe6; vertical-align: top; background: #fff; }
.line-table input, .line-table select { width: 100%; height: 34px; border: 1px solid #abb6c2; border-radius: 2px; padding: 6px 7px; background: #fff; outline: none; font-size: 12px; }
.line-table input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(21,87,160,.1); }
.line-table input[readonly] { background: #f2f4f6; border-color: #d1d7de; color: #344252; }
.line-table td.line-no { text-align: center; font-weight: 700; color: var(--muted); padding-top: 14px; }
.line-table td.amount-cell { text-align: right; padding-top: 14px; font-weight: 700; }
.col-line { width: 38px; }.col-customer-part { width: 154px; }.col-own-part { width: 118px; }.col-product { width: 260px; }.col-qty { width: 72px; }.col-unit { width: 55px; }.col-price { width: 94px; }.col-date { width: 126px; }.col-amount { width: 108px; }.col-action { width: 40px; }
.remove-line { width: 28px; height: 32px; border: 0; color: #7d8997; background: transparent; font-size: 17px; }
.remove-line:hover { color: var(--red); background: var(--red-soft); }
.line-foot { margin: 0 -19px; padding: 14px 19px 17px; display: flex; justify-content: space-between; align-items: flex-start; background: #fafbfc; border-top: 1px solid var(--line); }
.line-guidance { display: flex; flex-direction: column; color: var(--muted); font-size: 11px; }
.line-guidance strong { color: #3a4757; font-size: 12px; }
.totals { width: 290px; margin: 0; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals dt { color: var(--muted); font-size: 12px; }
.totals dd { margin: 0; font-weight: 700; }
.totals .grand { border-top: 1px solid var(--line-dark); margin-top: 5px; padding-top: 8px; align-items: baseline; }
.totals .grand dt { color: var(--ink); font-weight: 700; }
.totals .grand dd { color: var(--blue-dark); font-size: 20px; }
.document-card { border: 1px solid var(--line); border-radius: 4px; min-height: 91px; padding: 14px; display: flex; justify-content: space-between; align-items: center; background: #f8fafc; }
.document-card > div { display: flex; align-items: center; gap: 11px; min-width: 0; }
.document-card strong, .document-card small { display: block; }
.document-card strong { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-card small { color: var(--muted); margin-top: 3px; font-size: 10px; }
.pdf-badge { width: 34px; height: 40px; display: grid; place-items: center; background: #ca382d; color: white; border-radius: 3px; font-size: 10px; font-weight: 800; }
.document-card button { border: 0; background: transparent; color: var(--blue); font-weight: 700; }
.form-errors { border: 1px solid #e8aba5; background: var(--red-soft); color: #7d261e; border-radius: 4px; padding: 12px 15px; margin: 15px 0; font-size: 12px; }
.form-errors strong { display: block; margin-bottom: 4px; }
.form-errors ul { margin: 0; padding-left: 18px; }
.form-actions { display: flex; justify-content: space-between; padding: 5px 0 25px; }
.form-actions > div { display: flex; gap: 8px; }

.confirm-dialog { width: min(760px, calc(100vw - 80px)); max-height: calc(100vh - 60px); border: 0; border-radius: 6px; padding: 0; box-shadow: 0 25px 80px rgba(13,24,37,.35); color: var(--ink); }
.confirm-dialog::backdrop { background: rgba(11, 19, 30, .58); }
.confirm-dialog form { margin: 0; }
.dialog-head { padding: 21px 24px 17px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-head h2 { margin: 2px 0 0; font-size: 19px; }
.dialog-kicker { color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.dialog-close { border: 0; background: transparent; color: #677586; font-size: 25px; line-height: 1; padding: 0 3px; }
.confirm-body { padding: 18px 24px; overflow: auto; max-height: 58vh; }
.confirm-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.confirm-grid div { border-left: 3px solid #dbe5ef; padding-left: 9px; }
.confirm-grid dt { color: var(--muted); font-size: 10px; }
.confirm-grid dd { margin: 2px 0 0; font-size: 12px; font-weight: 700; }
.confirm-lines { width: 100%; border-collapse: collapse; font-size: 11px; }
.confirm-lines th, .confirm-lines td { border: 1px solid var(--line); padding: 8px; text-align: left; }
.confirm-lines th { background: #f2f5f8; color: var(--muted); }
.confirm-lines .number { text-align: right; }
.confirm-total { text-align: right; margin-top: 13px; font-size: 12px; }
.confirm-total strong { color: var(--blue-dark); font-size: 20px; margin-left: 13px; }
.dialog-note { margin: 0 24px; background: #f0f4f8; border-radius: 4px; padding: 10px 12px; color: #465466; font-size: 11px; }
.dialog-note span { color: var(--muted); }
.dialog-actions { padding: 18px 24px 22px; display: flex; justify-content: flex-end; gap: 8px; }

.success-card { max-width: 880px; margin: 50px auto 0; padding: 43px 52px; text-align: center; }
.success-icon { width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 50%; background: var(--green-soft); color: var(--green); display: grid; place-items: center; font-size: 28px; font-weight: 800; }
.success-card .eyebrow { margin: 0; color: var(--green); font-weight: 800; font-size: 12px; }
.success-card h1 { margin: 7px 0 9px; font-size: 25px; }
.success-card > p:not(.eyebrow) { color: var(--muted); }
.success-summary { display: grid; grid-template-columns: repeat(4, 1fr); margin: 28px 0; border: 1px solid var(--line); border-radius: 4px; text-align: left; }
.success-summary div { padding: 14px 16px; border-right: 1px solid var(--line); }
.success-summary div:last-child { border-right: 0; }
.success-summary dt { color: var(--muted); font-size: 10px; }
.success-summary dd { margin: 4px 0 0; font-size: 13px; font-weight: 700; }
.success-actions { display: flex; justify-content: center; gap: 8px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 80; color: #fff; background: #213145; border-radius: 4px; padding: 12px 17px; box-shadow: 0 8px 30px rgba(0,0,0,.24); font-size: 12px; font-weight: 600; }

@media (max-width: 1240px) {
  .view { padding-left: 20px; padding-right: 20px; }
  .filter-grid { grid-template-columns: minmax(230px, 1fr) 155px 155px 130px auto; }
  .form-grid.cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid.cols-4 .span-2 { grid-column: span 2; }
}

/* 左にChatGPT、右に受注システムを並べる録画専用表示 */
body.recording-mode .topbar { grid-template-columns: 72px 1fr auto; }
body.recording-mode .brand { justify-content: center; padding: 0; }
body.recording-mode .brand div { display: none; }
body.recording-mode .topbar-center { padding-left: 14px; gap: 10px; }
body.recording-mode .sidebar { width: 72px; }
body.recording-mode .sidebar nav { padding: 12px 8px; }
body.recording-mode .nav-label,
body.recording-mode .sidebar-foot { display: none; }
body.recording-mode .nav-item { justify-content: center; padding: 0; font-size: 0; margin-bottom: 5px; }
body.recording-mode .nav-icon { width: auto; font-size: 15px; }
body.recording-mode .main { margin-left: 72px; }
body.recording-mode .view { padding-left: 18px; padding-right: 18px; }
body.recording-mode .line-table { min-width: 1000px; }
body.recording-mode .col-line { width: 34px; }
body.recording-mode .col-customer-part { width: 137px; }
body.recording-mode .col-own-part { width: 108px; }
body.recording-mode .col-product { width: 210px; }
body.recording-mode .col-qty { width: 62px; }
body.recording-mode .col-unit { width: 48px; }
body.recording-mode .col-price { width: 82px; }
body.recording-mode .col-date { width: 112px; }
body.recording-mode .col-amount { width: 94px; }
body.recording-mode .col-action { width: 36px; }
body.recording-mode .line-table th,
body.recording-mode .line-table td { padding-left: 5px; padding-right: 5px; }

@media (max-width: 1260px) {
  body.recording-mode .division { display: none; }
  body.recording-mode .user-menu { padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
