/* 請求管理クラウド デモ用スタイル */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dde2ea;
  --text: #1f2a37;
  --muted: #667085;
  --side: #1b2a41;
  --side-text: #c9d3e1;
  --side-active: #2d4263;
  --accent: #0f7c86;
  --accent-dark: #0b5f67;
  --danger: #c0392b;
  --warn: #b7791f;
  --ok: #2f855a;
  --radius: 8px;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6; }
a { color: var(--accent); }

/* レイアウト */
.app { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: var(--text); text-decoration: none; }
.brand-mark { width: 28px; height: 28px; border-radius: 6px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 14px; }
.topbar-user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: #d5e6e8; color: var(--accent-dark);
  display: grid; place-items: center; font-weight: 700; }
.sidenav { background: var(--side); padding: 16px 10px; }
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.sidenav a { display: block; color: var(--side-text); text-decoration: none; padding: 9px 14px; border-radius: 6px; margin-bottom: 2px; }
.sidenav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidenav a[aria-current="page"] { background: var(--side-active); color: #fff; font-weight: 600; }
.sidenav .nav-section { color: #7f8ea6; font-size: 11px; padding: 14px 14px 6px; letter-spacing: .05em; }
.main { padding: 24px 28px 80px; min-width: 0; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-header h1 { font-size: 22px; margin: 0; }
.breadcrumb { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--muted); }

/* カード */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 18px; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.notice { border-left: 4px solid var(--warn); background: #fffaf0; }
.notice ul { margin: 0; padding-left: 18px; }
.notice li { margin: 4px 0; }
.notice time { color: var(--muted); font-size: 12px; margin-right: 8px; }

/* テーブル */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #f9fafb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f9fbfc; }
.empty { color: var(--muted); text-align: center; padding: 28px; }

.badge { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-draft { background: #eef0f3; color: #4a5565; }
.badge-sent { background: #e6f1fb; color: #1f5f99; }
.badge-paid { background: #e6f4ec; color: var(--ok); }
.badge-overdue { background: #fdecea; color: var(--danger); }

/* フォーム */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label, .toolbar label { font-size: 12px; color: var(--muted); font-weight: 600; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 18px; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="search"], select, textarea {
  font: inherit; padding: 7px 10px; border: 1px solid #c7cfdb; border-radius: 6px; background: #fff; color: var(--text); min-width: 0;
}
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 70px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); }
.required::after { content: " *"; color: var(--danger); }

.btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 7px 16px; border-radius: 6px;
  border: 1px solid #c7cfdb; background: #fff; color: var(--text); cursor: pointer; text-decoration: none; font-weight: 600; }
.btn:hover { background: #f3f5f8; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a93226; }
.btn-ghost-danger { color: var(--danger); border-color: #f1c4bf; }
.btn-small { padding: 3px 10px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* 品目テーブル */
.items input { width: 100%; }
.items td { padding: 6px 6px; }
.totals { margin-left: auto; width: min(320px, 100%); }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 18px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 8px; }

/* タブ */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { font: inherit; background: none; border: none; border-bottom: 2px solid transparent; padding: 10px 16px;
  color: var(--muted); cursor: pointer; font-weight: 600; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel[hidden] { display: none; }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 16px; }
.link-list li:last-child { border-bottom: none; }
.link-list a { font-weight: 600; }

/* モーダル */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 1000; padding: 16px; }
.modal-backdrop[hidden] { display: none; }
.modal { background: #fff; border-radius: 10px; width: min(440px, 100%); padding: 22px 24px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.modal h2 { margin: 0 0 10px; font-size: 17px; }
.modal p { margin: 0 0 12px; }
.modal .actions { margin-top: 18px; }

/* トースト */
.toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); background: #1f2a37; color: #fff;
  padding: 10px 20px; border-radius: 6px; z-index: 1100; font-size: 13px; box-shadow: 0 8px 20px rgba(0,0,0,.2); }
.toast[hidden] { display: none; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 56px auto 1fr; }
  .sidenav { padding: 6px; }
  .sidenav ul { display: flex; overflow-x: auto; }
  .sidenav .nav-section { display: none; }
  .main { padding: 16px; }
  .topbar-user .company { display: none; }
}
