:root {
  --indigo: #7a4a2f;
  --indigo-dark: #5c3821;
  --gold: #c47a3d;
  --gold-light: #dd9c5e;
  --cream: #fbf6ee;
  --cream-alt: #f3e9d9;
  --text: #3f362c;
  --danger: #b3432b;
  --warning: #b98a2f;
  --ok: #6f8f5e;
  --serif: "Shippori Mincho", serif;
  --sans: "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  background: #0e0b08;
}

a { color: var(--gold-light); }

header.app-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 12px;
  padding: max(20px, env(safe-area-inset-top)) 20px 14px;
  max-width: 960px;
  margin: 0 auto;
}
header.app-header h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.4rem;
  margin: 0;
}
header.app-header nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
header.app-header nav a {
  font-family: var(--serif);
  font-size: 0.9rem;
  padding: 0.3em 0.9em;
  border: 1px solid rgba(221, 156, 94, 0.4);
  border-radius: 16px;
  text-decoration: none;
  color: var(--cream);
}
header.app-header nav a.is-active {
  background: var(--gold);
  color: #2b1d10;
  font-weight: 700;
  border-color: var(--gold);
}
.logout-button {
  background: none;
  border: 1px solid rgba(251, 246, 238, 0.3);
  color: var(--cream);
  border-radius: 16px;
  padding: 0.3em 0.9em;
  font-size: 0.85rem;
  cursor: pointer;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 4px 20px 48px;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: rgba(251, 246, 238, 0.06);
  border: 1px solid rgba(251, 246, 238, 0.14);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
}
.login-card h1 {
  font-family: var(--serif);
  font-size: 1.3rem;
  margin: 0 0 20px;
}
.login-card input[type="password"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(251, 246, 238, 0.3);
  background: rgba(0, 0, 0, 0.2);
  color: var(--cream);
  font-size: 1rem;
  margin-bottom: 14px;
}
.login-card button,
.btn {
  display: inline-block;
  padding: 0.7em 1.4em;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: #2b1d10;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
}
.btn.btn-outline {
  background: none;
  border: 1px solid rgba(251, 246, 238, 0.35);
  color: var(--cream);
}
.btn.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.login-error {
  color: #e0917d;
  font-size: 0.85rem;
  margin-top: 10px;
  min-height: 1.2em;
}

.alert-banner {
  border-radius: 14px;
  padding: 14px 18px;
  margin: 12px 0 20px;
  font-size: 0.92rem;
}
.alert-banner.is-danger { background: rgba(179, 67, 43, 0.18); border: 1px solid rgba(179, 67, 43, 0.5); }
.alert-banner.is-warning { background: rgba(185, 138, 47, 0.18); border: 1px solid rgba(185, 138, 47, 0.5); }
.alert-banner.is-ok { background: rgba(111, 143, 94, 0.18); border: 1px solid rgba(111, 143, 94, 0.5); }

.section-title {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.2rem;
  margin: 28px 0 12px;
}

.category-group { margin-bottom: 22px; }
.category-label {
  font-family: var(--serif);
  font-size: 0.85rem;
  color: var(--gold-light);
  margin: 0 0 8px;
  letter-spacing: 0.04em;
}

.doc-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: rgba(251, 246, 238, 0.06);
  border: 1px solid rgba(251, 246, 238, 0.12);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  text-decoration: none;
  color: var(--cream);
}
.doc-card__main { min-width: 0; }
.doc-card__name { font-family: var(--serif); font-weight: 600; font-size: 1.02rem; }
.doc-card__meta { font-size: 0.8rem; color: var(--cream-alt); margin-top: 4px; }
.status-badge {
  flex-shrink: 0;
  padding: 0.35em 0.9em;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-badge.status-none { background: rgba(251, 246, 238, 0.14); color: var(--cream-alt); }
.status-badge.status-overdue { background: rgba(179, 67, 43, 0.25); color: #e0917d; }
.status-badge.status-due_soon { background: rgba(185, 138, 47, 0.25); color: #e0b95a; }
.status-badge.status-ok { background: rgba(111, 143, 94, 0.25); color: #a9c79a; }

.card {
  background: rgba(251, 246, 238, 0.06);
  border: 1px solid rgba(251, 246, 238, 0.12);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 18px;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
table.data-table th, table.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(251, 246, 238, 0.12);
  text-align: left;
  vertical-align: top;
}
table.data-table th { color: var(--gold-light); font-weight: 600; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 560px) {
  .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
}
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--cream-alt);
}
.form-grid input, .form-grid select, .form-grid textarea {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(251, 246, 238, 0.3);
  background: rgba(0, 0, 0, 0.2);
  color: var(--cream);
  font-family: var(--sans);
  font-size: 0.92rem;
  color-scheme: dark;
}
/* date/month inputのカレンダーピッカーアイコンは暗い背景に溶け込んで見えなくなるため、
   反転した上で背景を敷いてはっきり見えるようにする(Chrome/Edge共通のWebKit系実装)。 */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  filter: invert(1) brightness(1.4);
  cursor: pointer;
  padding: 4px;
  margin-left: 4px;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.18);
}

/* ネイティブのカレンダーアイコンが環境によって見えない/反応しないことがあるため、
   隣に明示的な📅ボタンを置いてshowPicker()で確実に開けるようにする(api.jsのattachDatePickerButton)。 */
.date-picker-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.date-picker-wrap input {
  flex: 1;
  min-width: 0;
}
.date-picker-btn {
  flex-shrink: 0;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(251, 246, 238, 0.3);
  background: rgba(255, 255, 255, 0.12);
  color: var(--cream);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.date-picker-btn:active { background: rgba(255, 255, 255, 0.24); }

.form-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.pill {
  font-size: 0.78rem;
  padding: 0.3em 0.8em;
  border-radius: 999px;
  background: rgba(251, 246, 238, 0.1);
  color: var(--cream-alt);
}

.link-back {
  display: inline-block;
  margin: 14px 0;
  font-size: 0.9rem;
  color: var(--gold-light);
  text-decoration: none;
}

.muted { color: var(--cream-alt); font-size: 0.85rem; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
