:root {
  --navy: #0b1b3a;
  --navy2: #122a52;
  --orange: #ff7819;
  --orange2: #ff944d;
  --bg: #f6f7f9;
  --card: #fff;
  --ring: rgba(11, 27, 58, 0.12);
  --text: #0f172a;
  --muted: #64748b;
  --shadow: 0 10px 20px rgba(2, 6, 23, 0.06);
  --radius: 18px;
  --btn-h: 36px;
}
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", "Yu Gothic", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.glow1 {
  position: absolute;
  left: 50%;
  top: -120px;
  width: 500px;
  height: 500px;
  transform: translateX(-50%);
  border-radius: 999px;
  filter: blur(48px);
  background: radial-gradient(circle, rgba(255, 106, 42, 0.15), transparent 60%);
}
.glow2 {
  position: absolute;
  right: -120px;
  top: -100px;
  width: 580px;
  height: 580px;
  border-radius: 999px;
  filter: blur(60px);
  background: radial-gradient(circle, rgba(11, 27, 58, 0.12), transparent 60%);
}

.app-wrap {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 16px 80px;
}

.header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}
.logo {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
  border: 1px solid var(--ring);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: var(--navy);
  font-size: 18px;
  overflow: hidden;
  flex-shrink: 0;
}
.logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.org-logo-preview-wrap {
  margin-bottom: 10px;
}
.org-logo-preview {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--ring);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: var(--navy);
  font-size: 22px;
  overflow: hidden;
}
.org-logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.title small {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.title h1 {
  font-size: 20px;
  color: var(--navy);
  font-weight: 900;
}
.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.btn {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--btn-h);
  padding: 0 14px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  line-height: 1.2;
  transition: transform 0.05s, background 0.15s, border-color 0.15s;
}
.btn:active {
  transform: translateY(1px);
}
.btn-outline {
  background: #fff;
  border: 1px solid var(--ring);
  color: var(--navy);
}
.btn-primary {
  background: linear-gradient(145deg, var(--orange) 0%, var(--orange2) 100%);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* .btn の display が [hidden] を上書きしてしまうため（ログイン済みでも Google ログインが見える問題の修正） */
[hidden] {
  display: none !important;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab {
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
}
.tab.is-active {
  background: #fff;
  border-color: var(--ring);
  color: var(--navy);
  box-shadow: var(--shadow);
}

.panel {
  display: none;
}
.panel.is-active {
  display: block;
}

.card {
  background: var(--card);
  border: 1px solid var(--ring);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 14px;
}
.card h2 {
  font-size: 15px;
  color: var(--navy);
  margin-bottom: 12px;
  font-weight: 900;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.stat {
  padding: 12px 14px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid var(--ring);
}
.stat .label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stat .value {
  font-size: 22px;
  font-weight: 900;
  color: var(--navy);
  margin-top: 4px;
}
.stat .sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.dash-viz-fallback {
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fffbeb;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.dash-viz-fallback code {
  font-size: 11px;
}
.dash-viz-wrap {
  margin-top: 18px;
}
.dash-viz-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 14px;
}
.dash-viz-card {
  position: relative;
  padding: 16px 16px 18px;
  border-radius: 18px;
  background: linear-gradient(165deg, #ffffff 0%, #f8fafc 55%, #f1f5f9 100%);
  border: 1px solid var(--ring);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}
.dash-viz-card::before {
  content: "";
  position: absolute;
  inset: -40% -20% auto auto;
  width: 55%;
  height: 55%;
  background: radial-gradient(circle, rgba(255, 122, 46, 0.12) 0%, transparent 70%);
  pointer-events: none;
  animation: dash-viz-glow 8s ease-in-out infinite alternate;
}
.dash-viz-card--me::before {
  background: radial-gradient(circle, rgba(59, 130, 246, 0.1) 0%, transparent 70%);
}
@keyframes dash-viz-glow {
  from {
    opacity: 0.5;
    transform: translate(0, 0) scale(1);
  }
  to {
    opacity: 1;
    transform: translate(-8px, 6px) scale(1.08);
  }
}
.dash-viz-card-head {
  position: relative;
  z-index: 1;
  margin-bottom: 12px;
}
.dash-viz-card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
  color: var(--navy);
}
.dash-viz-card-head p {
  margin: 4px 0 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.dash-viz-subtitle {
  position: relative;
  z-index: 1;
  margin: 14px 0 8px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.dash-viz-donut-wrap {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(120px, 140px) 1fr;
  gap: 14px;
  align-items: center;
}
@media (max-width: 520px) {
  .dash-viz-donut-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }
  .dash-viz-fy-nums {
    width: 100%;
  }
}
.dash-donut-inner {
  position: relative;
  width: 132px;
  height: 132px;
  margin: 0 auto;
}
.dash-donut-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 14px rgba(255, 122, 46, 0.2));
}
.dash-viz-card--me .dash-donut-svg {
  filter: drop-shadow(0 6px 14px rgba(59, 130, 246, 0.18));
}
.dash-donut-track {
  stroke: #e2e8f0;
}
.dash-donut-prog {
  transition: stroke-dashoffset 1.15s cubic-bezier(0.22, 1, 0.36, 1);
}
.dash-donut-glow {
  stroke: rgba(255, 122, 46, 0.08);
  stroke-width: 14;
  animation: dash-donut-pulse 2.8s ease-in-out infinite;
}
.dash-viz-card--me .dash-donut-glow {
  stroke: rgba(59, 130, 246, 0.1);
}
@keyframes dash-donut-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.85;
  }
}
.dash-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.dash-donut-pct {
  font-size: 22px;
  font-weight: 900;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.dash-donut-pct--ok {
  color: #0d9488;
}
.dash-donut-pct--hot {
  background: linear-gradient(120deg, var(--orange), #f59e0b);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.dash-donut-hint {
  margin-top: 2px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.dash-viz-fy-nums {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dash-fy-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}
.dash-fy-line strong {
  font-size: 14px;
  font-weight: 900;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.dash-fy-ach {
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  margin-top: 4px;
  line-height: 1.45;
}
.dash-q-chart {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 480px) {
  .dash-q-chart {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.dash-q-cell {
  padding: 8px 8px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(226, 232, 240, 0.9);
}
.dash-q-label {
  font-size: 12px;
  font-weight: 900;
  color: var(--navy);
  margin-bottom: 6px;
}
.dash-q-bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.dash-q-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 9px;
  font-weight: 800;
  color: var(--muted);
}
.dash-q-legend {
  width: 22px;
  flex-shrink: 0;
}
.dash-q-track {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}
.dash-q-fill {
  height: 100%;
  border-radius: 999px;
  width: 0;
  transition: width 0.95s cubic-bezier(0.22, 1, 0.36, 1);
}
.dash-q-fill--tgt {
  background: linear-gradient(90deg, #cbd5e1, #94a3b8);
}
.dash-q-fill--act {
  background: linear-gradient(90deg, #ff7a2e, #fbbf24);
}
.dash-q-foot {
  margin-top: 6px;
  font-size: 9px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  word-break: break-all;
}
.dash-month-chart {
  position: relative;
  z-index: 1;
  padding: 8px 4px 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px dashed rgba(148, 163, 184, 0.45);
}
.dash-mo-inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2px;
  min-height: 112px;
  padding: 0 2px;
}
.dash-mo-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.dash-mo-bars {
  width: 100%;
  height: 88px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.dash-mo-pair {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  height: 100%;
}
.dash-mo-bar {
  width: 7px;
  border-radius: 4px 4px 2px 2px;
  min-height: 2px;
  height: 0;
  transition: height 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.dash-mo-bar--tgt {
  background: linear-gradient(180deg, #cbd5e1, #94a3b8);
  opacity: 0.85;
}
.dash-mo-bar--act {
  background: linear-gradient(180deg, #fb923c, #ff7a2e);
  box-shadow: 0 0 12px rgba(255, 122, 46, 0.25);
}
.dash-mo-lab {
  font-size: 9px;
  font-weight: 800;
  color: var(--muted);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .dash-donut-prog,
  .dash-q-fill,
  .dash-mo-bar {
    transition-duration: 0.01ms !important;
  }
  .dash-viz-card::before,
  .dash-donut-glow {
    animation: none !important;
  }
}

.month-tabs {
  margin-bottom: 14px;
}
.month-tabs .tab {
  font-size: 12px;
  padding: 7px 11px;
}

.target-month-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px 12px;
  margin-top: 10px;
}
.target-month-cell label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 4px;
}

.sub-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.sub-tab {
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid var(--ring);
  background: #f8fafc;
  color: var(--muted);
  font-family: inherit;
}
.sub-tab.is-active {
  background: #fff;
  border-color: rgba(255, 120, 25, 0.4);
  color: var(--navy);
  box-shadow: var(--shadow);
}
.dash-block[hidden] {
  display: none !important;
}
.import-preview {
  max-height: 280px;
  overflow: auto;
  margin-top: 12px;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--ring);
  background: #fff;
}
.table-wrap-monthly {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.fy-select-wide,
.import-fy-select-wide {
  min-width: min(100%, 22rem);
  max-width: 100%;
}

table.data-monthly {
  table-layout: auto;
  min-width: 1100px;
}
table.data-monthly th,
table.data-monthly td {
  vertical-align: top;
}
table.data-monthly .col-area {
  min-width: 7rem;
}
table.data-monthly .col-cat {
  min-width: 7rem;
}
table.data-monthly .col-label {
  min-width: 14rem;
  width: 18%;
}
table.data-monthly .col-price {
  min-width: 6.5rem;
}
table.data-monthly .col-qty {
  min-width: 4.5rem;
}
table.data-monthly .col-amt {
  min-width: 8.5rem;
}
table.data-monthly td.num.amt {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.data-monthly .col-hours {
  min-width: 5rem;
}
table.data-monthly .col-tnote {
  min-width: 10rem;
  width: 12%;
}
table.data-monthly .col-note {
  min-width: 8rem;
  width: 10%;
}
table.data-monthly .col-actions {
  min-width: 9.5rem;
  width: 1%;
  white-space: nowrap;
}
table.data-monthly select {
  min-width: 5.5rem;
  max-width: 100%;
}
table.data-monthly td.col-label .inp-text {
  min-width: 12rem;
  width: 100%;
  box-sizing: border-box;
}
table.data-monthly .inp-num {
  min-width: 4rem;
  text-align: right;
}
table.data-monthly .inp-note {
  min-width: 8rem;
  min-height: 64px;
  width: 100%;
  box-sizing: border-box;
}
table.data-monthly .row-actions.row-actions-icons {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  min-width: 0;
}
table.data-monthly .row-actions.row-actions-icons .btn-icon {
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}
table.data-monthly .row-act-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  pointer-events: none;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.data th,
table.data td {
  border-bottom: 1px solid var(--ring);
  padding: 8px 6px;
  text-align: left;
  vertical-align: middle;
}
table.data th {
  background: #f8fafc;
  font-weight: 800;
  color: var(--navy);
  white-space: nowrap;
}
table.data input,
table.data select,
table.data textarea {
  width: 100%;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--ring);
  font: inherit;
  background: #fff;
}
table.data textarea {
  min-height: 52px;
  resize: vertical;
}
table.data .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.toolbar label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.toolbar select {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--ring);
  font: inherit;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(246, 247, 249, 0.92);
  backdrop-filter: blur(6px);
}
.auth-gate[hidden] {
  display: none !important;
}
.auth-gate-card {
  max-width: 400px;
  padding: 28px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--ring);
  text-align: center;
}
.auth-gate-card h2 {
  color: var(--navy);
  margin-bottom: 8px;
  font-size: 18px;
}
.auth-gate-card p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

body.auth-gate-active .app-wrap {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty-state strong {
  color: var(--navy);
  display: block;
  margin-bottom: 8px;
}

.save-toast-root {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 600;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}
.save-toast {
  padding: 12px 22px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(145deg, var(--navy) 0%, #152a52 100%);
  box-shadow: 0 10px 40px rgba(2, 6, 23, 0.25);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  text-align: center;
}
.save-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-bg[hidden] {
  display: none !important;
}
.modal {
  width: min(720px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--ring);
  padding: 20px 22px;
}
.modal.modal-settings-layout {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-sticky-head {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: #fff;
  border-bottom: 1px solid var(--ring);
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-sticky-head h2 {
  margin: 0;
  font-size: 17px;
  color: var(--navy);
  font-weight: 900;
}
.modal-settings-layout .modal-body {
  padding: 18px 20px 22px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.modal:not(.modal-settings-layout) h2 {
  font-size: 17px;
  color: var(--navy);
  margin-bottom: 14px;
  font-weight: 900;
}
.modal-section {
  margin-bottom: 18px;
}
.modal-section h3 {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 800;
}
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}
.list-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
}
.chip.master-chip {
  padding-right: 4px;
  gap: 4px;
}
.chip.master-chip .master-chip-name {
  margin-right: 2px;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.chip.master-chip .master-chip-name:hover {
  color: var(--orange);
}
.chip.master-chip .master-chip-name:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
  border-radius: 4px;
}
.chip.master-chip .btn-sm {
  padding: 2px 8px;
  font-size: 11px;
  min-height: 26px;
}

@media (max-width: 720px) {
  table.data {
    font-size: 11px;
  }
  table.data input,
  table.data select {
    padding: 5px 6px;
  }
}
