:root {
  --blue-50: #e9edef;
  --blue-100: #d3dade;
  --blue-600: #5b7180;
  --blue-700: #465c69;
  --navy-950: #242e35;
  --slate-700: #3f4a51;
  --slate-600: #536069;
  --slate-500: #707c84;
  --slate-300: #c3cbd0;
  --slate-200: #d7dde0;
  --slate-100: #e6eaec;
  --slate-50: #f1f3f4;
  --green-50: #edf1ee;
  --green-700: #4f6859;
  --amber-50: #f2efe7;
  --amber-700: #74623f;
  --red-50: #f3eded;
  --red-700: #815858;
  --white: #fafbfb;
  --sidebar-width: 236px;
  --topbar-height: 66px;
  --radius: 10px;
  --shadow-modal: 0 24px 60px rgba(15, 23, 42, 0.18);
  font-family: Inter, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--navy-950);
  background: var(--white);
  font-synthesis: none;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--slate-50); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--slate-50);
  color: var(--navy-950);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--slate-200);
  background: var(--white);
}

.brand {
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  gap: 11px;
  padding: 0 20px;
  border-bottom: 1px solid var(--slate-200);
  color: var(--blue-600);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--blue-100);
  border-radius: 8px;
  background: var(--blue-50);
}

.brand-mark svg { width: 19px; height: 19px; }
.main-nav { padding: 22px 12px; }

.nav-link {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 13px;
  margin-bottom: 3px;
  padding: 0 13px;
  border-radius: 8px;
  color: var(--slate-600);
  font-size: 14px;
  font-weight: 600;
  transition: color 150ms ease, background 150ms ease;
}

.nav-link:hover { color: var(--blue-700); background: var(--slate-50); }
.nav-link.active { color: var(--blue-700); background: var(--blue-50); }
.nav-link svg { width: 20px; height: 20px; }

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: auto 12px 14px;
  min-height: 46px;
  padding: 0 13px;
  border-radius: 8px;
  color: var(--slate-500);
  font-size: 12px;
  font-weight: 600;
  transition: color 150ms ease, background 150ms ease;
}

.sidebar-foot:hover { color: var(--blue-700); background: var(--slate-50); }
.sidebar-foot.active { color: var(--blue-700); background: var(--blue-50); }
.sidebar-foot svg { width: 19px; height: 19px; }

.sample-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--green-700); box-shadow: 0 0 0 3px var(--green-50); }
.app-main { min-height: 100vh; margin-left: var(--sidebar-width); background: var(--slate-50); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  justify-content: flex-end;
  padding: 0 clamp(20px, 3vw, 42px);
  border-bottom: 1px solid var(--slate-200);
  background: color-mix(in srgb, var(--white) 96%, transparent);
  backdrop-filter: blur(10px);
}

.topbar-note { display: flex; align-items: center; gap: 10px; color: var(--slate-500); font-size: 12px; font-weight: 600; }
.icon-button.mobile-menu, .mobile-brand { display: none; }

.content {
  width: min(100%, 1440px);
  min-height: calc(100vh - var(--topbar-height));
  margin: 0 auto;
  padding: 38px clamp(24px, 4vw, 56px) 60px;
  outline: none;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.page-heading h1 { margin: 0; font-size: clamp(27px, 2.4vw, 34px); line-height: 1.25; letter-spacing: -0.035em; }
.page-heading p { margin: 9px 0 0; color: var(--slate-500); font-size: 14px; line-height: 1.7; }
.heading-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.button:active { transform: translateY(1px); }
.button svg { width: 17px; height: 17px; }
.button-primary { color: var(--white); background: var(--blue-600); border-color: var(--blue-600); }
.button-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.button-secondary { color: var(--slate-700); background: var(--white); border-color: var(--slate-300); }
.button-secondary:hover { color: var(--blue-700); border-color: var(--blue-600); background: var(--blue-50); }
.button-danger { color: var(--red-700); background: var(--white); border-color: color-mix(in srgb, var(--red-700) 35%, var(--white)); }
.button-danger:hover { background: var(--red-50); }
.button-small { min-height: 34px; padding: 0 11px; font-size: 12px; }
.button:disabled { cursor: not-allowed; opacity: 0.5; transform: none; }

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--slate-500);
  background: transparent;
}

