/*
 * EXTONE Secure の画面。EXTONE Drive 管理コンソール（kintone_storage/apps/console、shadcn/ui の slate 配色）にそろえる。
 * 値は同じ設計トークン（--background・--primary・--border・--radius など）から作る。
 */
:root {
  --background: #ffffff;
  --foreground: #020817;            /* 222.2 84% 4.9% */
  --card: #ffffff;
  --primary: #0f172a;               /* 222.2 47.4% 11.2% */
  --primary-hover: #273246;
  --primary-foreground: #f8fafc;    /* 210 40% 98% */
  --secondary: #f1f5f9;             /* 210 40% 96.1% */
  --muted: #f1f5f9;
  --muted-bg: #f8fafc;              /* bg-muted/30 相当 */
  --muted-foreground: #64748b;      /* 215.4 16.3% 46.9% */
  --accent: #f1f5f9;
  --border: #e2e8f0;                /* 214.3 31.8% 91.4% */
  --ring: #020817;
  --destructive: #ef4444;           /* 0 84.2% 60.2% */
  --destructive-text: #b91c1c;
  --warn-bg: #fffbeb; --warn-border: #fde68a; --warn-text: #92400e;
  --info-bg: #eff6ff; --info-border: #bfdbfe; --info-text: #1e3a8a;
  --ok-bg: #ecfdf5; --ok-text: #047857;
  --brand-blue: #20aee5; --brand-magenta: #e5006e; --brand-yellow: #fabe00;
  --radius: 0.5rem;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}
* { box-sizing: border-box; border-color: var(--border); }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--foreground);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  font-size: 14px; line-height: 1.6;
}
a { color: var(--primary); text-underline-offset: 4px; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 600; line-height: 1.25; }
h2 { font-size: 1.125rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
h4 { font-size: 0.875rem; font-weight: 600; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.muted { color: var(--muted-foreground); font-size: 0.875rem; line-height: 1.5rem; }
.icon { width: 1rem; height: 1rem; flex-shrink: 0; }
.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 1rem; top: .5rem; z-index: 50; background: var(--background); padding: .5rem 1rem;
  border-radius: calc(var(--radius) - 2px); box-shadow: 0 0 0 2px var(--ring); }
.logo-img { display: block; width: 200px; max-width: 100%; height: auto; }

/* ---- ボタン（shadcn/ui の Button と同じ寸法） ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; white-space: nowrap;
  height: 2.5rem; padding: 0 1rem; border-radius: calc(var(--radius) - 2px); border: 1px solid transparent;
  background: var(--primary); color: var(--primary-foreground); font: inherit; font-size: .875rem; font-weight: 500;
  text-decoration: none; cursor: pointer; box-shadow: var(--shadow-sm); transition: all .15s;
}
.btn:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); text-decoration: none; }
.btn:active { transform: translateY(1px); box-shadow: var(--shadow-sm); }
.btn:disabled { opacity: .5; pointer-events: none; box-shadow: none; }
.btn-outline { background: var(--background); color: var(--foreground); border-color: var(--border); }
.btn-outline:hover { background: var(--accent); border-color: rgb(15 23 42 / .6); box-shadow: var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--foreground); box-shadow: none; }
.btn-ghost:hover { background: var(--accent); box-shadow: none; }
.btn-sm { height: 2.25rem; padding: 0 .75rem; }
.btn-lg { height: 2.75rem; padding: 0 2rem; }
.btn-block { width: 100%; }

/* ---- カード ---- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 1.5rem; }
.card-header { padding: 1.5rem 1.5rem 0; display: grid; gap: .5rem; }
.card-header.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.card-header p, .page-header p { color: var(--muted-foreground); font-size: .875rem; line-height: 1.5rem; }
.card-body { padding: 1.25rem 1.5rem 1.5rem; }
.card-body.flush { padding: 1rem 0 0; }
.card-foot { margin-top: 1.25rem; text-align: center; font-size: .875rem; color: var(--muted-foreground); }
.card-foot a { color: var(--muted-foreground); text-decoration: underline; }
.card-foot a:hover { color: var(--foreground); }

/* ---- フォーム ---- */
.form { display: grid; gap: 1rem; margin-top: 1.25rem; }
.field label { display: grid; gap: .5rem; font-size: .875rem; font-weight: 500; line-height: 1; }
.field input, .drop input[type=file] {
  height: 2.5rem; width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px);
  background: var(--background); font: inherit; font-size: .875rem; font-weight: 400; color: var(--foreground);
}
.field input:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring); }
.check { display: flex; gap: .5rem; align-items: center; font-size: .875rem; }
.check input { width: 1rem; height: 1rem; accent-color: var(--primary); }

