/* ============================================================
   請求書管理システム 共通スタイル
   経理データを長時間見るため、目が疲れにくい配色と余白にしている。
   ライト／ダークはブラウザの設定に追従する。
   ============================================================ */

:root {
  color-scheme: light dark;

  --bg: #f2f4f8;
  --bg-soft: #e8ecf3;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --line: #dde3ec;
  --line-strong: #c3ccdb;

  --text: #16202e;
  --text-soft: #5a6779;
  --text-faint: #8a95a6;

  --accent: #2f5fd0;
  --accent-strong: #24499f;
  --accent-soft: #e8efff;

  --ok: #17795e;
  --ok-soft: #e2f5ef;
  --warn: #9a6400;
  --warn-soft: #fdf3dd;
  --danger: #b3261e;
  --danger-soft: #fdecea;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 32, 51, .06), 0 8px 24px rgba(20, 32, 51, .06);
  --shadow-sm: 0 1px 2px rgba(20, 32, 51, .08);
  --sidebar-w: 232px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151c;
    --bg-soft: #161b24;
    --surface: #1a212b;
    --surface-2: #202836;
    --line: #2b3543;
    --line-strong: #3b4757;

    --text: #e6ebf2;
    --text-soft: #a3b0c2;
    --text-faint: #7c8899;

    --accent: #6b9bff;
    --accent-strong: #8db4ff;
    --accent-soft: #1e2b45;

    --ok: #5fd2ac;
    --ok-soft: #14322a;
    --warn: #e8b75a;
    --warn-soft: #35290f;
    --danger: #ff8b82;
    --danger-soft: #3a1c1a;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", "Meiryo", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 数字は等幅にして桁を揃える */
.num, td.num, th.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-align: right;
  white-space: nowrap;
}

/* ---------------------------------------------- ログイン画面 */

.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  background: var(--bg);
}

.auth__art {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  padding: 46px 52px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  color: #f4f7ff;
  background: linear-gradient(155deg, #14213f 0%, #0f1a30 55%, #0b1322 100%);
}

/* 背景に薄い方眼を敷き、ゆっくり流して動きを出す */
.auth__art::before {
  content: "";
  position: absolute;
  inset: -60px;
  z-index: -2;
  background-image:
    linear-gradient(rgba(255, 255, 255, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .055) 1px, transparent 1px);
  background-size: 46px 46px;
  animation: grid-drift 18s linear infinite;
}

@keyframes grid-drift {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(46px, 46px, 0); }
}

/* 漂う光の玉。3つを別々の速さで動かして単調さを消す。 */
.orb {
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(58px);
  opacity: .55;
  will-change: transform;
}
.orb--1 {
  width: 460px; height: 460px; top: -110px; left: -90px;
  background: radial-gradient(circle, #3f74f0 0%, transparent 70%);
  animation: float-a 14s ease-in-out infinite;
}
.orb--2 {
  width: 400px; height: 400px; bottom: -130px; right: -70px;
  background: radial-gradient(circle, #2a4fb8 0%, transparent 70%);
  animation: float-b 17s ease-in-out infinite;
}
.orb--3 {
  width: 300px; height: 300px; top: 42%; left: 52%;
  background: radial-gradient(circle, #4fb3e8 0%, transparent 70%);
  opacity: .32;
  animation: float-c 20s ease-in-out infinite;
}

@keyframes float-a {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(110px, 84px) scale(1.2); }
}
@keyframes float-b {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-100px, -72px) scale(1.16); }
}
@keyframes float-c {
  0%, 100% { transform: translate(0, 0); }
  33%      { transform: translate(-92px, 66px); }
  66%      { transform: translate(78px, -58px); }
}

/* 書類を読み取っている様子を表す走査線 */
.scanline {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 130px;
  z-index: -1;
  background: linear-gradient(180deg, transparent 0%, rgba(122, 164, 255, .16) 50%, transparent 100%);
  animation: scan 5.2s cubic-bezier(.45, 0, .55, 1) infinite;
}

