:root {
  --bg: #FFFFFF;
  --bg-subtle: #F7F7F5;
  --text: #37352F;
  --text-muted: #787774;
  --border: #E9E9E7;
  --accent: #2383E2;
  --accent-soft: #E7F3F8;
  --green: #0F7B6C;
  --green-soft: #DDEDEA;
  --red: #E03E3E;
  --red-soft: #FDEBEC;
  --orange: #D9730D;
  --orange-soft: #FAEBDD;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  --radius: 8px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.logo .mark { width: 20px; height: 20px; background: var(--text); border-radius: 5px; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 6px; padding: 7px 14px; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .12s;
}
.btn:hover { background: var(--bg-subtle); }
.btn.primary { background: var(--text); border-color: var(--text); color: #fff; }
.btn.primary:hover { background: #50483b; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { opacity: .9; }
.btn.large { padding: 10px 20px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 14px; font-family: inherit; color: var(--text); background: var(--bg);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft);
}
.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.badge.gray { background: var(--bg-subtle); color: var(--text-muted); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }

/* ---- 認証画面 ---- */
.auth-wrap { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg-subtle); }
.auth-card { background: var(--bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 36px; width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 20px; margin: 18px 0 4px; }
.auth-card .sub { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.auth-card .switch { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 18px; }
.auth-card .switch a { color: var(--accent); }
.error-box { background: var(--red-soft); color: var(--red); border-radius: 6px; padding: 10px 12px; font-size: 13px; margin-bottom: 16px; display: none; }

/* ---- アプリレイアウト ---- */
.layout { display: flex; height: 100vh; }
.sidebar {
  width: 240px; flex: none; background: var(--bg-subtle); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 10px;
}
.sidebar .logo { padding: 6px 10px 18px; }
.nav-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 6px;
  font-size: 14px; color: var(--text-muted); cursor: pointer; margin-bottom: 2px; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(0,0,0,.04); }
.nav-item.active { background: rgba(0,0,0,.06); color: var(--text); font-weight: 600; }
.sidebar .spacer { flex: 1; }
.user-box { border-top: 1px solid var(--border); padding: 12px 10px 4px; font-size: 13px; }
.user-box .name { font-weight: 600; }
.user-box .company { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }

.main { flex: 1; overflow-y: auto; }
.main-inner { max-width: 960px; margin: 0 auto; padding: 40px 40px 80px; }
.page-title { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.page-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); background: var(--bg); }
.card + .card { margin-top: 16px; }
.card .card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: space-between; }
.card .card-body { padding: 18px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px; text-align: center;
  color: var(--text-muted); font-size: 14px; cursor: pointer; transition: all .15s; background: var(--bg-subtle);
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.file-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.file-chip {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 12px; font-size: 13px; background: var(--bg);
}
.file-chip .size { color: var(--text-muted); font-size: 12px; }
.file-chip .rm { margin-left: auto; cursor: pointer; color: var(--text-muted); border: none; background: none; font-size: 15px; }
.file-chip .rm:hover { color: var(--red); }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 12px; color: var(--text-muted); font-weight: 600;
  padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover { background: var(--bg-subtle); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.empty { text-align: center; color: var(--text-muted); padding: 48px 20px; font-size: 14px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

.progress-box { text-align: center; padding: 48px 24px; }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.total-banner {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 22px; margin-bottom: 16px;
}
.total-banner .amount { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.total-banner .label { color: var(--text-muted); font-size: 13px; font-weight: 600; }

.section-title { font-size: 17px; font-weight: 700; margin: 28px 0 10px; }
.meta-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabbar button {
  border: none; background: none; padding: 8px 14px; font-size: 14px; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
}
.tabbar button.active { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar input[type="search"] {
  border: 1px solid var(--border); border-radius: 6px; padding: 7px 12px; font-size: 14px; width: 260px; font-family: inherit;
}
.toolbar input[type="search"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

@media (max-width: 760px) {
  .layout { flex-direction: column; height: auto; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px; }
  .sidebar .spacer, .user-box .company { display: none; }
  .user-box { border: none; padding: 0 10px; white-space: nowrap; }
  .main-inner { padding: 24px 18px 60px; }
  .form-grid { grid-template-columns: 1fr; }
}
