/* ============================================================
   Design System — Timee / Sharefull インスパイア
   Light theme / Green primary / Shadow cards
   ============================================================ */
:root {
  /* Brand */
  --primary:       #059669;   /* emerald-600 — 収益・緑 */
  --primary-dark:  #047857;   /* emerald-700 */
  --primary-light: #D1FAE5;   /* emerald-100 */
  --primary-mid:   #6EE7B7;   /* emerald-300 */

  /* Background */
  --bg:            #F0FDF4;   /* emerald-50 — 薄緑ベース */
  --bg-card:       #FFFFFF;
  --bg-input:      #F8FAF9;
  --bg-input-focus:#ECFDF5;   /* emerald-50 */

  /* Text */
  --text:          #111827;   /* gray-900 */
  --text-sub:      #374151;   /* gray-700 */
  --text-muted:    #6B7280;   /* gray-500 */
  --text-placeholder: #9CA3AF; /* gray-400 */

  /* Border */
  --border:        #E5E7EB;   /* gray-200 */
  --border-focus:  var(--primary);

  /* Semantic colours */
  --green:         #16A34A;
  --green-bg:      #F0FDF4;
  --green-border:  #86EFAC;
  --yellow:        #D97706;
  --yellow-bg:     #FFFBEB;
  --yellow-border: #FCD34D;
  --red:           #DC2626;
  --red-bg:        #FEF2F2;
  --red-border:    #FCA5A5;

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.1),  0 4px 10px rgba(0,0,0,0.05);

  /* Shape */
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm:  8px;
  --radius-xs:  6px;

  /* Layout */
  --tab-h:    62px;
  --header-h: 56px;
  --safe-b:   env(safe-area-inset-bottom, 0px);
  --safe-t:   env(safe-area-inset-top,    0px);
}

/* ============================================================
   Reset / Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html, body {
  height: 100%;
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans',
               'Yu Gothic', 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
input, button { font-family: inherit; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; }

/* ============================================================
   App Shell
   ============================================================ */
#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
}

/* ── Header ── */
#app-header {
  flex-shrink: 0;
  height: var(--header-h);
  padding-top: var(--safe-t);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  user-select: none;
}
.header-logo { font-size: 1.3rem; }
.header-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.04em;
}

/* ── Main ── */
#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

/* ── Tabs ── */
.tab {
  display: none;
  padding: 14px 14px calc(var(--tab-h) + var(--safe-b) + 16px);
}
.tab.active { display: block; }

/* ── Tab Bar ── */
#tab-bar {
  flex-shrink: 0;
  display: flex;
  height: calc(var(--tab-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  transition: color 0.15s;
}
.tab-btn.active { color: var(--primary); }

.tab-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 28px;
  border-radius: 14px;
  transition: background 0.2s;
}
.tab-btn.active .tab-icon-wrap {
  background: var(--primary-light);
}
.tab-icon  { font-size: 1.2rem; line-height: 1; }
.tab-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--primary);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 800;
  border-radius: 99px;
  min-width: 15px;
  height: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 1.5px solid var(--bg-card);
}

/* ============================================================
   Card
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.03);
}
.card-heading {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
}
.count-note {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}
.hint-text {
  font-size: 0.78rem;
  color: var(--text-placeholder);
}

/* ============================================================
   Input Rows
   ============================================================ */
.input-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 0;
}
.input-row + .input-row {
  border-top: 1px solid var(--border);
}
.input-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-sub);
  flex-shrink: 0;
  min-width: 88px;
  user-select: none;
}
.label-icon {
  font-size: 0.95rem;
  width: 22px;         /* 固定幅でアイコン描画幅の差を吸収 */
  min-width: 22px;
  flex-shrink: 0;
  text-align: center;
  /* flex item として block 表示を強制 */
  display: block;
}

.input-right {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.input-row input[type=number],
.input-row input[type=text] {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  padding: 8px 10px;
  text-align: right;
  width: 80px;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.input-row input:focus {
  border-color: var(--primary);
  background: var(--bg-input-focus);
  box-shadow: 0 0 0 3px rgba(5,150,105,0.12);
}
.unit {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  width: 16px;
  flex-shrink: 0;
}

/* ── クイックボタン下段行 ── */
.qrow {
  display: flex;
  justify-content: flex-end;
  padding: 6px 0 4px;
  border-top: 1px solid var(--border);
  margin-top: -1px; /* input-rowのボーダーと重ねる */
}
/* qrow の下のinput-rowはボーダーを出さない */
.qrow + .input-row {
  border-top: 1px solid var(--border);
}

/* ── Quick Buttons ── */
.qgroup { display: flex; gap: 4px; }
.qbtn {
  background: #F3F4F6;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 8px;
  cursor: pointer;
  transition: all 0.12s;
  line-height: 1;
  white-space: nowrap;
}
.qbtn:active,
.qbtn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5,150,105,0.3);
}

