/* ========================================
   STAFIT 日報アプリ - スタイルシート
   スマホファースト設計
======================================== */

:root {
  --primary: #1a56db;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;
  --secondary: #6b7280;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f3f4f6;
  --card-bg: #ffffff;
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --header-height: 56px;
  --bottom-nav-height: 64px;
  --sidebar-width: 260px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ======== ユーティリティ ======== */
.hidden { display: none !important; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }
.font-semibold { font-weight: 600; }
.required { color: var(--danger); }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--danger); color: white;
  border-radius: 999px; min-width: 20px; height: 20px;
  font-size: 11px; font-weight: 700; padding: 0 5px;
  margin-left: 6px;
}

/* ======== ローディング ======== */
.loading-overlay {
  position: fixed; inset: 0; background: white;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 9999; gap: 16px;
}
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ======== ログイン ======== */
.login-container {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(135deg, #1e40af 0%, #1a56db 50%, #2563eb 100%);
}
.login-logo {
  text-align: center; margin-bottom: 32px; color: white;
}
.logo-icon {
  width: 72px; height: 72px; border-radius: 20px;
  background: rgba(255,255,255,0.15); backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: white; margin: 0 auto 16px;
  border: 1px solid rgba(255,255,255,0.2);
}
.login-logo h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.login-logo h1 span { color: #93c5fd; }
.login-logo p { color: rgba(255,255,255,0.7); font-size: 14px; }
.login-form {
  background: white; border-radius: 20px;
  padding: 28px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.input-password { position: relative; display: flex; }
.input-password input { flex: 1; }
.btn-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px;
}
.error-msg {
  background: #fef2f2; color: var(--danger);
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 14px; margin-bottom: 12px;
  border: 1px solid #fecaca;
}

/* ======== ユーザー選択ボタン ======== */
.user-select-btn {
  width: 100%; background: white; border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  text-align: left;
}
.user-select-btn:hover, .user-select-btn:active {
  border-color: var(--primary); background: var(--primary-light);
  transform: translateY(-1px); box-shadow: var(--shadow-md);
}
.user-select-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.user-select-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.user-select-avatar.admin-avatar {
  background: #fef3c7; color: #d97706;
}
.user-select-info { flex: 1; }
.user-select-name { font-size: 17px; font-weight: 700; color: var(--text); }
.user-select-role { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ======== ヘッダー ======== */
.app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-height); background: white;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; z-index: 100;
  box-shadow: var(--shadow);
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-title { font-size: 18px; font-weight: 700; color: var(--primary); }
.username-badge {
  font-size: 13px; color: var(--text-muted); font-weight: 500;
}
.btn-icon {
  width: 36px; height: 36px; border: none; background: none;
  cursor: pointer; color: var(--text-muted); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  transition: background 0.2s;
}
.btn-icon:hover { background: var(--bg); color: var(--primary); }

/* ======== サイドバー ======== */
.sidebar {
  position: fixed; top: 0; left: -var(--sidebar-width);
  width: var(--sidebar-width); height: 100vh;
  background: white; z-index: 200;
  transform: translateX(-260px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid var(--border);
  overflow-y: auto; padding-top: var(--header-height);
  box-shadow: var(--shadow-lg);
}
.sidebar.open { transform: translateX(0); }
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 150; backdrop-filter: blur(2px);
}
.sidebar-user {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px; border-bottom: 1px solid var(--border);
}
.user-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.sidebar-menu { list-style: none; padding: 8px 0; }
.sidebar-menu a {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px; color: var(--text); text-decoration: none;
  font-size: 15px; font-weight: 500; transition: background 0.15s;
  border-radius: 0;
}
.sidebar-menu a:hover, .sidebar-menu a.active {
  background: var(--primary-light); color: var(--primary);
}
.sidebar-menu i { width: 20px; text-align: center; font-size: 16px; }

/* ======== メインコンテンツ ======== */
.main-content {
  margin-top: var(--header-height);
  padding: 16px 16px calc(var(--bottom-nav-height) + 16px);
  min-height: calc(100vh - var(--header-height));
}
.page-section { display: block; }
.page-section.hidden { display: none !important; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.page-header h2 { font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.date-badge {
  font-size: 13px; color: var(--text-muted); font-weight: 500;
  background: var(--bg); padding: 4px 10px; border-radius: 999px;
}

/* ======== カード ======== */
.card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 12px;
  overflow: hidden;
}
.card-header {
  padding: 14px 16px; font-weight: 600; font-size: 15px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg);
  gap: 8px;
}
.card-header i { color: var(--primary); }
.card-body { padding: 16px; }
.card-expense .card-header { background: #fef9f0; border-bottom-color: #fed7aa; }
.card-expense .card-header i { color: #f59e0b; }

/* ======== フォーム ======== */
.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.form-row { display: flex; gap: 10px; }
.form-row.col-2 > * { flex: 1; }
.form-row.col-3 > * { flex: 1; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"],
input[type="month"], select, textarea {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; color: var(--text); background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}
textarea { resize: vertical; min-height: 80px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%236b7280'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* ======== ボタン ======== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover, .btn-primary:active { background: var(--primary-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: white; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; padding: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.form-actions {
  display: flex; gap: 12px; padding: 8px 0 0;
}
.form-actions .btn { flex: 1; justify-content: center; padding: 14px; font-size: 15px; }

/* ======== ボトムナビ ======== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-height); background: white;
  border-top: 1px solid var(--border);
  display: flex; z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}
.bottom-nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 3px;
  color: var(--text-muted); text-decoration: none;
  font-size: 10px; font-weight: 600; padding: 8px 4px;
  transition: color 0.2s; -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item i { font-size: 22px; transition: transform 0.2s; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item.active i { transform: scale(1.1); }

/* ======== 日報カード ======== */
.report-card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 10px;
  padding: 14px 16px; cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
  border-left: 4px solid transparent;
}
.report-card:active { transform: scale(0.99); }
.report-card:hover { box-shadow: var(--shadow-md); }
.report-card.status-draft { border-left-color: var(--secondary); }
.report-card.status-submitted { border-left-color: var(--warning); }
.report-card.status-approved { border-left-color: var(--success); }
.report-card.status-rejected { border-left-color: var(--danger); }

.report-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.report-card-date { font-weight: 700; font-size: 16px; }
.report-card-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; color: var(--text-muted); }
.report-card-meta span { display: flex; align-items: center; gap: 4px; }

.status-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.status-draft { background: #f3f4f6; color: #6b7280; }
.status-submitted { background: #fef3c7; color: #d97706; }
.status-approved { background: #d1fae5; color: #059669; }
.status-rejected { background: #fee2e2; color: #dc2626; }

/* ======== ダッシュボード ======== */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: white; border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); text-align: center;
}
.stat-card .stat-value { font-size: 24px; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.success .stat-value { color: var(--success); }
.stat-card.danger .stat-value { color: var(--danger); }

.quick-action-btn {
  width: 100%; background: var(--primary); color: white;
  border: none; border-radius: var(--radius); padding: 16px;
  font-size: 16px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-bottom: 16px; box-shadow: var(--shadow-md);
  transition: background 0.2s, transform 0.1s;
}
.quick-action-btn:active { transform: scale(0.98); background: var(--primary-dark); }

/* ======== 経費アイテム ======== */
.expense-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.expense-item:last-child { border-bottom: none; }
.expense-icon {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.expense-info { flex: 1; min-width: 0; }
.expense-desc { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expense-cat { font-size: 12px; color: var(--text-muted); }
.expense-amount { font-weight: 700; color: var(--text); white-space: nowrap; }
.expense-actions { display: flex; gap: 6px; }
.expense-total {
  margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--border);
  text-align: right; font-size: 15px; color: var(--text-muted);
}
.expense-total strong { font-size: 20px; color: var(--text); margin-left: 4px; }

/* ======== 商談アイテム ======== */
.talk-item {
  padding: 12px; background: var(--bg); border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.talk-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.talk-company { font-weight: 700; }
.talk-content { font-size: 14px; color: var(--text-muted); }
.talk-next { font-size: 12px; color: var(--primary); margin-top: 4px; }

/* ======== 領収書アップロード ======== */
.receipt-upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 20px; text-align: center; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg);
}
.receipt-upload-area:hover { border-color: var(--primary); background: var(--primary-light); }
.receipt-preview-empty { color: var(--text-muted); }
.receipt-preview-empty i { font-size: 32px; margin-bottom: 8px; color: var(--border); }
.receipt-preview-empty p { font-size: 13px; }
.receipt-preview-img { max-height: 150px; max-width: 100%; border-radius: 8px; }

.category-auto-row { display: flex; align-items: center; gap: 8px; }
.category-auto-row select { flex: 1; }
.auto-badge {
  padding: 3px 8px; background: #d1fae5; color: #059669;
  border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap;
}
.transport-notice {
  background: #eff6ff; color: var(--primary);
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}

/* ======== モーダル ======== */
.modal {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
}
.modal-content {
  position: relative; background: white;
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 500px;
  max-height: 92vh; overflow-y: auto;
  z-index: 1;
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: white; z-index: 1;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-body { padding: 16px 20px; }
.modal-footer {
  display: flex; gap: 10px; padding-top: 16px; margin-top: 8px;
  border-top: 1px solid var(--border);
}
.modal-footer .btn { flex: 1; justify-content: center; padding: 12px; }

/* ======== フィルターバー ======== */
.filter-bar {
  display: flex; gap: 8px; margin-bottom: 12px;
}
.filter-bar select, .filter-bar input { flex: 1; }

/* ======== 経費集計 ======== */
.expense-category-bar {
  margin-bottom: 10px;
}
.category-bar-header {
  display: flex; justify-content: space-between;
  font-size: 14px; margin-bottom: 4px;
}
.category-bar-track {
  height: 8px; background: var(--border); border-radius: 999px; overflow: hidden;
}
.category-bar-fill {
  height: 100%; background: var(--primary); border-radius: 999px;
  transition: width 0.5s ease;
}

/* ======== スケルトンローダー ======== */
.skeleton-loader {
  height: 200px; background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: var(--radius);
}
@keyframes skeleton { to { background-position: -200% 0; } }

/* ======== 空状態 ======== */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 16px; }
.empty-state-sm {
  text-align: center; padding: 24px 16px;
  color: var(--text-muted);
}
.empty-state-sm i { font-size: 28px; margin-bottom: 8px; opacity: 0.3; }
.empty-state-sm p { font-size: 14px; }

/* ======== トースト ======== */
.toast-container {
  position: fixed; bottom: calc(var(--bottom-nav-height) + 16px);
  left: 50%; transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1f2937; color: white;
  padding: 12px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 500;
  animation: toastIn 0.3s ease; white-space: nowrap;
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #1f2937; }
@keyframes toastIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ======== 承認管理 ======== */
.approval-card {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden;
}
.approval-card-header {
  padding: 14px 16px; background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  display: flex; align-items: center; justify-content: space-between;
}
.approval-card-body { padding: 14px 16px; }
.approval-actions { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.approval-actions .btn { flex: 1; justify-content: center; }

/* ======== 設定 ======== */
.settings-section { margin-bottom: 20px; }
.settings-section-title {
  font-size: 13px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 10px;
}

/* ======== タブレット・PC対応 ======== */
@media (min-width: 768px) {
  .main-content { max-width: 720px; margin: var(--header-height) auto 0; padding: 24px 24px 80px; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .form-row.col-3 { gap: 16px; }
  .modal { align-items: center; }
  .modal-content { border-radius: 16px; max-height: 85vh; }
  @keyframes slideUp { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
}
@media (min-width: 1024px) {
  .main-content { max-width: 960px; }
  .sidebar { transform: translateX(0); }
  .sidebar-overlay { display: none !important; }
  .main-content { margin-left: var(--sidebar-width); max-width: calc(100% - var(--sidebar-width)); padding: 24px 32px 80px; }
  #menu-toggle { display: none; }
}