/* ---- お知らせ ---- */
.msg { padding: .75rem 1rem; border-radius: calc(var(--radius) - 2px); border: 1px solid transparent; font-size: .875rem; margin: 1rem 0 0; }
.msg p + p, .msg p + form, .msg form { margin-top: .5rem; }
.msg-error { background: rgb(239 68 68 / .1); color: var(--destructive-text); }
.msg-warn { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.msg-info { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }

/* ---- 未ログインの枠（PublicLayout） ---- */
body.public { background: var(--muted-bg); min-height: 100vh; display: flex; flex-direction: column; }
.public-header { height: 3.5rem; border-bottom: 1px solid var(--border); background: var(--background);
  display: flex; align-items: center; justify-content: space-between; padding: 0 1rem; gap: 1rem; }
.public-logo { display: inline-flex; border-radius: 2px; }
.public-actions { display: flex; gap: .5rem; align-items: center; }
.public-main { flex: 1; width: 100%; margin: 0 auto; padding: 2.5rem 1.5rem; display: flex; justify-content: center; align-items: center; }
.public-main.auth { max-width: 32rem; }
.public-main.doc { max-width: 48rem; align-items: flex-start; }
.auth-card, .doc-card { width: 100%; padding: 0 1.5rem 1.5rem; }
.auth-card > .card-header, .doc-card > .card-header { padding: 1.5rem 0 0; }
.public-foot { text-align: center; padding: 1.5rem; color: var(--muted-foreground); font-size: .75rem; }
.public-foot a { color: var(--muted-foreground); }

.terms { margin: 1rem 0 0; padding-left: 1.25rem; }
.terms li { margin-bottom: .5rem; }

/* ---- ログイン後の枠（ConsoleShell・Sidebar・Header） ---- */
.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 16rem; flex-shrink: 0; display: flex; flex-direction: column; border-right: 1px solid var(--border); background: var(--card); }
.sidebar-logo { height: 3.5rem; display: flex; align-items: center; padding: 0 1rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .5rem; display: grid; align-content: start; gap: .25rem; }
.sidebar-foot { border-top: 1px solid var(--border); padding: .75rem .5rem; display: grid; gap: .25rem; }
.sidebar-foot form { margin: 0; }
.nav-item {
  display: flex; align-items: center; gap: .75rem; width: 100%; padding: .5rem .75rem;
  border: 0; border-left: 2px solid transparent; border-radius: calc(var(--radius) - 2px); background: none;
  color: var(--muted-foreground); font: inherit; font-size: .875rem; font-weight: 500; text-align: left; text-decoration: none;
  cursor: pointer; transition: color .15s, background-color .15s;
}
.nav-item:hover { background: var(--accent); color: var(--foreground); text-decoration: none; }
.nav-item.active { border-left-color: var(--primary); background: var(--accent); color: var(--foreground); }
.sidebar-link { padding: .25rem .75rem; font-size: .75rem; color: var(--muted-foreground); }
.shell-main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.console-header { min-height: 3.5rem; display: flex; align-items: center; justify-content: flex-end; gap: .5rem;
  border-bottom: 1px solid var(--border); background: rgb(255 255 255 / .95); padding: 0 1rem; }