/* ── Site Quick Buttons ── */
.site-qbtn {
  background: #F3F4F6;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text-sub);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.site-qbtn:active,
.site-qbtn.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5,150,105,0.3);
}

/* ============================================================
   Result Card — KPI メイン表示
   ============================================================ */
.result-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 22px 20px 18px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-md);
  border: 1.5px solid var(--border);
  text-align: center;
  transition: background 0.35s, border-color 0.35s, box-shadow 0.35s;
}

/* 状態別スタイル */
.result-card.state-good {
  background: linear-gradient(150deg, #F0FDF4 0%, #DCFCE7 100%);
  border-color: var(--green-border);
  box-shadow: 0 6px 24px rgba(22,163,74,0.12), 0 2px 8px rgba(22,163,74,0.08);
}
.result-card.state-warn {
  background: linear-gradient(150deg, #FFFBEB 0%, #FEF3C7 100%);
  border-color: var(--yellow-border);
  box-shadow: 0 6px 24px rgba(217,119,6,0.12), 0 2px 8px rgba(217,119,6,0.08);
}
.result-card.state-bad {
  background: linear-gradient(150deg, #FEF2F2 0%, #FEE2E2 100%);
  border-color: var(--red-border);
  box-shadow: 0 6px 24px rgba(220,38,38,0.12), 0 2px 8px rgba(220,38,38,0.08);
}

/* 状態バッジ */
.res-state-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 20px;
  padding: 4px 12px;
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}
.badge-good { background: var(--primary-light); color: var(--primary-dark); }
.badge-warn { background: #FEF3C7; color: #92400E; }
.badge-bad  { background: #FEE2E2; color: #991B1B; }

.result-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

/* 大きな時給表示 */
.result-value-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  margin-bottom: 16px;
  line-height: 1;
}
.result-main {
  font-size: 3.8rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--text);
  transition: color 0.3s;
}
.result-card.state-good .result-main { color: var(--green); }
.result-card.state-warn .result-main { color: var(--yellow); }
.result-card.state-bad  .result-main { color: var(--red); }

.result-unit {
  font-size: 1rem;
  color: var(--text-muted);
  font-weight: 600;
  padding-bottom: 10px;
}

/* サブ指標 */
.result-subs {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  background: rgba(0,0,0,0.03);
  border-radius: var(--radius-md);
  padding: 10px 0;
}
.result-sub {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.result-sep {
  width: 1px;
  height: 32px;
  background: rgba(0,0,0,0.1);
  margin: 0 10px;
}
.sub-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sub-val {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-sub);
}

/* 実質率バー */
.wage-bar-wrap { margin-top: 2px; }
.wage-bar-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 7px;
  align-items: center;
}
.bar-meta-left { font-weight: 500; }
.bar-meta-left b { color: var(--text-sub); }
.res-diff { font-weight: 800; font-size: 0.82rem; }
.res-diff.negative { color: var(--red); }
.res-diff.positive { color: var(--green); }

.bar-track {
  background: rgba(0,0,0,0.07);
  border-radius: 99px;
  height: 7px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--green);
  transition: width 0.5s cubic-bezier(.4,0,.2,1), background 0.3s;
  width: 0%;
}
.bar-fill.bar-warn { background: var(--yellow); }
.bar-fill.bar-bad  { background: var(--red); }

.bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.58rem;
  color: var(--text-placeholder);
  margin-top: 4px;
  padding: 0 2px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-cta {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-lg);
  padding: 16px;
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px rgba(5,150,105,0.35);
  transition: opacity 0.12s, transform 0.1s, box-shadow 0.15s;
}
.btn-cta:hover  { box-shadow: 0 6px 18px rgba(5,150,105,0.4); }
.btn-cta:active { opacity: 0.88; transform: scale(0.98); box-shadow: none; }

.btn-primary {
  display: block;
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(5,150,105,0.25);
  transition: opacity 0.12s, transform 0.1s;
}
.btn-primary:active { opacity: 0.85; transform: scale(0.98); }

/* ============================================================
   Compare Cards
   ============================================================ */