.icon-button:hover { color: var(--blue-700); background: var(--blue-50); }
.icon-button svg { width: 18px; height: 18px; }

.workflow-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr auto 1fr;
  align-items: center;
  margin-bottom: 22px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  background: var(--white);
}

.workflow-step { display: flex; min-height: 82px; align-items: center; justify-content: center; gap: 11px; color: var(--slate-700); font-size: 13px; font-weight: 700; }
.workflow-step svg { width: 22px; height: 22px; color: var(--blue-600); }
.workflow-arrow { color: var(--slate-300); }

.summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 30px;
  overflow: hidden;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  background: var(--white);
}

.summary-item { min-width: 0; padding: 22px 24px; border-right: 1px solid var(--slate-200); }
.summary-item:last-child { border-right: 0; }
.summary-label { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; color: var(--slate-500); font-size: 12px; font-weight: 700; }
.summary-label svg { width: 17px; height: 17px; color: var(--blue-600); }
.summary-value { color: var(--navy-950); font-size: clamp(21px, 2vw, 28px); font-weight: 760; letter-spacing: -0.025em; white-space: nowrap; }
.summary-caption { margin-top: 6px; color: var(--slate-500); font-size: 11px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(260px, 0.7fr) minmax(620px, 1.3fr); gap: 34px; align-items: start; }
.dashboard-grid > section { min-width: 0; }
.dashboard-grid .data-table { min-width: 620px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; min-height: 32px; margin-bottom: 12px; }
.section-heading h2 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }
.text-link { border: 0; padding: 5px 0; color: var(--blue-600); background: transparent; font-size: 12px; font-weight: 700; }
.text-link:hover { color: var(--blue-700); text-decoration: underline; text-underline-offset: 3px; }

.chart-panel { padding: 18px 8px 6px 0; }
.bar-chart { display: flex; height: 260px; align-items: stretch; gap: 12px; padding: 8px 4px 0; border-bottom: 1px solid var(--slate-200); background-image: linear-gradient(to bottom, var(--slate-100) 1px, transparent 1px); background-size: 100% 25%; }
.bar-column { display: flex; min-width: 0; flex: 1; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; }
.bar-track { display: flex; width: min(30px, 58%); height: 100%; align-items: flex-end; }
.bar { width: 100%; min-height: 3px; border-radius: 5px 5px 0 0; background: var(--blue-600); transition: height 450ms ease; }
.bar-column:hover .bar { background: var(--blue-700); }
.bar-label { height: 18px; color: var(--slate-500); font-size: 11px; font-weight: 650; }
.chart-note { margin: 14px 0 0; color: var(--slate-500); font-size: 11px; line-height: 1.6; }

