:root {
  color-scheme: light;
  font-family: "Yu Gothic UI", "Hiragino Sans", sans-serif;
  color: #17211d;
  background: #f5f7f6;
  --green: #176b50;
  --green-dark: #0d4f3a;
  --line: #dfe6e2;
  --muted: #63706a;
}
[hidden] { display: none !important; }

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; overflow-x: hidden; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }

.site-header {
  min-height: 68px;
  padding: 0 5vw;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand { font-weight: 750; text-decoration: none; letter-spacing: .02em; }
.account-area { display: flex; align-items: center; gap: 18px; color: var(--muted); }
.account-area form { margin: 0; }
.text-button { border: 0; background: transparent; color: var(--green); cursor: pointer; padding: 8px 0; }

.main-nav {
  padding: 0 5vw;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 28px;
  overflow-x: auto;
}
.main-nav a { padding: 14px 0; text-decoration: none; white-space: nowrap; }

.page-shell { width: min(1180px, 90vw); margin: 48px auto 96px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
h1 { margin: 4px 0 0; font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -.03em; }
h2 { margin-top: 0; font-size: 1.2rem; }
.eyebrow { margin: 0; color: var(--green); font-size: .78rem; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.muted { color: var(--muted); line-height: 1.75; }

.auth-card, .content-card, .empty-state {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 16px 40px rgba(21, 44, 34, .05);
}
.auth-card { width: min(480px, 100%); margin: 8vh auto; padding: clamp(28px, 6vw, 52px); }

/* ログイン画面だけに適用。名刺一覧・管理画面のレイアウトは変更しない。 */
.login-page {
  background: radial-gradient(ellipse at 8% 0%, #e6f0eb 0, transparent 52%),
              radial-gradient(ellipse at 100% 100%, #edf3ef 0, transparent 48%), #f5f7f6;
}
.login-page > .site-header, .login-page > .main-nav { display: none; }
.login-page .page-shell {
  width: 100%; min-height: 100vh; min-height: 100svh; margin: 0;
  padding: 56px 24px 32px; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.login-page .login-card {
  width: min(460px, 100%); margin: 0; padding: 44px 40px 36px;
  border-radius: 24px; text-align: center;
  box-shadow: 0 20px 64px rgba(23, 61, 43, .07), 0 2px 8px rgba(23, 61, 43, .025);
}
.login-mark {
  display: grid; place-items: center; width: 60px; height: 60px;
  margin: 0 auto 24px; border-radius: 18px; color: #fff; background: #176b50;
  box-shadow: 0 8px 20px rgba(23, 107, 80, .16);
}
.login-page .login-eyebrow { font-size: .64rem; letter-spacing: .14em; color: #527261; }
.login-page h1 { margin-top: 10px; font-size: clamp(1.6rem, 5.5vw, 2rem); letter-spacing: .02em; }
.login-intro { margin: 20px 0 28px; line-height: 1.85; color: #56665d; font-size: .95rem; }
.google-signin-button {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; min-height: 52px; padding: 12px; border: 1px solid #747775;
  border-radius: 28px; background: #fff; color: #1f1f1f; text-decoration: none;
  font-family: "Google Sans", Arial, "Yu Gothic UI", sans-serif;
  font-size: 14px; font-weight: 500; transition: background .15s, box-shadow .15s;
}
.google-signin-button img { width: 20px; height: auto; flex: none; }
.google-signin-button:hover { background: #f8faf9; box-shadow: 0 3px 12px rgba(23, 61, 43, .08); }
.google-signin-button:focus-visible { outline: 3px solid #176b50; outline-offset: 4px; }
.login-retention-note { margin: 16px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.8; }
.login-first-time { margin: 18px 0 28px; color: #63706a; font-size: .8rem; line-height: 1.8; }
.login-account-note { border-top: 1px solid #e5ebe7; padding-top: 24px; }
.login-domain-label { display: block; color: #63706a; font-size: .72rem; letter-spacing: .04em; }
.login-account-note strong { display: block; margin-top: 7px; color: #176b50; font-size: .95rem; }
.login-account-note p { margin: 10px 0 0; color: #63706a; font-size: .72rem; line-height: 1.8; }
.login-footer { margin: 24px 0 0; color: #63706a; font-size: .72rem; letter-spacing: .06em; }
.login-error { margin: -4px 0 24px; text-align: left; font-size: .84rem; overflow-wrap: anywhere; }
.login-error strong { display: block; font-size: .85rem; }
.login-error p { margin: 6px 0 0; }
.login-page .stack-form { text-align: left; }
.login-migration-heading { margin: 28px 0 0; font-size: .95rem; }
@media (max-width: 480px) {
  .login-page .page-shell { padding: 28px 16px 24px; }
  .login-page .login-card { padding: 32px 24px 28px; border-radius: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .google-signin-button { transition: none; }
}
.content-card { padding: clamp(24px, 4vw, 36px); }
.content-card.narrow { width: min(560px, 100%); margin: 0 auto; }
.empty-state { text-align: center; padding: 72px 24px; color: var(--muted); }
.empty-state h2 { color: #27342e; }

.stack-form { display: grid; gap: 20px; margin-top: 28px; }
.form-field { display: grid; gap: 8px; }
label { display: grid; gap: 8px; font-weight: 650; }
input {
  width: 100%;
  border: 1px solid #cbd6d0;
  border-radius: 10px;
  background: #fff;
  padding: 13px 14px;
}
input:focus { outline: 3px solid rgba(23, 107, 80, .16); border-color: var(--green); }

button { border-radius: 10px; border: 1px solid #bcc9c3; padding: 11px 16px; cursor: pointer; }
.primary-button { border-color: var(--green); background: var(--green); color: #fff; font-weight: 700; }
.primary-button:hover { background: var(--green-dark); }
.primary-button:disabled { opacity: .45; cursor: not-allowed; }
.danger-button { border-color: #bd4c4c; background: #fff; color: #9d2828; }
.secondary-button { border: 1px solid var(--green); background: #fff; color: var(--green-dark); font-weight: 700; }
.button-link { display: inline-flex; justify-content: center; align-items: center; text-decoration: none; border-radius: 10px; padding: 11px 16px; }
.quiet-link { color: var(--green-dark); text-underline-offset: 4px; }

.message { border-radius: 10px; padding: 13px 15px; line-height: 1.5; }
.message.error { background: #fff1f1; border: 1px solid #efc8c8; color: #8c2222; }
.message.success { background: #edf8f2; border: 1px solid #c4e5d2; color: #155c43; }
.message.warning { background: #fff8e6; border: 1px solid #eed48f; color: #674b09; }
.duplicate-changes { margin: 10px 0; padding-left: 24px; line-height: 1.7; }
.duplicate-changes li { overflow-wrap: anywhere; }
.admin-grid { display: grid; grid-template-columns: minmax(300px, .8fr) minmax(420px, 1.2fr); gap: 24px; }
.user-list { display: grid; gap: 0; }
.user-row { display: grid; grid-template-columns: 1fr auto; gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row div { display: grid; gap: 4px; }
.user-row span { color: var(--muted); font-size: .9rem; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: .84rem; }

.search-panel { display: grid; grid-template-columns: 1fr 1fr 1.4fr auto; gap: 14px; align-items: end; margin-bottom: 28px; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.search-toggle { display: none; }
.section-tabs { display: flex; gap: 8px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.section-tabs a { padding: 12px 18px; border-bottom: 3px solid transparent; color: var(--muted); text-decoration: none; font-weight: 700; }
.section-tabs a.is-active { border-color: var(--green); color: var(--green-dark); }
.view-toggle { display: flex; align-items: center; gap: 6px; margin: 16px 0; }
.view-toggle > span { margin-right: 4px; color: var(--muted); font-size: .86rem; }
.view-toggle a { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; text-decoration: none; font-size: .88rem; font-weight: 700; }
.view-toggle a.is-active { border-color: var(--green); color: #fff; background: var(--green); }
.privacy-badge { justify-self: start; padding: 3px 8px; border-radius: 999px; background: #fff1dc; color: #714b0b !important; font-weight: 700; }
.company-folders { display: grid; gap: 16px; }
.company-folder { overflow: visible; background: #fff; border: 1px solid var(--line); border-radius: 16px; }
.company-folder > summary { display: flex; align-items: center; gap: 12px; padding: 18px 20px; cursor: pointer; list-style: none; }
.company-folder > summary::-webkit-details-marker { display: none; }
.company-folder > summary strong { flex: 1; }
.company-folder > summary > span:last-child { color: var(--muted); font-size: .86rem; }
.company-folder[open] > summary { border-bottom: 1px solid var(--line); }
.company-folder[open] { height: auto; }
.company-folder .card-grid { padding: 14px; }
.card-grid { display: grid; gap: 14px; }
.company-folder .selectable-card-row, .company-folder .business-card-row { width: 100%; min-width: 0; max-width: 100%; }
.business-card-row { display: grid; grid-template-columns: 180px 1fr; gap: 22px; padding: 18px; color: inherit; text-decoration: none; background: #fff; border: 1px solid var(--line); border-radius: 16px; transition: border-color .15s, transform .15s; }
.business-card-row:hover { border-color: #8eb9a7; transform: translateY(-1px); }
.thumbnail-cell { width: 180px; height: 109px; display: grid; place-items: center; }
.thumbnail-cell.is-portrait { width: 109px; height: 180px; justify-self: center; }
.thumbnail-wrap { position: relative; width: 100%; aspect-ratio: 1.65; display: grid; place-items: center; overflow: hidden; border-radius: 9px; background: #eef2f0; color: var(--muted); font-size: .8rem; }
.thumbnail-wrap.is-portrait { width: auto; height: 100%; aspect-ratio: .606; }
.thumbnail-wrap img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.business-card-copy { display: grid; align-content: center; gap: 5px; }
.business-card-copy strong { font-size: 1.25rem; }
.business-card-copy span { color: var(--muted); }
.business-card-copy .company-name { color: #27342e; font-weight: 700; }
.business-card-copy small { color: var(--muted); font-size: .76rem; }
.card-dates { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 20px; margin-top: 26px; }
.pagination a { color: var(--green); }
.selectable-card-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; align-items: center; }
.card-select { display: none; place-items: center; padding: 12px 4px; }
.company-folders.is-selecting .card-select { display: grid; }
.company-folders.is-selecting .selectable-card-row { grid-template-columns: auto minmax(0, 1fr); }
.share-selection-help { margin-bottom: 14px; }
.card-select input, .choice-row input { width: 20px; height: 20px; }
.share-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.share-layout .share-actions { grid-column: 1 / -1; }
.choice-list { display: grid; gap: 0; }
.choice-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; align-items: center; padding: 14px 2px; border-bottom: 1px solid var(--line); }
.choice-row:last-child { border-bottom: 0; }
.choice-row span { display: grid; gap: 3px; }
.choice-row small { color: var(--muted); font-weight: 400; }
.narrow-company-card { width: min(760px, 100%); }
.compact-card-list { display: grid; }
.compact-card-list a { display: flex; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.compact-card-list span { color: var(--muted); }

.org-create-card { margin-bottom: 20px; }
.org-create-card .inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.org-create-card .inline-form select { min-width: 0; }
.org-chart-list { display: grid; gap: 16px; }
.org-chart-card { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.org-chart-card p { margin: 0; }
.org-editor-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); grid-template-areas: "toolbar toolbar" "sidebar canvas"; gap: 18px; align-items: start; }
.org-editor-shell > .org-toolbar { grid-area: toolbar; width: auto; }
.org-employee-sidebar { grid-area: sidebar; position: sticky; top: 24px; margin-top: 12px; padding: 20px; max-height: calc(100vh - 52px); overflow: auto; }
.org-employee-sidebar .muted { margin-top: -8px; font-size: .82rem; }
.org-employee-list { display: grid; gap: 8px; }
.org-employee-card { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 9px; width: 100%; padding: 11px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.org-employee-card:hover { border-color: var(--green); }
.org-employee-card:has(input:checked) { border-color: var(--green); background: #edf8f2; }
.org-employee-card input { width: 19px; height: 19px; margin-top: 2px; }
.org-employee-card span { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.org-employee-card small { color: var(--muted); font-size: .76rem; font-weight: 400; }
.org-build-button { width: 100%; margin-top: 12px; }
.org-manual-person { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.org-manual-person summary { cursor: pointer; color: var(--green-dark); font-weight: 700; }
.manual-person-form { display: grid; gap: 8px; margin-top: 12px; }
.org-editor-main { grid-area: canvas; min-width: 0; }
.org-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; overflow: visible; padding: 10px; margin-bottom: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.org-toolbar button { flex: 0 0 auto; min-width: max-content; padding: 9px 12px; background: #fff; }
.org-toolbar button.is-active { border-color: var(--green); background: var(--green); color: #fff; }
.org-toolbar-spacer { flex: 1 1 auto; }
.org-toolbar-field { display: flex; grid: none; flex: 0 0 auto; align-items: center; gap: 6px; white-space: nowrap; font-size: .82rem; }
.org-toolbar-field input[type="color"] { width: 38px; height: 36px; padding: 2px; }
.org-toolbar-field select { width: auto; min-width: 66px; padding: 8px; }
.org-tool-status { min-height: 24px; margin: 0 0 8px; color: var(--muted); font-size: .84rem; }
.org-view-toolbar { margin-left: auto; width: max-content; max-width: 100%; }
.org-chart-viewport { position: relative; height: min(72vh, 720px); min-height: 520px; padding: 0; overflow: auto; touch-action: none; background-image: radial-gradient(#d8e1dc 1px, transparent 1px); background-size: 20px 20px; }
.org-chart-viewport.is-pannable { cursor: grab; touch-action: none; user-select: none; }
.org-chart-viewport.is-panning { cursor: grabbing; }
.org-chart-viewport.is-right-pannable.is-panning { cursor: grabbing; user-select: none; }
.org-stage-shell { position: relative; overflow: visible; }
.org-stage { position: relative; transform-origin: 0 0; }
.org-print-page { display: none; }
.org-canvas { position: relative; pointer-events: none; }
.org-department-frames { position: absolute; inset: 0; z-index: 1; pointer-events: auto; }
.org-department-frame { position: absolute; padding: 14px 12px; border: 2px solid var(--frame-color, #9ab9aa); border-radius: 18px; background: rgba(237, 248, 242, .28); pointer-events: auto; box-sizing: border-box; }
.org-department-frame.is-selected { outline: 3px solid rgba(23,107,80,.35); outline-offset: 3px; }
.org-department-frame-header { position: absolute; z-index: 4; top: -16px; left: 14px; display: flex; align-items: center; gap: 3px; pointer-events: auto; }
.org-department-frame-header strong { position: static; padding: 2px 10px; border: 1px solid var(--frame-color, #9ab9aa); border-radius: 999px; background: #fff; color: var(--green-dark); font-size: .82rem; cursor: grab; }
.org-frame-remove { width: 22px; height: 22px; padding: 0; border: 1px solid var(--frame-color, #9ab9aa); border-radius: 50%; background: #fff; color: #8c2222; cursor: pointer; line-height: 1; opacity: 0; visibility: hidden; }
.org-department-frame.is-selected .org-frame-remove { opacity: 1; visibility: visible; }
.org-frame-resize-handle { position: absolute; z-index: 4; width: 12px; height: 12px; padding: 0; border: 2px solid var(--frame-color, #9ab9aa); border-radius: 3px; background: transparent; color: transparent; cursor: nwse-resize; opacity: 0; visibility: hidden; pointer-events: auto; touch-action: none; }
.org-department-frame.is-selected .org-frame-resize-handle { opacity: 1; visibility: visible; }
.org-frame-resize-handle--nw { left: -6px; top: -6px; cursor: nwse-resize; }
.org-frame-resize-handle--ne { right: -6px; top: -6px; cursor: nesw-resize; }
.org-frame-resize-handle--sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.org-frame-resize-handle--se { right: -6px; bottom: -6px; cursor: nwse-resize; }
.org-lines { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: visible; }
.org-line { stroke: #65736c; stroke-width: 2.5; }
.org-line.hierarchy { stroke: var(--green-dark); stroke-width: 3; }
.org-line.auxiliary { stroke: #9a7d37; stroke-dasharray: 8 6; }
.org-person { position: absolute; z-index: 1; display: grid; gap: 7px; width: 230px; min-height: 120px; padding: 15px; border: 1px solid #c9d5cf; border-top: 7px solid var(--person-color, var(--green)); border-radius: 12px; background: #fff; box-shadow: 0 8px 22px rgba(21,44,34,.12); overflow-wrap: anywhere; pointer-events: auto; }
.org-person-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.org-person-heading > strong { min-width: 0; overflow-wrap: anywhere; }
.org-person-tags { display: flex; flex: 0 0 auto; flex-wrap: wrap; justify-content: flex-end; gap: 3px; }
.org-person-tag { padding: 2px 5px; border-radius: 999px; background: #e8efeb; color: #234c3c; font-size: .65rem; font-weight: 700; line-height: 1.25; white-space: nowrap; }
.org-person-tag[data-tag="決裁者"] { background: #f7e4d8; color: #8a3b1e; }
.org-person-tag[data-tag="キーマン"] { background: #dceee4; color: #176b50; }
.org-person-tag[data-tag="影響力あり"] { background: #e5e0f6; color: #553b92; }
.org-person-tag[data-tag="現場担当"] { background: #dfeaf7; color: #1d5488; }
.org-person-tag[data-tag="要注意"] { background: #f8dede; color: #9d2828; }
.org-person.is-editable { cursor: grab; touch-action: none; }
.org-person.is-dragging { cursor: grabbing; box-shadow: 0 14px 34px rgba(21,44,34,.22); }
.org-person.is-selected, .org-person.is-pair-selected, .org-text-item.is-selected { outline: 3px solid rgba(23,107,80,.35); outline-offset: 3px; }
.org-person > span { color: var(--muted); font-size: .84rem; }
.org-person .org-person-role { color: #27342e; font-weight: 700; }
.org-canvas { z-index: 2; }
.org-text-item { position: absolute; z-index: 3; min-width: 120px; max-width: 520px; pointer-events: auto; }
.org-text-content { min-width: 120px; padding: 5px 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.org-text-content[contenteditable="true"]:focus { outline: 2px solid var(--green); background: rgba(255,255,255,.9); }
.org-text-handle { display: block; margin-bottom: 2px; padding: 3px 7px; border: 0; background: #e8efeb; color: var(--muted); font-size: .66rem; cursor: move; touch-action: none; }
.form-actions.org-form-actions { position: static; bottom: auto; margin-top: 12px; }
.org-person-note-popover { position: absolute; z-index: 4; display: grid; gap: 14px; width: 290px; padding: 16px; border: 1px solid #b8cbc1; border-radius: 12px; background: rgba(255,255,255,.98); box-shadow: 0 12px 28px rgba(21,44,34,.18); }
.org-person-note-popover h2 { margin: 0; font-size: 1rem; }
.org-person-note-popover p { margin: 0; }
.org-tag-choices { display: flex; flex-wrap: wrap; gap: 10px 14px; }
.org-tag-choices label { display: flex; align-items: center; gap: 5px; margin: 0; font-size: .9rem; }
.org-tag-choices input { width: auto; }

.card-edit-form { display: grid; gap: 20px; }
.form-section { box-shadow: none; }
.form-grid { display: grid; gap: 18px; }
.form-grid.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
select, textarea { width: 100%; border: 1px solid #cbd6d0; border-radius: 10px; background: #fff; padding: 13px 14px; }
select:focus, textarea:focus { outline: 3px solid rgba(23, 107, 80, .16); border-color: var(--green); }
.required { color: #9d2828; font-size: .76rem; }
.contact-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.address-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.address-add-button { justify-self: start; align-self: end; }
fieldset { display: grid; gap: 9px; margin: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
legend { padding: 0 6px; font-weight: 700; }
.checkbox-label { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-weight: 500; }
.checkbox-label input { width: auto; }
.company-common-info { border: 1px solid #d5e1db; background: #fbfdfc; }
.company-ocr-differences { margin-top: 14px; }
.company-ocr-differences ul { display: grid; gap: 9px; padding-left: 0; list-style: none; }
.company-ocr-differences li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.company-candidate-button { flex: 0 0 auto; margin: 0; padding: 7px 10px; font-size: .85rem; }
.current-images { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 18px 0; }
.current-images figure { margin: 0; }
.orientation-preview img,
.orientation-preview canvas { display: block; width: 100%; max-height: 68vh; object-fit: contain; border-radius: 10px; }
.orientation-preview [hidden] { display: none; }
.image-orientation-form { margin-top: 16px; }
.orientation-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.orientation-actions button { min-height: 44px; }
.orientation-hint, .orientation-status { font-size: .85rem; line-height: 1.65; }
.oriented-card-image + .oriented-card-image { margin-top: 28px; }
.current-images img { display: block; width: 100%; max-height: 68vh; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); }
.image-gallery figure { width: min(66.667%, 640px); min-width: 0; margin: 0 auto; }
.image-gallery img { display: block; width: 100%; max-width: 100%; max-height: 68vh; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); }
figcaption { margin-bottom: 8px; color: var(--muted); font-size: .85rem; }
.form-actions { display: flex; justify-content: flex-end; align-items: center; gap: 20px; position: sticky; bottom: 18px; padding: 16px 20px; background: rgba(255,255,255,.96); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 12px 32px rgba(21,44,34,.12); }

.heading-actions { display: flex; align-items: center; gap: 16px; }
.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 1fr); gap: 24px; align-items: start; }
.detail-layout > * { min-width: 0; }
.image-gallery { display: grid; gap: 24px; }
.image-gallery { grid-column: 1; grid-row: 1; }
.card-data-panel { grid-column: 2; grid-row: 1 / span 2; }
.company-memo-inline { grid-column: 1; grid-row: 2; }
.company-memo-inline .stack-form { margin-top: 16px; }
.company-memo-inline textarea { width: 100%; max-width: 100%; min-height: 150px; resize: none; overflow-y: hidden; }
.detail-list { margin: 0; }
.detail-list > div { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.detail-list dt { color: var(--muted); }
.detail-list dd { min-width: 0; margin: 0; overflow-wrap: anywhere; word-break: break-word; }
.detail-list dd a { overflow-wrap: anywhere; word-break: normal; }
.detail-list small { display: block; margin-top: 3px; color: var(--muted); }
.detail-label { display: grid; align-content: start; }
.detail-label small { margin-top: 2px; }
.contact-link { color: #1261a0; text-decoration: underline; text-underline-offset: 3px; overflow-wrap: anywhere; word-break: break-word; user-select: all; }
.password-field { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.password-toggle { min-width: 72px; background: #fff; color: var(--green-dark); }
.preserve-lines { white-space: pre-wrap; }
.history-section { margin-top: 24px; }
.history-list article { padding: 18px 0; border-bottom: 1px solid var(--line); }
.history-list article:last-child { border-bottom: 0; }
.history-list article > div { display: flex; justify-content: space-between; gap: 16px; }
.history-list time { color: var(--muted); font-size: .9rem; }
.history-list ul, .history-list p { margin-bottom: 0; color: var(--muted); line-height: 1.7; }
.danger-zone { margin-top: 36px; padding: 24px; border: 1px solid #efc8c8; border-radius: 14px; background: #fffafa; }
.danger-zone h2 { color: #8c2222; }
.capture-app { display: grid; gap: 16px; }
.orientation-picker { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.orientation-picker > div { display: flex; gap: 8px; }
.orientation-button { min-width: 82px; background: #fff; color: var(--green-dark); }
.orientation-button.is-selected { border-color: var(--green); background: var(--green); color: #fff; font-weight: 700; }
.camera-stage { position: relative; height: min(58vh, 520px); min-height: 300px; overflow: hidden; display: grid; place-items: center; background: #17211d; border-radius: 16px; }
.camera-stage video { width: 100%; height: 100%; object-fit: cover; }
.camera-placeholder { position: absolute; z-index: 2; color: #fff; text-align: center; padding: 24px; }
.capture-guide { position: absolute; z-index: 1; border: 3px solid rgba(255,255,255,.95); border-radius: 8px; box-shadow: 0 0 0 999px rgba(0,0,0,.2); pointer-events: none; }
.capture-guide.is-landscape { width: 92%; max-height: 88%; aspect-ratio: 1.65; }
.capture-guide.is-portrait { height: 88%; max-width: 82%; aspect-ratio: .606; }
.capture-status { display: flex; justify-content: space-between; gap: 20px; }
.capture-status span { color: var(--muted); }
.capture-controls { display: grid; gap: 12px; }
.back-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.shutter-button { width: 76px; height: 76px; margin: 0 auto; padding: 0; border: 8px solid #fff; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 2px var(--green); color: transparent; }
.capture-list { margin: 0; padding-left: 24px; color: var(--muted); line-height: 1.8; }
.additional-fields { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.additional-fields summary { cursor: pointer; color: var(--green); font-weight: 700; }
.additional-fields[open] summary { margin-bottom: 12px; }
.additional-fields input + input { margin-top: 8px; }
.processing-card { width: min(560px, 100%); margin: 10vh auto; text-align: center; }
.spinner { width: 48px; height: 48px; margin: 0 auto 24px; border: 5px solid #dfe6e2; border-top-color: var(--green); border-radius: 50%; animation: spin .9s linear infinite; }
.ocr-text { overflow-x: auto; padding: 16px; border-radius: 10px; background: #f5f7f6; white-space: pre-wrap; line-height: 1.7; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 761px) {
  .company-folder .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; }
  .company-folder .selectable-card-row { min-width: 0; height: 286px; }
  .company-folder .business-card-row { grid-template-columns: 1fr; grid-template-rows: 150px minmax(0, 1fr); width: 100%; height: 286px; gap: 12px; }
  .company-folder .thumbnail-cell, .company-folder .thumbnail-cell.is-portrait { width: 100%; height: 150px; }
  .company-folder .thumbnail-wrap, .company-folder .thumbnail-wrap.is-portrait { width: 100%; height: 150px; aspect-ratio: auto; }
  .company-folder .business-card-copy { align-content: start; min-width: 0; }
  .company-folder .business-card-copy strong, .company-folder .business-card-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 760px) {
  .site-header { padding: 0 20px; }
  .account-area > span { display: none; }
  .main-nav {
    position: fixed;
    z-index: 10;
    left: 0;
    right: 0;
    bottom: 0;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    justify-content: space-around;
    padding: 0 12px;
  }
  .main-nav a { padding: 16px 8px; font-size: .9rem; }
  .page-shell { width: calc(100% - 32px); margin-top: 32px; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .admin-grid { grid-template-columns: 1fr; }
  .search-toggle { display: inline-flex; align-items: center; gap: 9px; margin-bottom: 14px; background: #fff; color: var(--green-dark); font-weight: 700; }
  .search-toggle::before { content: ""; width: 13px; height: 13px; border: 2px solid currentColor; border-radius: 50%; box-shadow: 7px 7px 0 -5px currentColor; }
  .search-panel { display: none; }
  .search-panel.is-open { display: grid; grid-template-columns: 1fr; }
  .form-grid.two-columns, .contact-grid, .address-list, .detail-layout, .share-layout, .org-editor-tools { grid-template-columns: 1fr; }
  .share-layout .share-actions { grid-column: auto; }
  .manual-person-form { grid-template-columns: 1fr; }
  .org-chart-card { align-items: stretch; flex-direction: column; }
  .org-editor-shell { grid-template-columns: minmax(0, 1fr); grid-template-areas: "toolbar" "sidebar" "canvas"; }
  .org-employee-sidebar { position: static; max-height: none; }
  .org-employee-list { display: flex; overflow-x: auto; }
  .org-employee-card { flex: 0 0 190px; }
  .org-toolbar { padding: 8px; }
  .org-chart-viewport { height: 62vh; min-height: 420px; }
  .company-folder > summary { padding: 16px; }
  .company-folder .card-grid { grid-template-columns: minmax(0, 1fr); padding: 10px; }
  .company-folder .business-card-row { grid-template-columns: 110px minmax(0, 1fr); gap: 14px; padding: 12px; overflow: hidden; }
  .thumbnail-cell { width: 110px; height: 67px; }
  .thumbnail-cell.is-portrait { width: 67px; height: 110px; }
  .current-images { grid-template-columns: 1fr; }
  .image-gallery { padding: 16px; }
  .image-gallery figure { width: min(82%, 280px); }
  .image-gallery img, .image-gallery canvas { max-height: 38vh; }
  .image-gallery, .card-data-panel, .company-memo-inline { grid-column: 1; grid-row: auto; }
  .detail-list > div { grid-template-columns: 92px minmax(0, 1fr); gap: 12px; }
  .heading-actions { align-items: stretch; flex-direction: column; }
  .org-chart-actions, .org-view-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .org-chart-actions .button-link, .org-view-actions .button-link { min-width: 0; padding-inline: 9px; white-space: nowrap; }
  .org-view-actions .quiet-link { grid-column: 1 / -1; text-align: center; padding-top: 5px; }
  .form-actions { bottom: 72px; justify-content: space-between; }
  .user-row { grid-template-columns: 1fr; }
  .inline-form { flex-direction: column; }
  .org-create-card .inline-form { grid-template-columns: 1fr; }
  .capture-app { padding: 14px; gap: 13px; }
  .orientation-picker { gap: 10px; }
  .orientation-picker > strong { font-size: .9rem; }
  .orientation-button { min-width: 72px; padding: 9px 12px; }
  .camera-stage { height: min(46vh, 360px); min-height: 220px; }
  .back-choice { grid-template-columns: 1fr; }
  .activity-card { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
  .activity-card .table-wrap { overflow: visible; }
  .activity-table, .activity-table tbody { display: block; width: 100%; }
  .activity-table thead { display: none; }
  .activity-table tr { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5px 12px; padding: 13px 2px; border-bottom: 1px solid var(--line); }
  .activity-table td { display: block; min-width: 0; padding: 0; border: 0; overflow-wrap: anywhere; }
  .activity-date { color: var(--muted); font-size: .78rem; white-space: nowrap; }
  .activity-actor { font-size: .84rem; }
  .activity-summary { grid-column: 1 / -1; line-height: 1.55; }
}

@media print {
  @page { size: A4 landscape; margin: 5mm; }
  html, body { width: auto !important; height: auto !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; overflow: hidden !important; background: #fff; }
  body > *:not(.org-print-page) { display: none !important; }
  .org-print-page { display: block !important; position: relative; width: 286mm; height: 199mm; margin: 0; overflow: hidden; background: #fff; break-inside: avoid; page-break-inside: avoid; break-after: avoid; page-break-after: avoid; }
  .org-print-stage { position: absolute !important; margin: 0; transform-origin: 0 0 !important; }
  .org-print-stage .org-department-frame { background: transparent !important; }
  .org-print-stage, .org-print-stage * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Tablet camera: large preview with reachable controls in landscape orientation. */
.capture-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.capture-panel { display: grid; align-content: start; gap: 16px; }
.capture-back-option { display: flex; align-items: center; gap: 8px; }
.capture-back-option input { width: auto; }
.quick-grid { margin-top: 20px; }
.quick-grid label { display: grid; gap: 6px; }
.quick-grid input[type="checkbox"] { width: auto; }
#quick-batch-form { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin: 20px 0; }
#quick-batch-form label { display: flex; gap: 8px; align-items: center; }
#quick-batch-form input { width: auto; }
@media (min-width: 760px) and (orientation: landscape) {
  .capture-layout { grid-template-columns: minmax(0, 1fr) 245px; align-items: start; }
  .capture-layout .camera-stage { height: min(65vh, 650px); }
  .capture-panel .orientation-picker { flex-wrap: wrap; }
}

@media (min-width: 760px) and (orientation: landscape) {
  .capture-page .page-shell { margin: 12px auto 40px; }
  .capture-page .capture-app { padding: 18px 22px; gap: 10px; }
  .capture-page .capture-app h1 { margin: 0; font-size: 1.55rem; }
  .capture-page .capture-app > p { margin: 0; font-size: .9rem; }
  .capture-page .capture-layout .camera-stage { height: min(55vh, 440px); }
  .capture-page .capture-guide.is-landscape { width: min(92%, 80vh); }
  .capture-page .capture-panel { gap: 10px; }
  .capture-page .capture-tip { margin: 0; font-size: .82rem; }
}

/* Visible only to administrators; shared controls keep their normal colours. */
.admin-only, .admin-only .muted, .admin-only .secondary-button { color: #1d4ed8; }
