/* シェアハウスアプリ スタイル
 * - モバイルファースト
 * - 多言語対応（ネパール語含む）
 * - シンプル＆視認性重視
 */

/* ============ Reset & Variables ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  --c-primary: #264653;
  --c-primary-light: #2a6072;
  --c-accent: #e76f51;
  --c-good: #2a9d8f;
  --c-warn: #e9c46a;
  --c-bad: #e76f51;
  --c-critical: #c1272d;
  --c-electric: #f4a261;
  --c-gas: #e76f51;
  --c-water: #2a9d8f;
  --c-bg: #f7f7f5;
  --c-card: #ffffff;
  --c-text: #1f2a30;
  --c-text-sub: #6b7780;
  --c-border: #e5e7eb;
  --c-muted: #9ca3af;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 8px rgba(38, 70, 83, 0.08);
  --shadow-strong: 0 6px 24px rgba(38, 70, 83, 0.16);
  --font: 'Hiragino Sans', 'Meiryo', 'Noto Sans CJK JP', 'Noto Sans Devanagari', 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --header-h: 56px;
  --nav-h: 64px;
}

body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  min-height: 100vh;
  font-size: 15px;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* ============ Login Screen ============ */
#login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--c-primary) 0%, var(--c-primary-light) 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-strong);
}

.login-title {
  font-size: 24px;
  margin: 0 0 4px;
  text-align: center;
  color: var(--c-primary);
}

.login-tagline {
  text-align: center;
  color: var(--c-text-sub);
  margin: 0 0 24px;
  font-size: 13px;
}

.login-tabs {
  display: flex;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 20px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  background: none;
  border-bottom: 2px solid transparent;
  color: var(--c-text-sub);
  font-size: 14px;
  transition: all 0.15s;
}

.tab-btn.active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
  font-weight: 600;
}

.login-error {
  margin-top: 12px;
  padding: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  color: var(--c-critical);
  font-size: 13px;
}

/* ============ Form Elements ============ */
.form-label {
  display: block;
  font-size: 13px;
  color: var(--c-text-sub);
  margin: 12px 0 4px;
  font-weight: 500;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--c-text);
  transition: border 0.15s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(38, 70, 83, 0.1);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.btn-primary {
  background: var(--c-primary);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  width: 100%;
  margin-top: 16px;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--c-primary-light); }

.btn-secondary {
  background: var(--c-bg);
  color: var(--c-primary);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  font-weight: 500;
  margin-right: 8px;
}

.btn-danger {
  background: var(--c-critical);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.btn-link {
  background: none;
  color: var(--c-primary-light);
  text-decoration: underline;
  padding: 8px;
  margin-top: 8px;
  font-size: 13px;
  width: 100%;
  text-align: center;
}

.btn-icon {
  background: rgba(255,255,255,0.15);
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.btn-icon:hover { background: rgba(255,255,255,0.25); }

/* ============ App Shell ============ */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--c-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 10px; }
.header-title { font-size: 16px; font-weight: 600; }

.lang-switch {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.lang-switch option { color: var(--c-text); }

.user-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
}

.app-main {
  padding: 16px 16px calc(var(--nav-h) + 24px);
  max-width: 760px;
  margin: 0 auto;
}

.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: white;
  border-top: 1px solid var(--c-border);
  display: flex;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  padding: 6px 4px;
  color: var(--c-text-sub);
  font-size: 11px;
  transition: color 0.15s;
}

.nav-btn .nav-icon { font-size: 20px; }
.nav-btn.active { color: var(--c-primary); font-weight: 600; }

/* ============ Page Header ============ */
.page-header {
  margin: 4px 0 16px;
}

.page-header h1 {
  font-size: 22px;
  margin: 0;
  color: var(--c-primary);
}

.page-subtitle {
  color: var(--c-text-sub);
  font-size: 13px;
  margin: 4px 0 0;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-text-sub);
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.subhead {
  font-size: 14px;
  color: var(--c-text-sub);
  margin: 24px 0 8px;
}