.table-frame { overflow: hidden; border: 1px solid var(--slate-200); border-radius: var(--radius); background: var(--white); }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; min-width: 760px; border-collapse: collapse; text-align: left; }
.data-table th { padding: 13px 15px; border-bottom: 1px solid var(--slate-200); color: var(--slate-500); background: var(--slate-50); font-size: 11px; font-weight: 750; letter-spacing: 0.02em; white-space: nowrap; }
.data-table td { padding: 15px; border-bottom: 1px solid var(--slate-200); color: var(--slate-700); font-size: 13px; line-height: 1.5; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--slate-50); }
.cell-primary { color: var(--navy-950); font-weight: 700; }
.cell-secondary { display: block; margin-top: 3px; color: var(--slate-500); font-size: 11px; }
.cell-number { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-actions { width: 1%; white-space: nowrap; }
.action-group { display: flex; justify-content: flex-end; gap: 6px; }

.status {
  display: inline-flex;
  min-height: 25px;
  align-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.status-blue { color: var(--blue-700); background: var(--blue-50); border-color: var(--blue-100); }
.status-green { color: var(--green-700); background: var(--green-50); border-color: color-mix(in srgb, var(--green-700) 30%, var(--white)); }
.status-amber { color: var(--amber-700); background: var(--amber-50); border-color: color-mix(in srgb, var(--amber-700) 30%, var(--white)); }
.status-gray { color: var(--slate-600); background: var(--slate-100); border-color: var(--slate-200); }

.empty-state { padding: 58px 24px; text-align: center; }
.empty-state svg { width: 36px; height: 36px; margin-bottom: 12px; color: var(--slate-300); }
.empty-state h3 { margin: 0 0 7px; font-size: 15px; }
.empty-state p { margin: 0; color: var(--slate-500); font-size: 12px; }

.table-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; color: var(--slate-500); font-size: 12px; }
.table-count strong { color: var(--navy-950); font-size: 14px; }
.settings-stack { display: grid; max-width: 760px; gap: 24px; }
.settings-panel { border: 1px solid var(--slate-200); border-radius: var(--radius); background: var(--white); }
.settings-panel-heading { display: flex; align-items: flex-start; gap: 14px; padding: 23px 25px; border-bottom: 1px solid var(--slate-200); }
.settings-panel-heading h2 { margin: 1px 0 5px; font-size: 17px; }
.settings-panel-heading p { margin: 0; color: var(--slate-500); font-size: 12px; line-height: 1.7; }
.settings-icon { display: grid; width: 38px; height: 38px; flex: 0 0 auto; place-items: center; border: 1px solid var(--blue-100); border-radius: 9px; color: var(--blue-700); background: var(--blue-50); }
.settings-icon svg { width: 20px; height: 20px; }
.settings-form { display: grid; grid-template-columns: minmax(220px, 300px) minmax(260px, 1fr); gap: 24px 32px; align-items: end; padding: 26px; }
.company-settings-form { align-items: start; }
.settings-field { align-self: start; }
.fiscal-preview { display: grid; min-height: 76px; align-content: center; gap: 7px; padding: 14px 17px; border: 1px solid var(--slate-200); border-radius: 8px; background: var(--slate-50); }
.fiscal-preview span { color: var(--slate-500); font-size: 11px; font-weight: 650; }
.fiscal-preview strong { color: var(--slate-700); font-size: 14px; }
.settings-actions { display: flex; grid-column: 1 / -1; justify-content: flex-end; padding-top: 3px; }
.loading { display: grid; min-height: 360px; place-items: center; color: var(--slate-500); font-size: 13px; }
.loading-spinner { width: 26px; height: 26px; margin: 0 auto 12px; border: 2px solid var(--blue-100); border-top-color: var(--blue-600); border-radius: 50%; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.modal { width: min(720px, calc(100% - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 13px; color: var(--navy-950); background: var(--white); box-shadow: var(--shadow-modal); }
.modal::backdrop { background: rgba(15, 23, 42, 0.48); backdrop-filter: blur(2px); }
.modal-card { display: flex; max-height: calc(100vh - 40px); flex-direction: column; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 24px 26px 19px; border-bottom: 1px solid var(--slate-200); }
.modal-context { margin: 0 0 5px; color: var(--blue-600); font-size: 11px; font-weight: 750; }
.modal-header h2 { margin: 0; font-size: 21px; letter-spacing: -0.025em; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; padding: 24px 26px; overflow-y: auto; }
.field { min-width: 0; }
.field-full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 7px; color: var(--slate-700); font-size: 12px; font-weight: 700; }
.required-mark { margin-left: 4px; color: var(--red-700); font-size: 10px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--slate-300); border-radius: 8px; outline: none; color: var(--navy-950); background: var(--white); font-size: 14px; transition: border-color 150ms ease, box-shadow 150ms ease; }
.field input, .field select { height: 42px; padding: 0 12px; }
.field textarea { min-height: 88px; resize: vertical; padding: 11px 12px; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px var(--blue-100); }
.field input:disabled { color: var(--slate-500); background: var(--slate-50); }
.field-hint { display: block; margin-top: 6px; color: var(--slate-500); font-size: 10px; line-height: 1.5; }
.form-error { min-height: 18px; margin: -6px 26px 0; color: var(--red-700); font-size: 12px; font-weight: 650; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 18px 26px 22px; border-top: 1px solid var(--slate-200); }

.toast-region { position: fixed; z-index: 80; right: 22px; bottom: 22px; display: grid; width: min(380px, calc(100vw - 44px)); gap: 10px; pointer-events: none; }
.toast { display: flex; align-items: flex-start; gap: 11px; padding: 14px 16px; border: 1px solid var(--slate-200); border-radius: 10px; color: var(--slate-700); background: var(--white); box-shadow: 0 12px 30px rgba(15, 23, 42, 0.13); font-size: 12px; font-weight: 650; animation: toast-in 180ms ease-out; }
.toast svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--green-700); }
.toast.error svg { color: var(--red-700); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.sidebar-scrim { display: none; }

@media (max-width: 1120px) {
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .summary-item:nth-child(2) { border-right: 0; }
  .summary-item:nth-child(-n + 2) { border-bottom: 1px solid var(--slate-200); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .chart-panel { max-width: 720px; }
}

@media (max-width: 820px) {
  :root { --topbar-height: 58px; }
  .sidebar { transform: translateX(-100%); box-shadow: 18px 0 50px rgba(15, 23, 42, 0.12); transition: transform 180ms ease; }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 25; border: 0; background: rgba(15, 23, 42, 0.38); }
  body.sidebar-open .sidebar-scrim { display: block; }
  .app-main { margin-left: 0; }
  .topbar { justify-content: flex-start; gap: 10px; padding: 0 18px; }
  .icon-button.mobile-menu { display: inline-grid; margin-left: -8px; }
  .mobile-brand { display: block; color: var(--blue-700); font-size: 14px; font-weight: 750; }
  .topbar-note { margin-left: auto; }
  .content { padding: 28px 20px 48px; }
  .workflow-strip { grid-template-columns: repeat(4, 1fr); }
  .workflow-step { min-height: 70px; flex-direction: column; gap: 5px; font-size: 11px; }
  .workflow-arrow { display: none; }
}

@media (max-width: 600px) {
  .topbar-note { display: none; }
  .page-heading { align-items: stretch; flex-direction: column; gap: 17px; }
  .page-heading p { font-size: 13px; }
  .heading-actions { justify-content: flex-start; }
  .heading-actions .button { flex: 1; }
  .summary-row { grid-template-columns: 1fr; }
  .summary-item { border-right: 0; border-bottom: 1px solid var(--slate-200); }
  .summary-item:nth-child(2) { border-bottom: 1px solid var(--slate-200); }
  .summary-item:last-child { border-bottom: 0; }
  .summary-value { font-size: 24px; }
  .chart-panel { padding-right: 0; }
  .bar-chart { height: 220px; gap: 8px; }
  .form-grid { grid-template-columns: 1fr; padding: 20px; }
  .field-full { grid-column: auto; }
  .modal-header { padding: 20px; }
  .form-error { margin-right: 20px; margin-left: 20px; }
  .modal-actions { padding: 16px 20px 20px; }
  .modal-actions .button { flex: 1; }
  .settings-panel-heading { padding: 20px; }
  .settings-form { grid-template-columns: 1fr; padding: 20px; }
  .settings-actions { grid-column: auto; }
  .settings-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
