/* ノリツグ管理システム 共通スタイル（スマホ優先）。インラインstyleは使わない（CSPで禁止） */
:root {
  --green: #22594f;
  --green-dark: #1a463e;
  --blue: #416780;
  --ink: #203631;
  --muted: #5f726c;
  --bg: #f5f6f2;
  --line: #d8dfd8;
  --card: #ffffff;
  --danger: #a8392f;
  --warn-bg: #fbf3dc;
  --radius: 10px;
  --tabbar-h: 62px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Yu Gothic', 'YuGothic', 'Hiragino Sans', 'Meiryo', sans-serif;
  font-size: 16px;
  line-height: 1.7;
}
h1, h2, h3, .brand, .plain-brand {
  font-family: 'Yu Mincho', 'YuMincho', 'Hiragino Mincho ProN', serif;
  font-weight: 700;
  letter-spacing: .03em;
}
h1 { font-size: 1.45rem; margin: 0 0 .6rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
a { color: var(--blue); }
.muted { color: var(--muted); }
.small { font-size: .85rem; color: var(--muted); }

/* ---- ボタン・フォーム ---- */
.btn {
  display: inline-block; padding: .55em 1.1em; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit; font-size: .95rem; text-decoration: none; cursor: pointer; line-height: 1.4;
}
.btn:hover { border-color: var(--green); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 700; }
.btn-primary:hover { background: var(--green-dark); }
.btn-danger { color: var(--danger); border-color: #e3c3bf; }
.btn-quiet { background: transparent; }
.btn-sm { padding: .3em .8em; font-size: .82rem; }
.btn-block { display: block; width: 100%; text-align: center; padding: .8em; font-size: 1rem; }

.field { display: block; margin: 0 0 1rem; }
.field > span { display: block; font-size: .88rem; font-weight: 700; margin-bottom: .25rem; }
input[type=text], input[type=password], select {
  width: 100%; padding: .65em .8em; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit; font-size: 16px; /* iOSのズーム防止 */
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.check { display: flex; gap: .5em; align-items: flex-start; margin: 0 0 1rem; font-size: .9rem; }
.check input { margin-top: .35em; }
.code-input { font-size: 1.6rem !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---- カード・通知 ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; margin: 0 0 1rem; }
.flash { padding: .7em 1em; border-radius: 8px; margin: 0 0 1rem; border: 1px solid var(--line); background: #eef5f1; font-size: .92rem; }
.flash-error { background: #fbe9e6; border-color: #e3c3bf; color: #7d2820; }
.flash-warn { background: var(--warn-bg); border-color: #e7d9a6; }
.soon { display: inline-block; font-size: .68rem; font-style: normal; padding: 0 .5em; border-radius: 99px; background: #e6ebe7; color: var(--muted); line-height: 1.6; }
.err-code { font-family: 'Yu Mincho', 'YuMincho', serif; font-size: 2.4rem; margin: 0; color: var(--blue); }
.empty { text-align: center; padding: 2.2rem 1rem; }
.empty-title { font-weight: 700; margin: 0 0 .3rem; }

/* ---- ログイン系（ナビなし） ---- */
body.plain { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.plain-wrap { width: 100%; max-width: 430px; }
.plain-brand { text-align: center; font-size: 1.5rem; color: var(--green); margin-bottom: 1rem; }
.plain-brand span { display: block; font-size: .8rem; color: var(--muted); letter-spacing: .15em; }
.steps { padding-left: 1.3rem; margin: .5rem 0 1rem; font-size: .92rem; }
.qr-box { display: flex; justify-content: center; margin: 0 0 1rem; }
#qr { padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; min-width: 100px; min-height: 100px; }
#qr img, #qr canvas { display: block; max-width: 100%; height: auto; }
.manual { margin: 0 0 1rem; font-size: .88rem; }
.manual summary { cursor: pointer; color: var(--blue); }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; letter-spacing: .08em; word-break: break-all; background: #f1f4f0; padding: .5em .7em; border-radius: 6px; user-select: all; }
.manual .small { word-break: break-all; }

/* ---- アプリ外枠 ---- */
body.app { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .55rem 1rem; background: #fff; border-bottom: 1px solid var(--line); }
.brand { color: var(--green); text-decoration: none; font-size: 1.2rem; line-height: 1.2; }
.brand span { display: block; font-size: .65rem; color: var(--muted); letter-spacing: .12em; }
.usermenu { display: flex; align-items: center; gap: .5rem; }
.usermenu form { margin: 0; }
.user-name { color: var(--ink); text-decoration: none; font-size: .85rem; line-height: 1.2; text-align: right; }
.user-name small { display: block; font-size: .68rem; color: var(--muted); }
.content { max-width: 1040px; margin: 0 auto; padding: 1.1rem 1rem 2rem; }

/* ナビ: スマホは下部タブ、PCは上部に横並び */
.mainnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-item { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabbar-h); color: var(--muted); text-decoration: none; font-size: .68rem; position: relative; }
.nav-item .nav-icon { opacity: .55; }
.nav-item.is-active { color: var(--green); font-weight: 700; }
.nav-item.is-active .nav-icon { opacity: 1; }
.nav-item.is-active::before { content: ''; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; background: var(--green); border-radius: 0 0 3px 3px; }
.nav-item .nav-label, .nav-item .soon { display: none; }
.nav-item .nav-short { display: block; }
.nav-item.is-soon .nav-icon { opacity: .35; }

@media (min-width: 820px) {
  body.app { padding-bottom: 0; }
  .topbar { padding: .5rem 1.5rem; }
  .mainnav { position: static; border: 0; background: transparent; padding: 0; flex: 1; justify-content: center; gap: .2rem; }
  .nav-item { flex: 0 0 auto; flex-direction: row; gap: .45rem; height: auto; padding: .45rem .8rem; border-radius: 8px; font-size: .9rem; }
  .nav-item:hover { background: #eef2ee; }
  .nav-item.is-active { background: #e4ede9; }
  .nav-item.is-active::before { display: none; }
  .nav-item .nav-icon { width: 20px; height: 20px; }
  .nav-item .nav-label, .nav-item .soon { display: inline-block; }
  .nav-item .nav-short { display: none; }
  .content { padding-top: 1.6rem; }
}

/* ---- ダッシュボードなど ---- */
.grid { display: grid; grid-template-columns: 1fr; gap: .8rem; margin-top: 1rem; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tile { display: flex; flex-direction: column; gap: .2rem; padding: 1rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.tile:hover { border-color: var(--green); }
.tile strong { font-family: 'Yu Mincho', 'YuMincho', serif; font-size: 1.1rem; color: var(--green); }
.tile span { font-size: .85rem; color: var(--muted); }
.tile em { align-self: flex-start; margin-top: .3rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.page-head h1 { margin: 0; }
.kv { display: grid; grid-template-columns: 8em 1fr; gap: .3rem .8rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; }

/* ---- 表（スマホでは縦積み） ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); font-size: .9rem; }
.table th, .table td { padding: .6rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { background: #eef2ee; font-size: .8rem; white-space: nowrap; }
.table tr.is-off td { color: var(--muted); background: #f8f8f6; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.actions form { margin: 0; }
@media (max-width: 720px) {
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr { border-bottom: 6px solid var(--bg); padding: .3rem 0; }
  .table td { border: 0; padding: .25rem .8rem; }
  .table td[data-label]::before { content: attr(data-label) '：'; color: var(--muted); font-size: .8rem; }
}

/* ---- 顧客・商談・LINE連携（PRJ-027 P1） ---- */
input[type=search], input[type=tel], input[type=email], input[type=date], textarea {
  width: 100%; padding: .65em .8em; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); font: inherit; font-size: 16px;
}
textarea { resize: vertical; line-height: 1.6; }
input[type=search]:focus, input[type=tel]:focus, input[type=email]:focus, input[type=date]:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; }
.two { display: grid; grid-template-columns: 1fr; gap: 0 .8rem; }
@media (min-width: 560px) { .two { grid-template-columns: 1fr 1fr; } }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: 0 0 1rem; }
.filters input[type=search] { grid-column: 1 / -1; }
.filters .btn { text-align: center; }
@media (min-width: 820px) { .filters { grid-template-columns: 2fr 1fr 1fr 1fr auto auto; align-items: center; } .filters input[type=search] { grid-column: auto; } }
.chip { display: inline-block; font-size: .75rem; line-height: 1.6; padding: 0 .6em; border-radius: 99px; background: #e4ede9; color: var(--green-dark); white-space: nowrap; font-weight: 700; font-family: inherit; letter-spacing: 0; }
.chip-line { background: #dff3e4; color: #1f6b3a; margin-left: .3em; }
.chip-warn { background: var(--warn-bg); color: #7a5b00; }
.stage-off { background: #ece9e4; color: var(--muted); }
.chip-via-line { background: #dff3e4; color: #1f6b3a; font-weight: 400; }
.chip-via-system { background: #e6edf3; color: var(--blue); font-weight: 400; }
.row-link { font-weight: 700; color: var(--ink); text-decoration: none; }
.row-link:hover { color: var(--green); text-decoration: underline; }
.pager { display: flex; justify-content: center; align-items: center; gap: .8rem; margin: 1rem 0; }
.empty-img { display: block; margin: 0 auto .8rem; max-width: 60%; height: auto; }
.pre { white-space: pre-wrap; word-break: break-word; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.inline-form select { width: auto; min-width: 10em; flex: 1 1 10em; }
.timeline { list-style: none; margin: 1rem 0 0; padding: 0; border-left: 2px solid var(--line); }
.timeline li { padding: .2rem 0 .7rem .9rem; position: relative; font-size: .92rem; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: .75rem; width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.line-box { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; margin: 0 0 .8rem; background: #fafbf9; }
.line-head { display: flex; gap: .8rem; align-items: center; margin-bottom: .6rem; }
.avatar { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; background: #e6ebe7; flex: none; }
.avatar-sm { width: 32px; height: 32px; }
.avatar-none { display: inline-block; }
.masked { color: var(--muted); letter-spacing: .1em; }
.sens, fieldset.sens { border: 1px dashed #d7c27a; background: #fffbea; border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 1rem; }
fieldset.sens legend { font-weight: 700; font-size: .88rem; padding: 0 .4em; }
.cand { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: 0 0 .6rem; }
.cand form { margin: 0; }
.reveal-form { margin: 1rem 0 0; }
.text-danger { color: var(--danger); }
code { font-family: ui-monospace, Consolas, monospace; font-size: .9em; background: #f1f4f0; padding: 0 .3em; border-radius: 4px; }
h3 { font-size: 1rem; margin: .8rem 0 .4rem; }
.line-box .actions { margin-top: .7rem; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .kv { grid-template-columns: 6em 1fr; } }