/* ============ Hero (Dashboard top) — コンパクト版 ============ */
.hero {
  background: linear-gradient(135deg, var(--c-primary), var(--c-primary-light));
  color: white;
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.hero.over,
.hero.critical { background: linear-gradient(135deg, var(--c-critical), var(--c-bad)); }
.hero.warn { background: linear-gradient(135deg, #d97706, var(--c-warn)); }
.hero.good { background: linear-gradient(135deg, var(--c-good), #4abdab); }

.hero-compact .hero-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.hero-month-label {
  display: flex;
  flex-direction: column;
}

.hero-month {
  font-size: 12px;
  opacity: 0.85;
  font-weight: 500;
}

.hero-title-inline {
  font-size: 11px;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.2);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.status-pill .pill-icon {
  width: 14px;
  height: 14px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  font-size: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.hero-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.hero-main-amount {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.amount-number {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.amount-unit {
  font-size: 14px;
  opacity: 0.9;
}

.hero-main-pp {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.2;
}

.pp-label {
  font-size: 10px;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pp-value {
  font-size: 18px;
  font-weight: 700;
}

.pp-value small {
  font-size: 11px;
  font-weight: 500;
  opacity: 0.85;
  margin-left: 2px;
}

.pp-budget {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 1px;
}

/* 予算バー（コンパクト） */
.budget-bar-wrap {
  margin: 6px 0 0;
}

.budget-bar {
  position: relative;
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
  overflow: hidden;
}

.budget-bar-fill {
  height: 100%;
  background: white;
  transition: width 0.5s ease;
}

.budget-bar-fill.good,
.budget-bar-fill.ok { background: rgba(255,255,255,0.9); }

.budget-bar-marker {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: rgba(255,255,255,0.7);
}

.budget-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  opacity: 0.7;
  margin-top: 3px;
}

/* 判定バッジ（カード化、ヒーロー外） */
.verdict {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--c-card);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--c-good);
}

.verdict.bad { border-left-color: var(--c-bad); }

.verdict-icon {
  font-size: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
  color: white;
}

.verdict.good .verdict-icon { background: var(--c-good); }
.verdict.bad .verdict-icon { background: var(--c-bad); }

.verdict strong { display: block; font-size: 14px; color: var(--c-text); }
.verdict small { display: block; font-size: 12px; color: var(--c-text-sub); margin-top: 2px; }

/* ============ Card ============ */
.card {
  background: var(--c-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

/* ============ Compare (Last month vs Current) ============ */
.compare-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

.compare-col {
  text-align: center;
  padding: 10px;
  background: var(--c-bg);
  border-radius: var(--radius-sm);
}

.compare-col.current {
  background: rgba(38, 70, 83, 0.06);
}

.compare-label {
  font-size: 11px;
  color: var(--c-text-sub);
  text-transform: uppercase;
}

.compare-value {
  font-size: 18px;
  font-weight: 700;
  margin-top: 2px;
}

.compare-value small { font-size: 12px; opacity: 0.7; margin-left: 2px; }

.compare-arrow {
  text-align: center;
  font-size: 12px;
  color: var(--c-text-sub);
}

.compare-arrow .arrow-icon {
  font-size: 24px;
  display: block;
}

.compare-arrow.up .arrow-icon { color: var(--c-critical); }
.compare-arrow.down .arrow-icon { color: var(--c-good); }
.compare-arrow.stable .arrow-icon { color: var(--c-text-sub); }

.compare-arrow .arrow-label { display: block; font-weight: 600; }
.compare-arrow small { display: block; opacity: 0.7; }

/* ============ Breakdown ============ */
.breakdown { display: flex; flex-direction: column; gap: 12px; }

.breakdown-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 12px;
}

.breakdown-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.breakdown-icon { font-size: 18px; }
.breakdown-label { flex: 1; font-weight: 500; }
.breakdown-amount { font-weight: 700; color: var(--c-text); }

.breakdown-bar {
  grid-column: 1;
  height: 8px;
  background: var(--c-bg);
  border-radius: 4px;
  overflow: hidden;
}

.breakdown-bar-fill {
  height: 100%;
  transition: width 0.5s ease;
}

.breakdown-bar-fill.electric { background: var(--c-electric); }
.breakdown-bar-fill.gas { background: var(--c-gas); }
.breakdown-bar-fill.water { background: var(--c-water); }

.breakdown-pct {
  grid-column: 2;
  font-size: 12px;
  color: var(--c-text-sub);
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}

/* ============ Chart ============ */
.chart-container {
  position: relative;
  height: 260px;
  margin-top: 8px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--c-text-sub);
  justify-content: center;
}

.legend-item { display: inline-flex; align-items: center; gap: 4px; }

.dot { width: 10px; height: 10px; border-radius: 2px; }
.dot-electric { background: var(--c-electric); }
.dot-gas { background: var(--c-gas); }
.dot-water { background: var(--c-water); }
.dot-budget { background: var(--c-primary); border: 1px dashed white; }

/* ============ Explain Card ============ */
.explain-card {
  background: rgba(38, 70, 83, 0.05);
  border-left: 4px solid var(--c-primary);
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.explain-card h3 {
  margin: 0 0 8px;
  color: var(--c-primary);
  font-size: 15px;
}

.explain-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--c-text);
}

.seasonal-alert {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(231, 196, 106, 0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  border-left: 3px solid var(--c-warn);
}

/* ============ Tips Page ============ */
.tip-section { margin-bottom: 24px; }

.tip-section-title {
  font-size: 16px;
  margin: 0 0 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: white;
}

.tip-section-title.electric { background: var(--c-electric); }
.tip-section-title.gas { background: var(--c-gas); }
.tip-section-title.water { background: var(--c-water); }

.tip-list { display: flex; flex-direction: column; gap: 10px; }

.tip-card {
  display: flex;
  gap: 12px;
  background: var(--c-card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.tip-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
  border-radius: 50%;
}

.tip-body { flex: 1; min-width: 0; }
.tip-title { font-size: 15px; margin: 0 0 4px; font-weight: 600; }
.tip-desc { font-size: 13px; color: var(--c-text-sub); margin: 0 0 8px; line-height: 1.6; }

.tip-save {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(42, 157, 143, 0.1);
  color: var(--c-good);
  border-radius: 12px;
  font-size: 12px;
}

.tip-save-value { font-weight: 700; }
.tip-save-value small { font-weight: 400; opacity: 0.8; }

/* ============ Announcements ============ */
.announcement-list { display: flex; flex-direction: column; gap: 10px; }

.ann-card {
  background: var(--c-card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--c-primary);
}

.ann-card.is-unread { border-left-color: var(--c-accent); background: #fffbf7; }
.ann-card.type-support { border-left-color: #db2777; }
.ann-card.type-event { border-left-color: #f59e0b; }
.ann-card.type-construction { border-left-color: #6b7280; }
.ann-card.type-inspection { border-left-color: #0ea5e9; }

.ann-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--c-text-sub);
  margin-bottom: 8px;
}

.ann-type { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }

.ann-title { font-size: 16px; margin: 0 0 6px; }
.ann-body { font-size: 14px; line-height: 1.6; margin: 0 0 8px; color: var(--c-text); }

.ann-scheduled {
  display: inline-block;
  background: rgba(38, 70, 83, 0.08);
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--c-primary);
  margin-bottom: 8px;
}

.ann-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--c-border);
}

.btn-read {
  background: var(--c-primary);
  color: white;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
}

.ann-read-badge {
  background: rgba(42, 157, 143, 0.15);
  color: var(--c-good);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.read-count { font-size: 11px; color: var(--c-text-sub); }
.btn-delete { font-size: 14px; padding: 2px 6px; opacity: 0.6; }

/* ============ Bike ============ */
.etiquette-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: rgba(244, 162, 97, 0.12);
  border-left: 4px solid var(--c-electric);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
}

.etiquette-icon { font-size: 20px; }

.usage-list { display: flex; flex-direction: column; gap: 6px; }

.usage-row {
  display: grid;
  grid-template-columns: 110px 1fr 60px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.usage-name { font-weight: 600; }
.usage-bar {
  height: 8px;
  background: var(--c-bg);
  border-radius: 4px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  background: var(--c-primary);
}

.usage-days { text-align: right; color: var(--c-text-sub); font-weight: 600; }

.bike-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.bike-day {
  background: var(--c-bg);
  border-radius: var(--radius-sm);
  padding: 6px 4px;
  min-height: 70px;
  display: flex;
  flex-direction: column;
  font-size: 11px;
}

.bike-day.weekend { background: rgba(38, 70, 83, 0.04); }
.bike-day.today { box-shadow: 0 0 0 2px var(--c-primary); }
.bike-day.reserved { background: rgba(231, 111, 81, 0.08); }
.bike-day.mine { background: rgba(42, 157, 143, 0.15); }

.bike-day-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 4px;
}

.bike-day-num { font-weight: 700; font-size: 14px; }
.bike-day-dow { color: var(--c-text-sub); }

.bike-day-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.bike-reserved-by {
  font-size: 10px;
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-word;
}

.btn-mini {
  padding: 4px;
  border-radius: 4px;
  font-size: 10px;
  width: 100%;
  font-weight: 600;
}

.btn-mini.reserve { background: var(--c-primary); color: white; }
.btn-mini.cancel { background: var(--c-bad); color: white; }

/* ============ Admin ============ */
.admin-tabs {
  display: flex;
  overflow-x: auto;
  border-bottom: 1px solid var(--c-border);
  margin-bottom: 16px;
  gap: 4px;
}

.admin-tab-btn {
  padding: 10px 14px;
  background: none;
  color: var(--c-text-sub);
  font-size: 13px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.admin-tab-btn.active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
  font-weight: 600;
}

.admin-section { margin-bottom: 24px; }

.form-grid {
  display: flex;
  flex-direction: column;
}

.form-total {
  background: var(--c-bg);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin: 12px 0;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-total strong { font-size: 18px; color: var(--c-primary); }

.form-feedback {
  background: rgba(42, 157, 143, 0.15);
  color: var(--c-good);
  padding: 10px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  font-size: 13px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--c-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 13px;
}

.data-table th {
  background: var(--c-bg);
  padding: 8px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--c-text-sub);
}

.data-table td {
  padding: 8px;
  border-top: 1px solid var(--c-border);
}

.settings-block {
  background: var(--c-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.settings-block h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--c-primary);
}

/* ============ Misc ============ */
.empty, .muted {
  text-align: center;
  color: var(--c-muted);
  padding: 20px;
  font-size: 14px;
}

.error {
  background: #fee;
  color: #c00;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.fatal-error {
  padding: 40px 20px;
  text-align: center;
  color: var(--c-critical);
}

/* ============ Responsive ============ */
@media (min-width: 600px) {
  .form-grid {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 16px;
    align-items: center;
  }
  .form-grid .form-label { margin: 0; }
  .form-grid .btn-primary,
  .form-grid .form-total,
  .form-grid .form-feedback,
  .form-grid textarea { grid-column: 1 / -1; }
  .form-grid input,
  .form-grid select { margin: 4px 0; }
}

@media (min-width: 900px) {
  .app-main { padding-bottom: 24px; }
  .app-nav {
    position: sticky;
    top: var(--header-h);
    bottom: auto;
    border-top: none;
    border-bottom: 1px solid var(--c-border);
    max-width: 760px;
    margin: 0 auto;
    height: 48px;
  }
}

/* Nepali script needs slightly larger size for legibility */
html[lang="ne"] body {
  font-size: 15.5px;
  line-height: 1.65;
}

html[lang="ne"] .amount-number {
  font-size: 36px;
}
