:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e3e6f0;
  --ok: #16a34a;
  --warn: #d97706;
  --error: #dc2626;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 960px; margin: 0 auto; padding: 0 16px 48px; }

.loading { text-align: center; padding: 80px 0; color: var(--muted); }

/* ---- ヘッダー ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; margin-bottom: 12px;
}
.topbar .brand { font-weight: 700; font-size: 18px; color: var(--primary); }
.topbar .brand small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
.topbar .user-info { text-align: right; font-size: 13px; color: var(--muted); }
.topbar .user-info strong { display: block; color: var(--text); font-size: 14px; }

/* ---- カード ---- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(20, 24, 60, 0.05);
}
.card h2 { font-size: 16px; margin-bottom: 14px; }
.card h3 { font-size: 14px; margin: 14px 0 8px; }

/* ---- フォーム ---- */
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.form-row { display: flex; gap: 10px; }
.form-row > * { flex: 1; }

button {
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 11px 18px; border: none; border-radius: 10px;
  background: var(--primary); color: #fff; cursor: pointer;
  transition: background 0.15s;
}
button:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.secondary { background: #eef0fa; color: var(--primary); }
button.danger { background: #fde8e8; color: var(--error); }
button.ghost { background: transparent; color: var(--muted); font-weight: 400; padding: 6px 10px; }
button.small { font-size: 13px; padding: 7px 12px; }
button.block { width: 100%; margin-top: 14px; }

/* ---- ログイン ---- */
.login-wrap { max-width: 380px; margin: 8vh auto 0; }
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); margin-top: 14px; }
.auth-switch a { color: var(--primary); font-weight: 600; text-decoration: none; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .mark {
  width: 64px; height: 64px; border-radius: 18px; background: var(--primary);
  color: #fff; font-size: 30px; line-height: 64px; margin: 0 auto 10px;
}
.login-logo h1 { font-size: 20px; }
.login-logo p { font-size: 13px; color: var(--muted); }

/* ---- タブ ---- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  background: transparent; color: var(--muted); font-weight: 500;
  padding: 9px 14px; border-radius: 999px; white-space: nowrap; font-size: 14px;
}
.tabs button.active { background: var(--primary); color: #fff; }
.tabs button:hover:not(.active) { background: #e8eaf8; }

/* ---- メッセージ ---- */
.msg { padding: 10px 14px; border-radius: 10px; font-size: 14px; margin: 10px 0; }
.msg.ok { background: #e8f7ee; color: var(--ok); }
.msg.error { background: #fdeaea; color: var(--error); }

/* ---- 打刻ボタン ---- */
.punch-status { text-align: center; padding: 8px 0 16px; }
.punch-status .date { color: var(--muted); font-size: 14px; }
.punch-status .state { font-size: 22px; font-weight: 700; margin-top: 4px; }
.punch-status .times { font-size: 14px; color: var(--muted); margin-top: 6px; }
.punch-buttons { display: flex; gap: 12px; }
.punch-buttons button { flex: 1; padding: 20px 0; font-size: 18px; border-radius: 14px; }
.punch-buttons .out { background: #eef0fa; color: var(--primary); }

/* ---- テーブル ---- */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border: 1px solid var(--border); padding: 6px 8px; text-align: center; white-space: nowrap; }
th { background: #f0f1fa; font-weight: 600; }
td.name-cell, th.name-cell { text-align: left; position: sticky; left: 0; background: #fff; min-width: 110px; }
th.name-cell { background: #f0f1fa; }
td.weekend, th.weekend { background: #fafafa; color: #b3b7c4; }

.mark-present { color: var(--ok); font-weight: 700; }
.mark-absent { color: var(--error); font-weight: 700; }
.mark-leave { color: var(--warn); font-weight: 700; }
.mark-working { color: var(--primary); font-weight: 700; }

/* ---- バッジ ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.paid { background: #e8f7ee; color: var(--ok); }
.badge.unpaid { background: #fdeaea; color: var(--error); }
.badge.trial { background: #fef4e6; color: var(--warn); }
.badge.pending { background: #fef4e6; color: var(--warn); }
.badge.approved { background: #e8f7ee; color: var(--ok); }
.badge.rejected { background: #f1f2f6; color: var(--muted); }

/* ---- リスト ---- */
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .main .title { font-weight: 600; font-size: 14px; }
.list-item .main .sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.list-item .actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---- 地図 ---- */
#map { height: 340px; border-radius: 10px; border: 1px solid var(--border); }
.map-hint { font-size: 13px; color: var(--muted); margin: 8px 0; }

/* ---- 月ナビ ---- */
.month-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.month-nav .ym { font-weight: 700; font-size: 16px; min-width: 100px; text-align: center; }
.month-nav .spacer { flex: 1; }

.legend { font-size: 12px; color: var(--muted); margin-top: 10px; }

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

@media (max-width: 600px) {
  .form-row { flex-direction: column; }
  #map { height: 280px; }
}