@keyframes scan {
  0%       { transform: translateY(-140px); opacity: 0; }
  12%      { opacity: 1; }
  88%      { opacity: 1; }
  100%     { transform: translateY(100dvh); opacity: 0; }
}

.auth__brand { display: flex; align-items: center; gap: 12px; }
.auth__mark {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .13);
  border: 1px solid rgba(255, 255, 255, .2);
  font-size: 19px;
}
.auth__brandname { font-weight: 700; letter-spacing: .04em; font-size: 14.5px; }

.auth__center { display: grid; align-content: center; justify-items: start; }

/* 社名を1文字ずつ、回りながら飛び込ませる。出たあとも軽く波打たせる。 */
.auth__logo {
  position: relative;
  margin: 0;
  font-size: clamp(30px, 3.6vw, 46px);
  font-weight: 700;
  letter-spacing: .14em;
  line-height: 1.3;
  perspective: 700px;
}
.auth__logo span {
  display: inline-block;
  opacity: 0;
  transform: translateY(56px) rotateX(-80deg) scale(.55);
  filter: blur(10px);
  /* 飛び込み → そのまま波打ちへ続ける */
  animation:
    burst .85s cubic-bezier(.16, 1.5, .3, 1) forwards,
    wave 3.6s ease-in-out infinite;
}
.auth__logo span:nth-child(1) { animation-delay: .05s, 1.0s; }
.auth__logo span:nth-child(2) { animation-delay: .13s, 1.1s; }
.auth__logo span:nth-child(3) { animation-delay: .21s, 1.2s; }
.auth__logo span:nth-child(4) { animation-delay: .32s, 1.3s; }
.auth__logo span:nth-child(5) { animation-delay: .40s, 1.4s; }
.auth__logo span:nth-child(6) { animation-delay: .48s, 1.5s; }
.auth__logo span:nth-child(7) { animation-delay: .56s, 1.6s; }
.auth__logo span:nth-child(8) { animation-delay: .64s, 1.7s; }
.auth__logo span:nth-child(9) { animation-delay: .72s, 1.8s; }

@keyframes burst {
  0% {
    opacity: 0;
    transform: translateY(56px) rotateX(-80deg) scale(.55);
    filter: blur(10px);
    text-shadow: none;
  }
  55% {
    opacity: 1;
    transform: translateY(-10px) rotateX(12deg) scale(1.14);
    filter: blur(0);
    text-shadow: 0 0 26px rgba(130, 175, 255, .95), 0 0 60px rgba(90, 140, 255, .6);
  }
  100% {
    opacity: 1;
    transform: translateY(0) rotateX(0) scale(1);
    filter: blur(0);
    text-shadow: 0 0 18px rgba(120, 165, 255, .28);
  }
}

/* 出現後、上下にゆらぐ */
@keyframes wave {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* 文字の上を光が走る */
.auth__logo::after {
  content: "";
  position: absolute;
  top: -12%;
  left: -35%;
  width: 28%;
  height: 124%;
  pointer-events: none;
  transform: skewX(-18deg);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, .55) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  mix-blend-mode: screen;
  animation: sweep 4.6s 1.2s cubic-bezier(.5, 0, .4, 1) infinite;
}

@keyframes sweep {
  0%       { left: -35%; opacity: 0; }
  12%      { opacity: 1; }
  60%      { opacity: 1; }
  75%, 100% { left: 118%; opacity: 0; }
}

/* 社名の下に伸びる線。伸びたあとは光が往復する。 */
.auth__rule {
  position: relative;
  overflow: hidden;
  height: 2px;
  width: 0;
  margin-top: 22px;
  border-radius: 2px;
  background: linear-gradient(90deg, #6f9dff, rgba(111, 157, 255, 0));
  animation: rule-grow .8s .7s cubic-bezier(.22, .8, .3, 1) forwards;
}
.auth__rule::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, #eaf2ff, transparent);
  transform: translateX(-100%);
  animation: rule-shine 4s 1.8s ease-in-out infinite;
}