.account { text-align: right; }
.account-name { font-size: .875rem; font-weight: 500; line-height: 1.25; }
.account-email { font-size: .75rem; color: var(--muted-foreground); max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-icon { width: 2.5rem; height: 2.5rem; display: inline-flex; align-items: center; justify-content: center; border-radius: calc(var(--radius) - 2px); }
.console-page { flex: 1; overflow: auto; padding: 1.5rem; display: grid; align-content: start; gap: 1.5rem; }
.console-page:focus { outline: none; }
.page-header { display: grid; gap: .5rem; }
.back { font-size: .875rem; }
.back a { color: var(--muted-foreground); }

/* ダッシュボード */
.quota { font-size: .875rem; color: var(--muted-foreground); white-space: nowrap; }
.quota b { color: var(--foreground); font-size: 1rem; }
.upload { display: grid; gap: 1rem; }
.drop { display: grid; gap: .5rem; padding: 1.25rem; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--muted-bg); }
.drop-title { font-weight: 500; }
.drop input[type=file] { height: auto; padding: .4rem .5rem; }
.upload-status { font-size: .875rem; color: var(--muted-foreground); min-height: 1.25rem; }
.upload-status.error { color: var(--destructive-text); }
.empty { color: var(--muted-foreground); padding: 0 1.5rem 1.5rem; }
.history { width: 100%; border-collapse: collapse; font-size: .875rem; }
.history th { text-align: left; font-weight: 500; color: var(--muted-foreground); padding: .75rem 1rem; border-bottom: 1px solid var(--border); background: var(--muted-bg); }
.history td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.history th:first-child, .history td:first-child { padding-left: 1.5rem; }
.history tr:last-child td { border-bottom: 0; }
.history td a { word-break: break-all; font-weight: 500; }
.badge { display: inline-flex; align-items: center; padding: .125rem .625rem; border-radius: 9999px; font-size: .75rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--secondary); color: var(--foreground); white-space: nowrap; }
.badge-completed { background: var(--ok-bg); border-color: transparent; color: var(--ok-text); }
.badge-rejected, .badge-failed, .badge-expired { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
.badge-scanning, .badge-waiting_upload { background: var(--info-bg); border-color: var(--info-border); color: var(--info-text); }
.counts { color: var(--muted-foreground); }
.counts b { color: var(--destructive-text); }

/* 診断結果 */
.meta { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.5rem; margin: 0; font-size: .875rem; }
.meta dt { color: var(--muted-foreground); } .meta dd { margin: 0; word-break: break-all; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.sum { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1rem 1.25rem; }
.sum span { display: block; color: var(--muted-foreground); font-size: .875rem; font-weight: 500; }
.sum b { display: block; font-size: 1.875rem; font-weight: 700; line-height: 1.2; margin-top: .25rem; }
.sum-action { border-top: 3px solid var(--destructive); } .sum-action b { color: var(--destructive-text); }
.sum-review { border-top: 3px solid var(--brand-yellow); } .sum-review b { color: var(--warn-text); }
.sum-info { border-top: 3px solid var(--brand-blue); }
.sum-unchecked { border-top: 3px solid var(--muted-foreground); }
.console-page > section { display: grid; gap: .5rem; }
.findings, .simple { list-style: none; padding: 0; margin: .25rem 0 0; display: grid; gap: .75rem; }
.findings li { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1.25rem 1.5rem; display: grid; gap: .5rem; }
.findings dl { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0; font-size: .875rem; }
.findings dt { color: var(--muted-foreground); } .findings dd { margin: 0; }
.dep { font-size: .875rem; color: var(--muted-foreground); }
.simple li { background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px); padding: .625rem 1rem; font-size: .875rem; }
.path { color: var(--muted-foreground); font-weight: 400; font-size: .75rem; word-break: break-all; }

/* 件数から各区分へ移動 */
html, .console-page { scroll-behavior: smooth; }
a.sum { color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s; }
a.sum:hover { box-shadow: var(--shadow-md); text-decoration: none; transform: translateY(-1px); }
.console-page > section[id] { scroll-margin-top: 1rem; }
.console-page > section[id]:target h3 { color: var(--brand-blue); }

/* 場所とソースコードの抜粋 */
.where { font-size: .8125rem; font-weight: 500; color: var(--foreground); background: var(--muted); border-radius: calc(var(--radius) - 4px);
  padding: .125rem .5rem; justify-self: start; word-break: break-all; }
details.source { margin-top: .25rem; }
details.source > summary, details.places > summary { cursor: pointer; font-size: .8125rem; font-weight: 500; color: var(--primary); width: max-content; }
details.source > summary:hover, details.places > summary:hover { text-decoration: underline; }
pre.code { margin: .5rem 0 0; padding: .5rem 0; background: #0f172a; color: #e2e8f0; border-radius: calc(var(--radius) - 2px);
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-x: auto; }
.code-line { display: flex; min-width: max-content; padding-right: 1rem; }
.code-line .ln { flex: 0 0 3.5rem; padding-right: .75rem; text-align: right; color: #64748b; user-select: none; }
.code-line .tx { white-space: pre; }
.code-line.hit { background: rgb(250 190 0 / .18); box-shadow: inset 3px 0 0 var(--brand-yellow); }
.code-line.hit .ln { color: var(--brand-yellow); }

/* 情報・確認できなかった項目 */
.groups { list-style: none; padding: 0; margin: .25rem 0 0; display: grid; gap: .75rem; }
.groups > li { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 1rem 1.25rem; display: grid; gap: .5rem; }
.group-text { font-size: .875rem; }
.files { margin: 0; padding-left: 1.1rem; font-size: .8125rem; color: var(--muted-foreground); }
details.places ol { margin: .5rem 0 0; padding-left: 1.25rem; display: grid; gap: .5rem; font-size: .8125rem; }
details.places li { display: grid; gap: .25rem; }

/* ---- 狭い画面 ---- */
@media (max-width: 1023px) {
  .shell { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar-logo { border-bottom: 0; }
  .sidebar-nav, .sidebar-foot { flex: 0 1 auto; display: flex; padding: .5rem; border-top: 0; }
  .sidebar-link { display: none; }
  .shell-main { overflow: visible; }
  .console-page { overflow: visible; }
}
@media (max-width: 640px) {
  .public-header .logo-img { width: 150px; }
  .summary { grid-template-columns: repeat(2, 1fr); }
  .history th:nth-child(3), .history td:nth-child(3), .history th:nth-child(5), .history td:nth-child(5) { display: none; }
  .account-email { display: none; }
  .console-page { padding: 1rem; }
}

/* AI による説明と見解（参考）。検査の結果とは別の囲みで見せる */
.ai-consent { margin: 4px 0 12px; align-items: flex-start; }
.ai-consent .muted { font-size: 12px; }
.ai-overview { margin-bottom: 16px; }
.ai-overview h3 { margin: 0 0 8px; font-size: 15px; }
.ai { margin-top: 12px; border: 1px dashed var(--border); border-left: 4px solid var(--muted-foreground);
  border-radius: var(--radius); padding: 10px 12px; background: var(--muted); }
.ai-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 6px; }
.ai-label { font-weight: 600; font-size: 13px; }
.ai-badge { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--background); border: 1px solid var(--border); }
.ai-acceptable { border-left-color: #16a34a; } .ai-acceptable .ai-badge { color: #166534; border-color: #86efac; background: #f0fdf4; }
.ai-improvable { border-left-color: #d97706; } .ai-improvable .ai-badge { color: #92400e; border-color: #fcd34d; background: #fffbeb; }
.ai-high_risk { border-left-color: #dc2626; } .ai-high_risk .ai-badge { color: #991b1b; border-color: #fca5a5; background: #fef2f2; }
.ai dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 13px; }
.ai dt { color: var(--muted-foreground); }
.ai dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 640px) { .ai dl { grid-template-columns: 1fr; } .ai dt { margin-top: 4px; } }

/* アカウント設定・問い合わせ・二要素認証 */
.field select, .field textarea {
  width: 100%; padding: .5rem .75rem; border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px);
  background: var(--background); font: inherit; font-size: .875rem; font-weight: 400; color: var(--foreground); line-height: 1.5;
}
.field select { height: 2.5rem; }
.field textarea { resize: vertical; min-height: 8rem; }
.field select:focus-visible, .field textarea:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring); }
.narrow { max-width: 40rem; }
.console-page > .card + .card { margin-top: 1rem; }
.card.danger { border-color: rgb(239 68 68 / .4); }
.card.danger h2 { color: var(--destructive-text); }
.btn-danger { background: var(--destructive); color: #fff; border-color: transparent; }
.btn-danger:hover { background: var(--destructive-text); }
.qr { width: 200px; margin: .5rem 0 1rem; background: #fff; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius); }
.qr svg { display: block; width: 100%; height: auto; }
.steps { margin: 0 0 .5rem 1.25rem; padding: 0; font-size: .875rem; line-height: 1.6; }
code.secret { font-size: .875rem; letter-spacing: .05em; word-break: break-all; }
.recovery-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .25rem .75rem; list-style: none; padding: 0; margin: .5rem 0 0; }
.recovery-codes code { font-size: .9375rem; }
.ai-counts { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.ai-count { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--background); }
.ai-count b { margin-left: 2px; }
.ai-count.ai-high_risk { color: #991b1b; border-color: #fca5a5; background: #fef2f2; }
.ai-count.ai-improvable { color: #92400e; border-color: #fcd34d; background: #fffbeb; }
.ai-count.ai-acceptable { color: #166534; border-color: #86efac; background: #f0fdf4; }
.ai-risks { border-left: 4px solid #dc2626; background: #fef2f2; border-radius: 6px; padding: 8px 12px; margin: 8px 0; font-size: 13px; }
.ai-risks-head { margin: 0 0 4px; font-weight: 600; color: #991b1b; }
.ai-risks ul { margin: 0; padding-left: 1.25rem; display: grid; gap: 2px; }
.ai-flag { margin: 4px 0; font-size: 13px; font-weight: 600; color: #991b1b; }
.ai[id] { scroll-margin-top: 1rem; }
.ai:target { box-shadow: 0 0 0 2px #fca5a5; }

/* 利用条件（章・節・条・項・号） */
.terms-doc { font-size: .875rem; line-height: 1.8; }
.terms-preamble { margin: 1rem 0; }
.terms-chapter { font-size: 1.125rem; margin: 1.75rem 0 .5rem; padding-bottom: .25rem; border-bottom: 1px solid var(--border); }
.terms-section { font-size: 1rem; margin: 1.5rem 0 .5rem; }
.terms-article { margin: 0 0 1rem; scroll-margin-top: 1rem; }
.terms-article h4 { font-size: .9375rem; margin: 0 0 .25rem; }
.terms-article p { margin: 0; }
.terms-paragraphs { margin: 0; padding-left: 1.5rem; }
.terms-paragraphs > li { margin-bottom: .375rem; }
.terms-items { margin: .25rem 0 .25rem; padding-left: 1.75rem; list-style-type: lower-roman; }
.terms-enacted { margin-top: 1.5rem; color: var(--muted-foreground); text-align: right; }