.compare-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.04);
  border-top: 4px solid var(--border);  /* overridden per rank */
}
.rank-1 { border-top-color: #F59E0B; }  /* gold */
.rank-2 { border-top-color: #94A3B8; }  /* silver */
.rank-3 { border-top-color: #B45309; }  /* bronze */

.ccard-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.rank-badge {
  font-size: 0.68rem;
  font-weight: 800;
  color: #000;
  border-radius: var(--radius-xs);
  padding: 3px 10px;
  flex-shrink: 0;
}
.ccard-name-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 5px 8px;
  outline: none;
  transition: border-color 0.15s;
}
.ccard-name-input:focus { border-color: var(--primary); }

.ccard-del-btn {
  background: #F3F4F6;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1rem;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.12s;
}
.ccard-del-btn:active { background: var(--red-bg); color: var(--red); }

.ccard-wage {
  text-align: center;
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  margin: 4px 0 10px;
  line-height: 1;
}
.ccard-wage-unit {
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text-muted);
}

.ccard-bar-track {
  background: rgba(0,0,0,0.07);
  border-radius: 99px;
  height: 5px;
  overflow: hidden;
  margin-bottom: 14px;
}
.ccard-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
}

.ccard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  background: rgba(0,0,0,0.02);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.ccard-item { display: flex; flex-direction: column; gap: 2px; }
.ccard-item-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.ccard-item-val {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-sub);
}

/* ============================================================
   Site Cards
   ============================================================ */
.site-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.site-card-info { flex: 1; min-width: 0; }
.site-card-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.site-card-detail {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.site-card-actions { display: flex; gap: 7px; flex-shrink: 0; }

.site-use-btn {
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 7px 14px;
  cursor: pointer;
  transition: opacity 0.12s;
}
.site-use-btn:active { opacity: 0.8; }

.site-del-btn {
  background: #F3F4F6;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.site-del-btn:active { background: var(--red-bg); color: var(--red); }

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  gap: 6px;
}
.empty-icon { font-size: 2.8rem; opacity: 0.4; margin-bottom: 6px; }
.empty-sub  { font-size: 0.78rem; opacity: 0.65; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  bottom: calc(var(--tab-h) + var(--safe-b) + 14px);
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: #1F2937;
  color: #fff;
  font-size: 0.83rem;
  font-weight: 500;
  padding: 11px 22px;
  border-radius: 99px;
  white-space: nowrap;
  max-width: calc(100vw - 40px);
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity 0.22s, transform 0.22s;
  pointer-events: none;
  z-index: 999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Scrollbar (subtle)
   ============================================================ */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ============================================================
   Utility helpers
   ============================================================ */
.hidden { display: none !important; }

/* ── month / date inputs ── */
.input-row input[type=month],
.input-row input[type=date] {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  width: 150px;
  text-align: left;
}
.input-row input[type=month]:focus,
.input-row input[type=date]:focus {
  border-color: var(--primary);
  background: var(--bg-input-focus);
}

/* ── Enhanced site card layout ── */
.site-card-enhanced { align-items: flex-start; }
.site-card-rating   { display: flex; gap: 2px; margin-top: 3px; }
.site-star          { color: #D1D5DB; font-size: 0.82rem; line-height: 1; }
.site-star.filled   { color: #F59E0B; }
.site-card-industry {
  font-size: 0.68rem;
  color: var(--primary);
  font-weight: 700;
  margin-top: 2px;
  letter-spacing: 0.02em;
}
.site-card-memo {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

/* ── Star rating widget (in site form) ── */
.star-rating { display: flex; gap: 4px; align-items: center; }
.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  padding: 2px;
  line-height: 1;
  color: #D1D5DB;
  transition: color 0.1s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.star-btn.active { color: #F59E0B; }
.star-btn:active { transform: scale(1.25); }

/* ── Industry select ── */
.industry-select {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 8px 30px 8px 10px;
  outline: none;
  transition: border-color 0.15s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%236B7280' d='M5 7l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  width: 100%;
  max-width: 200px;
}
.industry-select:focus { border-color: var(--primary); }

/* ── Memo textarea ── */
.memo-textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 8px 10px;
  outline: none;
  resize: none;
  height: 60px;
  line-height: 1.5;
  transition: border-color 0.15s;
  font-family: inherit;
}
.memo-textarea:focus { border-color: var(--primary); }

/* ── Sort toggle buttons ── */
.sort-toggle { display: flex; gap: 6px; margin-bottom: 10px; }
.sort-btn {
  background: #F3F4F6;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
  transition: all 0.12s;
}
.sort-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ============================================================
   Feature 1 — Income Dashboard
   ============================================================ */

/* ── App chip selector ── */
.app-chip-group { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.app-chip {
  background: #F3F4F6;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text-sub);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 7px 16px;
  cursor: pointer;
  transition: all 0.12s;
  white-space: nowrap;
}
.app-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(5,150,105,0.3);
}

/* ── 扶養バナー ── */
.fuyo-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 12px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 14px rgba(5,150,105,0.35);
}
.fuyo-banner-label {
  font-size: 0.68rem;
  font-weight: 700;
  opacity: 0.88;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.fuyo-banner-remaining {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 4px 0 2px;
}
.fuyo-banner-sub {
  font-size: 0.66rem;
  opacity: 0.78;
}
.fuyo-banner-gear {
  background: rgba(255,255,255,0.22);
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.fuyo-banner-gear:active { background: rgba(255,255,255,0.38); }

/* ── Chart ── */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 200px;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: var(--text-sub);
  font-weight: 600;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── Income record rows ── */
.income-record {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  gap: 10px;
}
.income-record:first-child { border-top: none; }
.income-record-left { flex: 1; min-width: 0; }
.income-record-app {
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 1px;
}
.income-record-date {
  font-size: 0.68rem;
  color: var(--text-muted);
}
.income-record-amount {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-sub);
  flex-shrink: 0;
}
.income-record-del {
  background: none;
  border: none;
  color: var(--text-placeholder);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.12s;
}
.income-record-del:active { color: var(--red); }

/* ── Settings overlay ── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.settings-sheet {
  background: var(--bg-card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 24px 20px calc(var(--safe-b) + 28px);
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}
.settings-sheet-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 16px;
  text-align: center;
}
.limit-option-group { display: flex; flex-direction: column; gap: 8px; }
.limit-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-sub);
  transition: all 0.12s;
}
.limit-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}
.limit-option-check { color: var(--primary); font-size: 1rem; font-weight: 800; }
.settings-custom-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}
.settings-custom-input {
  flex: 1;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}
.settings-custom-input::-webkit-outer-spin-button,
.settings-custom-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.settings-custom-input:focus { border-color: var(--primary); }

/* ============================================================
   Feature 2 — Company 28万 Counter
   ============================================================ */

.company-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.04);
}
.company-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}
.company-card-name {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text);
}
.company-card-del {
  background: #F3F4F6;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1rem;
  width: 32px;
  height: 32px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.12s;
}
.company-card-del:active { background: var(--red-bg); color: var(--red); }

.company-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
}
.company-progress-total {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--text);
}
.company-progress-limit {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}
.company-bar-track {
  background: rgba(0,0,0,0.07);
  border-radius: 99px;
  height: 9px;
  overflow: hidden;
  margin-bottom: 6px;
}
.company-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--green);
  transition: width 0.5s cubic-bezier(.4,0,.2,1), background 0.3s;
}
.company-bar-fill.bar-warn { background: var(--yellow); }
.company-bar-fill.bar-bad  { background: var(--red); }