@keyframes rule-grow {
  to { width: 300px; }
}
@keyframes rule-shine {
  0%       { transform: translateX(-100%); }
  60%, 100% { transform: translateX(220%); }
}

.auth__foot { font-size: 12px; color: rgba(244, 247, 255, .45); }

.auth__form { display: grid; place-items: center; padding: 40px 28px; }
.auth__panel { width: 100%; max-width: 380px; }
.auth__panel h2 { margin: 0 0 4px; font-size: 21px; }
.auth__lead { margin: 0 0 26px; color: var(--text-soft); font-size: 13px; }

/* 動きを減らす設定の人には静止した状態で見せる */
@media (prefers-reduced-motion: reduce) {
  .auth__art::before, .orb, .scanline,
  .auth__logo span, .auth__logo::after,
  .auth__rule, .auth__rule::after {
    animation: none;
  }
  .auth__logo span { opacity: 1; transform: none; filter: none; }
  .auth__logo::after { display: none; }
  .auth__rule { width: 300px; }
  .scanline { display: none; }
}

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth__art { padding: 30px 24px; gap: 26px; min-height: 240px; }
  .auth__logo { letter-spacing: .1em; }
  .auth__rule { animation-name: rule-grow-sm; }
  @keyframes rule-grow-sm { to { width: 180px; } }
}

/* ---------------------------------------------- フォーム部品 */

.field { margin-bottom: 16px; }
.field > label {
  display: block;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
}

.input, select.input, textarea.input {
  width: 100%;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, select.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, transform .06s;
}
.btn:hover { background: var(--accent-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--block { width: 100%; }
.btn--ghost {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line-strong);
}
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { padding: 7px 13px; font-size: 13px; }

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert--error { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert--warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert--ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }

/* ---------------------------------------------- アプリの骨格 */

.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100dvh; }

.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.side__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--line);
}
.side__mark {
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  color: #fff; font-size: 15px;
  background: linear-gradient(140deg, #3f6de0, #23417f);
}
.side__title { font-weight: 700; font-size: 14px; letter-spacing: .02em; }
.side__nav { padding: 12px 10px; display: grid; gap: 2px; overflow-y: auto; }
.side__label {
  padding: 12px 10px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text-faint);
}
.side__link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 13.5px;
}
.side__link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side__link.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side__icon { width: 18px; text-align: center; }
.side__foot { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); }
.side__user { font-size: 12.5px; color: var(--text-soft); margin-bottom: 8px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 16px 26px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 700; }
.topbar__sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-soft); }
.content { padding: 24px 26px 56px; max-width: 1440px; width: 100%; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .side__nav { display: flex; padding: 8px; }
  .side__label, .side__foot { display: none; }
  .content { padding: 18px 14px 40px; }
}

/* ---------------------------------------------- カード・表 */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--line);
}
.card__head h2 { margin: 0; font-size: 14.5px; font-weight: 700; }
.card__note { font-size: 12.5px; color: var(--text-soft); }
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.stat { padding: 16px 18px; }
.stat__label { font-size: 12px; color: var(--text-soft); margin-bottom: 6px; }
.stat__value { font-size: 25px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat__unit { font-size: 13px; font-weight: 500; color: var(--text-soft); margin-left: 3px; }
.stat__foot { margin-top: 6px; font-size: 12px; color: var(--text-faint); }

.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}
table.data thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--line-strong);
  z-index: 1;
}
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.wrap { white-space: normal; min-width: 16em; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
}
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--muted { background: var(--bg-soft); color: var(--text-soft); }

.empty { padding: 44px 20px; text-align: center; color: var(--text-faint); }
.empty__icon { font-size: 30px; display: block; margin-bottom: 8px; opacity: .6; }

