/* ObyDesign Office 共通 UI */
:root {
  --paper: #FAF7F2; --surface: #FFFFFF; --ink: #1F2A2E; --muted: #5B6468; --rule: #DDD6CB;
  --nest: #1F6F5C; --z: #B4532A; --accent: #1F6F5C; --danger: #B3261E; --ok: #1F6F5C;
  --focus: #1F6F5C;
}
.app-meishi { --accent: #B4532A; }
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif; font-size: 15px; line-height: 1.7; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .6em; line-height: 1.4; }
h2 { font-size: 1.15rem; margin: 1.6em 0 .6em; }
h3 { font-size: 1rem; margin: 1.2em 0 .4em; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
small, .small { font-size: .85em; color: var(--muted); }

.top { background: var(--ink); color: #fff; }
.top-inner { max-width: 1180px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; min-height: 52px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand span { font-weight: 400; opacity: .8; }
.apps { display: flex; gap: 4px; }
.apps a { color: #fff; text-decoration: none; padding: 6px 12px; border-radius: 6px; opacity: .8; }
.apps a[aria-current="page"] { background: rgba(255,255,255,.14); opacity: 1; font-weight: 700; }
.user { margin-left: auto; font-size: .9rem; }
.user a { color: #fff; opacity: .8; margin-left: 10px; }
.sub { background: var(--surface); border-bottom: 1px solid var(--rule); }
.sub .top-inner { min-height: 44px; gap: 4px; }
.sub a { color: var(--ink); text-decoration: none; padding: 10px 12px; border-bottom: 3px solid transparent; white-space: nowrap; }
.sub a[aria-current="page"] { border-bottom-color: var(--accent); font-weight: 700; }
.main-inner { max-width: 1180px; margin: 0 auto; padding: 24px 16px 64px; }
.foot { border-top: 1px solid var(--rule); color: var(--muted); font-size: .85rem; }
.foot .top-inner { min-height: 48px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h1 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer; font-family: inherit; }
.btn:hover { filter: brightness(1.08); }
.btn-sub { background: var(--surface); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: .85rem; }
.btn-x { border: 0; background: transparent; color: var(--muted); font-size: 1.2rem; cursor: pointer; padding: 0 6px; line-height: 1; }
.btn-x:hover { color: var(--danger); }

.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.grid { display: grid; gap: 16px; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 16px 20px; }
.stat .label { color: var(--muted); font-size: .85rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; }

.alert { padding: 12px 16px; border-radius: 8px; border: 1px solid var(--rule); background: var(--surface); margin: 0 0 16px; }
.alert ul { margin: 0; padding-left: 1.2em; }
.alert-ok { border-color: var(--ok); color: var(--ok); }
.alert-error { border-color: var(--danger); color: var(--danger); }
.alert-info { border-color: var(--accent); }

form .field { margin-bottom: 14px; }
label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: 4px; }
label .opt { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=tel], input[type=url], input:not([type]), select, textarea {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid #B9B2A7; border-radius: 6px; background: #fff; color: var(--ink); min-height: 40px;
}
textarea { min-height: 96px; resize: vertical; }
input.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--rule); }
.form-actions .spacer { flex: 1; }
.inline-form { display: inline; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.check input { width: auto; min-height: 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th, table.list td { padding: 10px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; white-space: nowrap; }
table.list th { background: #F3EFE8; font-weight: 700; font-size: .85rem; }
table.list tr:last-child td { border-bottom: 0; }
table.list td.wrap { white-space: normal; }
table.list tbody tr:hover { background: #FBF9F5; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: #EEE9E0; color: var(--ink); }
.badge-draft { background: #EEE9E0; } .badge-sent, .badge-issued { background: #DDE9F5; color: #1C4F7A; }
.badge-accepted, .badge-paid { background: #DCEFE6; color: #1F6F5C; } .badge-rejected, .badge-cancelled { background: #F5DEDC; color: #8F2A24; }
.badge-overdue { background: #F5DEDC; color: #8F2A24; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 140px; }
.filters .field.grow { flex: 1; min-width: 200px; }
.filters input, .filters select { min-height: 38px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 6px; margin-top: 14px; }
.pager a, .pager span { padding: 4px 10px; border: 1px solid var(--rule); border-radius: 6px; text-decoration: none; }
.pager span { background: var(--accent); color: #fff; border-color: var(--accent); }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .9rem; }
dl.kv dd { margin: 0; }

table.items-editor { width: 100%; border-collapse: collapse; }
table.items-editor th { font-size: .8rem; color: var(--muted); font-weight: 700; text-align: left; padding: 4px 6px; }
table.items-editor td { padding: 4px 6px; vertical-align: middle; }
table.items-editor .c-desc { width: 40%; } table.items-editor .c-qty { width: 10%; } table.items-editor .c-unit { width: 9%; }
table.items-editor .c-price { width: 14%; } table.items-editor .c-rate { width: 9%; } table.items-editor .c-amt { width: 14%; } table.items-editor .c-del { width: 4%; }
.totals-preview { margin: 12px 0 0 auto; max-width: 360px; }
.totals-preview table { width: 100%; border-collapse: collapse; }
.totals-preview th { text-align: left; font-weight: 400; color: var(--muted); padding: 4px 8px; }
.totals-preview td { text-align: right; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.totals-preview tr.total th, .totals-preview tr.total td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid var(--ink); }

.doc-summary { display: grid; gap: 16px; }
@media (min-width: 900px) { .doc-summary { grid-template-columns: 1fr 360px; } }
table.lines-view { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.lines-view th, table.lines-view td { padding: 8px 10px; border-bottom: 1px solid var(--rule); text-align: left; }
table.lines-view th { background: #F3EFE8; font-size: .85rem; }

.login-box { max-width: 420px; margin: 40px auto; }
.portal-apps { display: grid; gap: 20px; margin-top: 24px; }
@media (min-width: 700px) { .portal-apps { grid-template-columns: 1fr 1fr; } }
.portal-apps a { display: block; background: var(--surface); border: 1px solid var(--rule); border-top: 4px solid var(--accent); border-radius: 8px; padding: 28px 24px; text-decoration: none; color: var(--ink); }
.portal-apps a.z { --accent: #B4532A; }
.portal-apps h2 { margin: 0 0 .4em; color: var(--accent); }

.card-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.meishi { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 16px; text-decoration: none; color: var(--ink); display: block; }
.meishi:hover { border-color: var(--accent); }
.meishi .m-name { font-weight: 700; font-size: 1.05rem; }
.meishi .m-company { color: var(--accent); font-weight: 700; font-size: .9rem; }
.meishi .m-sub { color: var(--muted); font-size: .85rem; }
.meishi .m-tags { margin-top: 6px; }
.tag { display: inline-block; font-size: .75rem; background: #EEE9E0; border-radius: 999px; padding: 1px 8px; margin: 2px 2px 0 0; }
.card-images { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.card-images img { width: 100%; height: auto; border: 1px solid var(--rule); border-radius: 6px; background: #fff; }
.thumb { width: 64px; height: 40px; object-fit: cover; border: 1px solid var(--rule); border-radius: 4px; vertical-align: middle; }

@media (max-width: 767px) {
  .user { width: 100%; margin-left: 0; padding-bottom: 8px; }
  .sub .top-inner { overflow-x: auto; flex-wrap: nowrap; }
  table.items-editor, table.items-editor thead, table.items-editor tbody, table.items-editor tr, table.items-editor td { display: block; width: 100%; }
  table.items-editor thead { display: none; }
  table.items-editor tr { border: 1px solid var(--rule); border-radius: 8px; padding: 8px; margin-bottom: 10px; background: var(--surface); }
  table.items-editor td { padding: 3px 0; }
  table.items-editor td.amt::before { content: "金額 "; color: var(--muted); font-size: .85rem; }
  table.items-editor td.amt { text-align: left; }
  table.items-editor td input[name="item_desc[]"]::placeholder { color: #999; }
}

/* 名刺 OCR */
.ocr-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ocr-status { font-size: .9rem; color: var(--muted); }
.ocr-busy { color: var(--accent); }
.ocr-ok { color: var(--ok); font-weight: 700; }
.ocr-error { color: var(--danger); }
.ocr-preview { width: 100%; border: 1px solid var(--rule); border-radius: 6px; margin-bottom: 6px; background: #fff; }
.ocr-filled { background: #FFF8E1; }

/* 一括取り込み */
.import-row { margin-bottom: 16px; }
.import-row .ocr-preview { max-height: 260px; object-fit: contain; }
.import-row label { font-size: .85rem; }