.company-warn-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #FEF3C7;
  color: #92400E;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 12px;
  margin-bottom: 6px;
}
.company-over-badge {
  background: #FEE2E2;
  color: #991B1B;
}
.period-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 2px;
}

/* ── Entry list ── */
.entry-list { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 6px; }
.entry-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.8rem;
  color: var(--text-sub);
  border-top: 1px solid var(--border);
}
.entry-row:first-child { border-top: none; }
.entry-date { color: var(--text-muted); flex-shrink: 0; font-size: 0.75rem; }
.entry-amount { font-weight: 700; flex: 1; text-align: right; }
.entry-del {
  background: none;
  border: none;
  color: var(--text-placeholder);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.12s;
}
.entry-del:active { color: var(--red); }

/* ── Entry add form (inside company card) ── */
.entry-add-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 12px;
}
.entry-add-date,
.entry-add-amount {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 8px;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  -moz-appearance: textfield;
}
.entry-add-date::-webkit-outer-spin-button,
.entry-add-amount::-webkit-outer-spin-button,
.entry-add-date::-webkit-inner-spin-button,
.entry-add-amount::-webkit-inner-spin-button { -webkit-appearance: none; }
.entry-add-date:focus,
.entry-add-amount:focus { border-color: var(--primary); }
.entry-add-date   { flex: 1; min-width: 0; }
.entry-add-amount { width: 88px; text-align: right; }
.entry-add-btn {
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.12s;
}
.entry-add-btn:active { opacity: 0.8; }

/* ── Reset button ── */
.btn-reset {
  width: 100%;
  background: var(--red-bg);
  color: var(--red);
  border: 1.5px solid var(--red-border);
  border-radius: var(--radius-md);
  padding: 11px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
  transition: opacity 0.12s;
}
.btn-reset:active { opacity: 0.78; }

/* ============================================================
   App Footer
   ============================================================ */
.app-footer {
  text-align: center;
  padding: 20px 16px 6px;
  font-size: 0.68rem;
  color: var(--text-placeholder);
  line-height: 1.8;
}
.app-footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================
   Header terms link
   ============================================================ */
.header-terms-link {
  position: absolute;
  right: 16px;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: background 0.12s;
}
.header-terms-link:active { background: var(--border); }
#app-header { position: relative; }

/* ── workplace_id schema note (dev-only, not shown in UI) ──
   地域フィールドは .site-card-industry のスタイルを共用 */
#site-inp-region { width: 160px; text-align: left; }