/* 月別の支払額を横棒で見せる簡易グラフ */
.bars { display: grid; gap: 9px; }
.bar { display: grid; grid-template-columns: 5.5em 1fr 8.5em; align-items: center; gap: 10px; }
.bar__label { font-size: 12.5px; color: var(--text-soft); }
.bar__track { height: 9px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.bar__fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, #4b7bef, #7aa4ff); }
.bar__value { font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: right; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.toolbar .field { margin-bottom: 0; }
.toolbar .field--grow { flex: 1 1 220px; }

.section-title { margin: 26px 0 12px; font-size: 13px; font-weight: 700; color: var(--text-soft); letter-spacing: .04em; }
.stack { display: grid; gap: 16px; }

/* ============================================================
   ログイン後の画面の作り込み
   数字が主役なので、色と余白でめりはりを付ける。
   ============================================================ */

/* ---- 画面上部の見出し帯 ---- */

.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
  color: #eef3ff;
  background: linear-gradient(120deg, #1b2f5e 0%, #16233f 60%, #131c2f 100%);
  box-shadow: var(--shadow);
}
.hero::after {
  content: "";
  position: absolute;
  right: -70px; top: -90px;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(96, 145, 255, .38) 0%, transparent 68%);
  pointer-events: none;
}
.hero__row { position: relative; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px; }
.hero__label { font-size: 12px; letter-spacing: .08em; color: rgba(238, 243, 255, .62); }
.hero__value { font-size: 34px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.hero__value small { font-size: 15px; font-weight: 500; margin-left: 4px; color: rgba(238, 243, 255, .7); }
.hero__meta { display: flex; flex-wrap: wrap; gap: 20px; }
.hero__meta div { font-size: 12.5px; color: rgba(238, 243, 255, .68); }
.hero__meta strong { display: block; font-size: 17px; color: #eef3ff; font-variant-numeric: tabular-nums; }

/* 月を選ぶタブ */
.monthtabs { position: relative; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.monthtab {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  color: rgba(238, 243, 255, .72);
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  transition: background .15s, color .15s;
}
.monthtab:hover { background: rgba(255, 255, 255, .16); color: #fff; text-decoration: none; }
.monthtab.is-active { background: #fff; color: #1b2f5e; font-weight: 700; border-color: #fff; }

/* ---- 色付きの数字カード ---- */

.stat {
  position: relative;
  overflow: hidden;
  padding: 18px 18px 18px 22px;
  transition: transform .16s, box-shadow .16s;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--tone, var(--accent));
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.stat__icon {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 14px;
  color: var(--tone, var(--accent));
  background: var(--tone-soft, var(--accent-soft));
}
.stat--blue { --tone: #2f5fd0; --tone-soft: #e8efff; }
.stat--green { --tone: #17795e; --tone-soft: #e2f5ef; }
.stat--amber { --tone: #9a6400; --tone-soft: #fdf3dd; }
.stat--violet { --tone: #6146c6; --tone-soft: #eeeaff; }
@media (prefers-color-scheme: dark) {
  .stat--blue { --tone: #6b9bff; --tone-soft: #1e2b45; }
  .stat--green { --tone: #5fd2ac; --tone-soft: #14322a; }
  .stat--amber { --tone: #e8b75a; --tone-soft: #35290f; }
  .stat--violet { --tone: #a893ff; --tone-soft: #241f3f; }
}

/* ---- 決済方法の内訳（円グラフ） ---- */

.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut {
  width: 132px; height: 132px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: grid; place-items: center;
  background: conic-gradient(var(--slices, var(--accent) 0 100%));
  position: relative;
}
.donut::after {
  content: "";
  position: absolute;
  inset: 17px;
  border-radius: 50%;
  background: var(--surface);
}
.donut__center { position: relative; z-index: 1; text-align: center; line-height: 1.3; }
.donut__center b { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.donut__center span { font-size: 11px; color: var(--text-soft); }
.legend { display: grid; gap: 8px; min-width: 0; }
.legend__item { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend__dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.legend__name { color: var(--text-soft); }
.legend__value { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---- 棒グラフを伸ばす ---- */

.bar__fill { width: 0; transition: width .9s cubic-bezier(.22, .8, .3, 1); }
.bar.is-current .bar__label { color: var(--text); font-weight: 700; }
.bar.is-current .bar__fill { background: linear-gradient(90deg, #1f47a8, #4b7bef); }
.bar__track { position: relative; }

/* ---- 順位の丸 ---- */

.rank {
  display: inline-grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 7px;
  font-size: 11.5px; font-weight: 700;
  background: var(--bg-soft); color: var(--text-soft);
}
.rank--1 { background: #fbe9c4; color: #8a5a00; }
.rank--2 { background: #e4e8ef; color: #4d5a6d; }
.rank--3 { background: #f4ddcb; color: #85512a; }
@media (prefers-color-scheme: dark) {
  .rank--1 { background: #40320f; color: #f0c465; }
  .rank--2 { background: #2c3543; color: #b9c5d6; }
  .rank--3 { background: #3d2b1c; color: #dda06a; }
}

/* ---- カードの登場 ---- */

.reveal { opacity: 0; transform: translateY(10px); animation: reveal .5s cubic-bezier(.22, .8, .3, 1) forwards; }
.reveal:nth-child(1) { animation-delay: .02s; }
.reveal:nth-child(2) { animation-delay: .07s; }
.reveal:nth-child(3) { animation-delay: .12s; }
.reveal:nth-child(4) { animation-delay: .17s; }
.reveal:nth-child(5) { animation-delay: .22s; }
@keyframes reveal { to { opacity: 1; transform: translateY(0); } }

/* ---- 表を見やすく ---- */

table.data tbody tr { transition: background .12s; }
table.data tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
table.data tbody tr:hover { background: var(--accent-soft); }

/* 進捗を示す細い帯 */
.mini-bar { height: 5px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; margin-top: 6px; }
.mini-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--tone, var(--accent)); }

/* サイドメニューの現在地を目立たせる */
.side__link { position: relative; }
.side__link.is-active::before {
  content: "";
  position: absolute;
  left: -10px; top: 50%;
  width: 3px; height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
  transform: translateY(-50%);
}

@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; transform: none; }
  .bar__fill { transition: none; }
  .stat:hover { transform: none; }
}

/* ---- 台帳から書類をダウンロードするボタン ---- */

td.docs { white-space: nowrap; }
.doc {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  padding: 0 7px;
  margin-right: 4px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: transform .12s, filter .12s;
}
.doc:hover { text-decoration: none; transform: translateY(-1px); filter: brightness(1.06); }
.doc--invoice { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.doc--contract { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.doc--zip { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }

/* ---- 一括ダウンロードの選択バー ---- */

.selbar {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  transform: translate(-50%, 20px);
  opacity: 0;
  transition: transform .18s cubic-bezier(.22,.8,.3,1), opacity .18s;
}
.selbar.is-shown { transform: translate(-50%, 0); opacity: 1; }
.selbar__count { font-size: 13px; color: var(--text-soft); padding-left: 6px; }
.selbar__count b { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }

/* 行の選択が分かるようにする */
table.data tbody tr.is-selected { background: var(--accent-soft); }
table.data input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .selbar { transition: none; }
}

/* ---- 絞り込み結果をまとめて選ぶときの案内 ---- */

.allnote {
  padding: 9px 18px;
  font-size: 13px;
  color: var(--accent);
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line);
}
.allnote b { font-variant-numeric: tabular-nums; }
.linklike {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
}
.linklike:hover { opacity: .8; }

/* ---- 確認状態の切り替えボタン ---- */

.statusbtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  background: var(--bg-soft);
  color: var(--text-soft);
  border: 1px solid var(--line-strong);
  transition: background .13s, color .13s, border-color .13s, transform .1s;
}
.statusbtn:hover { border-color: var(--ok); color: var(--ok); background: var(--ok-soft); }
.statusbtn:active { transform: scale(.96); }
.statusbtn__mark { font-size: 12px; line-height: 1; }
.statusbtn.is-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.statusbtn.is-confirmed { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.statusbtn.is-confirmed:hover { background: var(--bg-soft); color: var(--text-soft); border-color: var(--line-strong); }
.statusbtn.is-busy { opacity: .5; pointer-events: none; }

/* 確認済みにした瞬間に光らせる */
.statusbtn.is-flash { animation: statusflash .55s ease-out; }
@keyframes statusflash {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  100% { box-shadow: 0 0 0 12px transparent; }
}

.btn--ok { background: var(--ok); }
.btn--ok:hover { background: color-mix(in srgb, var(--ok) 82%, #000); }

@media (prefers-reduced-motion: reduce) {
  .statusbtn.is-flash { animation: none; }
}

/* ---- 台帳の修正画面（左：入力／右：書類） ---- */

.editlayout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 1200px) {
  .editlayout { grid-template-columns: 1fr; }
  .viewer { position: static !important; height: 70vh; }
}

.formgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 14px;
}
.formgrid .field { margin-bottom: 0; }
.formgrid .field--wide { grid-column: 1 / -1; }
.input--num { text-align: right; font-variant-numeric: tabular-nums; }

.calcgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; }
.calcgrid > div { display: grid; gap: 2px; }
.calcgrid span { font-size: 12px; color: var(--text-soft); }
.calcgrid b { font-size: 18px; font-variant-numeric: tabular-nums; }
.calcgrid__total { color: var(--accent); }

/* 書類のビューア。スクロールしても付いてくる。 */
.viewer {
  position: sticky;
  top: 78px;
  height: calc(100dvh - 110px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.viewer__tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.viewer__tab {
  padding: 5px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-soft);
  background: transparent;
  border: 1px solid transparent;
}
.viewer__tab:hover { background: var(--bg-soft); }
.viewer__tab.is-active { background: var(--accent); color: #fff; }
.viewer__open { margin-left: auto; font-size: 12px; }
.viewer__frame { flex: 1; width: 100%; border: 0; background: var(--bg-soft); }
.doc--edit { background: var(--bg-soft); color: var(--text-soft); border-color: var(--line-strong); }

/* ---- シート選択のボタン列 ---- */

.sheetpick__label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 8px;
}
.sheetpick__count {
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--text-faint);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: background .13s, color .13s, border-color .13s;
}
.chip:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.chip.is-active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }

/* シートの中身は行が多いので詰めて表示する */
.sheetview { max-height: 70vh; overflow: auto; }
table.data--compact th, table.data--compact td { padding: 5px 9px; font-size: 12.5px; }
td.rownum, th.rownum {
  position: sticky; left: 0;
  width: 46px;
  text-align: right;
  color: var(--text-faint);
  background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}
table.data--compact tbody tr:hover td.rownum { background: var(--accent-soft); }

/* ---- ファイルの種類を示す小さな印 ---- */

.filemark {
  display: inline-grid;
  place-items: center;
  width: 20px; height: 20px;
  margin-right: 6px;
  border-radius: 5px;
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: -4px;
  color: #fff;
  background: #1d7044;              /* Excel */
}
.filemark--pdf { background: #b3261e; }  /* PDF */

/* ---- メーカー別サマリー ---- */

.makerlayout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 1100px) {
  .makerlayout { grid-template-columns: 1fr; }
}

.makerlist { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow-y: auto; }
.makerlist__item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  transition: background .12s;
}
.makerlist__item:hover { background: var(--surface-2); text-decoration: none; }
.makerlist__item.is-active { background: var(--accent-soft); }
.makerlist__item.is-active .makerlist__name { color: var(--accent); font-weight: 700; }
.makerlist__name { font-size: 13px; line-height: 1.4; }
.makerlist__amount { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.makerlist__count { grid-column: 1 / -1; font-size: 11.5px; color: var(--text-faint); }
