:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-alt: #edf2f7;
  --line: #d9e1ea;
  --text: #18212f;
  --muted: #657386;
  --primary: #126b8f;
  --primary-dark: #0f5574;
  --accent: #d97706;
  --success: #16845b;
  --warning: #d97706;
  --danger: #c2413a;
  --shadow: 0 16px 40px rgba(24, 33, 47, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif;
  letter-spacing: 0;
}

body.locked {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #102231;
  color: #f4f7fb;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 10px;
}

.brand-mark {
  align-items: center;
  background: #e8b44c;
  border-radius: 8px;
  color: #102231;
  display: grid;
  font-weight: 800;
  height: 38px;
  place-items: center;
  width: 38px;
}

.brand span,
.sidebar-footer span {
  color: #aebdcc;
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #dfe8f1;
  display: flex;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  text-align: left;
  width: 100%;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.owner-subnav {
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  display: grid;
  gap: 3px;
  margin: -2px 0 4px 30px;
  padding-left: 10px;
}

.owner-subnav-item {
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: #aebdcc;
  font-size: 12px;
  font-weight: 800;
  min-height: 30px;
  padding: 0 9px;
  text-align: left;
  width: 100%;
}

.owner-subnav-item:hover,
.owner-subnav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.icon {
  display: inline-grid;
  font-size: 17px;
  height: 22px;
  place-items: center;
  width: 22px;
}

.sidebar-footer {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 14px;
}

.goal-card {
  margin-top: auto;
}

.sidebar-footer strong {
  display: block;
  font-size: 26px;
  margin: 8px 0;
}

.mini-progress {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.mini-progress span {
  background: #e8b44c;
  display: block;
  height: 100%;
  width: 0;
}

.table-progress {
  background: #e8edf3;
  margin: 7px 0 5px;
  min-width: 96px;
}

.table-progress span {
  background: var(--primary);
}

.user-name {
  font-size: 18px !important;
}

.sidebar-button {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #ffffff;
  margin-top: 10px;
  min-height: 34px;
  width: 100%;
}

.main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 19px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.billing-notice {
  background: #eef7f1;
  border: 1px solid #b8dec7;
  border-radius: 8px;
  color: #12633f;
  font-weight: 800;
  margin: -10px 0 22px;
  padding: 13px 16px;
}

.billing-notice.warn {
  background: #fff0d3;
  border-color: #f1c36e;
  color: #8b4b00;
}

.notice-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.service-notice {
  background: #eef7fb;
  border: 1px solid #b9ddea;
  border-left: 5px solid var(--primary);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 4px;
  padding: 12px 14px;
}

.service-notice.maintenance {
  background: #fff8e8;
  border-color: #f0c26a;
  border-left-color: var(--warning);
}

.service-notice.incident {
  background: #fdeaea;
  border-color: #efb4b0;
  border-left-color: var(--danger);
}

.service-notice strong {
  font-size: 14px;
}

.service-notice span {
  color: var(--muted);
  line-height: 1.5;
}

.search-box {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  width: min(370px, 42vw);
}

.search-box input {
  border: 0;
  min-width: 0;
  outline: 0;
  width: 100%;
}

.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
}

.primary-button {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #fff;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button,
.ghost-button,
.icon-button,
.file-button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}

.ghost-button {
  min-height: 34px;
}

.icon-button {
  font-size: 22px;
  height: 38px;
  padding: 0;
  width: 38px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  margin-bottom: 18px;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  margin-bottom: 16px;
}

.metric-card,
.panel,
.customer-card,
.activity-column,
.pipeline-column,
.summary-tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.summary-tile {
  box-shadow: none;
  padding: 14px;
}

.summary-tile span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.summary-tile strong {
  font-size: 18px;
}

.summary-tile small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.4;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.compact-summary {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.compact-form {
  margin-top: 14px;
}

.usage-list {
  display: grid;
  gap: 10px;
  margin: 4px 0 16px;
}

.usage-line {
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-left: 5px solid var(--success);
  border-radius: 8px;
  padding: 10px 12px;
}

.usage-line.warn {
  border-left-color: var(--warning);
}

.usage-line.danger {
  border-left-color: var(--danger);
}

.usage-heading,
.usage-cell {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.usage-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.usage-cell {
  justify-content: flex-start;
}

.usage-cell strong {
  white-space: nowrap;
}

.metric-card span {
  color: var(--muted);
  font-size: 13px;
}

.metric-card strong {
  display: block;
  font-size: 27px;
  margin-top: 8px;
}

.metric-card small {
  color: var(--success);
  display: block;
  margin-top: 8px;
}

.content-grid {
  display: grid;
  gap: 18px;
}

.two-columns {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-header,
.section-toolbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 16px;
}

.deal-list,
.activity-list,
.activity-board {
  display: grid;
  gap: 10px;
}

.deal-row,
.activity-row,
.deal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.deal-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.deal-row strong,
.deal-card strong,
.customer-card strong {
  overflow-wrap: anywhere;
}

.meta-line {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 8px;
}

.amount {
  color: var(--primary-dark);
  font-weight: 800;
  white-space: nowrap;
}

.badge {
  align-items: center;
  background: var(--surface-alt);
  border-radius: 999px;
  color: #3a4859;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  min-height: 24px;
  padding: 0 9px;
  width: fit-content;
}

.badge.success {
  background: #dff4e8;
  color: #12633f;
}

.badge.warn {
  background: #fff0d3;
  color: #8b4b00;
}

.badge.danger {
  background: #fde2e2;
  color: #9d1c1c;
}

.readiness-list {
  display: grid;
  gap: 10px;
}

.readiness-item {
  align-items: center;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-left: 5px solid #91a1b2;
  border-radius: 8px;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 12px 14px;
}

.readiness-item.ok {
  border-left-color: var(--success);
}

.readiness-item.warn {
  border-left-color: var(--warning);
}

.readiness-item.danger {
  border-left-color: var(--danger);
}

.readiness-item strong {
  color: var(--text);
  display: block;
  font-size: 14px;
  margin-bottom: 4px;
}

.readiness-item p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0;
}

.alert-actions {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-board {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(5, minmax(210px, 1fr));
  overflow-x: auto;
  padding-bottom: 6px;
}

.pipeline-column {
  min-height: 500px;
  min-width: 210px;
  padding: 12px;
}

.column-header {
  align-items: start;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.column-header span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 4px;
}

.deal-stack {
  display: grid;
  gap: 10px;
}

.deal-card {
  background: #fbfcfe;
}

.deal-actions {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
}

.mini-button {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 30px;
  padding: 0 9px;
}

.mini-link {
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.mini-link:hover {
  text-decoration: underline;
}

.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}

table {
  border-collapse: collapse;
  min-width: 1180px;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 14px;
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.table-control {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 32px;
  padding: 0 8px;
  width: 128px;
}

.compact-number {
  width: 104px;
}

.compact-date {
  width: 142px;
}

.support-note {
  width: 220px;
}

.table-actions {
  display: flex;
  gap: 6px;
}

.mini-check {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  gap: 5px;
  white-space: nowrap;
}

.mini-check input {
  height: 14px;
  width: 14px;
}

.customer-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.customer-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.customer-top {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.rank {
  align-items: center;
  border: 2px solid var(--primary);
  border-radius: 50%;
  color: var(--primary);
  display: grid;
  flex: 0 0 auto;
  font-weight: 800;
  height: 34px;
  place-items: center;
  width: 34px;
}

.activity-board {
  grid-template-columns: repeat(3, minmax(230px, 1fr));
}

.activity-column {
  min-height: 420px;
  padding: 12px;
}

.activity-row {
  background: #fbfcfe;
}

.invoice-overdue-row {
  background: #fff8f8;
}

.cancellation-due-row {
  background: #fff8f8;
}

.support-stale-row {
  background: #fff8f8;
}

.signup-stale-row {
  background: #fff8f8;
}

.row-warn {
  background: #fff8f8;
}

.row-soft-warn {
  background: #fffaf0;
}

.bar-chart {
  display: grid;
  gap: 14px;
}

.bar-line {
  display: grid;
  gap: 7px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.bar-track {
  background: var(--surface-alt);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
}

.bar-fill {
  background: linear-gradient(90deg, var(--primary), var(--success));
  display: block;
  height: 100%;
  min-width: 4px;
}

.bar-fill.warn {
  background: linear-gradient(90deg, var(--warning), #f08b2f);
}

.bar-fill.danger {
  background: linear-gradient(90deg, var(--danger), #d23c3c);
}

.settings-form,
.admin-actions {
  display: grid;
  gap: 12px;
}

.settings-form {
  max-width: 460px;
}

.settings-form .primary-button {
  margin-top: 4px;
  width: fit-content;
}

.admin-actions {
  grid-template-columns: repeat(2, minmax(150px, 1fr));
}

.file-button {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
}

.file-button input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.admin-status {
  color: var(--muted);
  margin-top: 14px;
  min-height: 22px;
}

.admin-only {
  margin-top: 18px;
}

.owner-console-layout {
  display: block;
}

.owner-workspace {
  min-width: 0;
}

.owner-section {
  scroll-margin-top: 18px;
}

.owner-page-hidden {
  display: none !important;
}

.invite-result {
  background: #eef8f3;
  border: 1px solid #b7e3cd;
  border-radius: 8px;
  color: #12633f;
  font-weight: 800;
  margin-top: 14px;
  overflow-wrap: anywhere;
  padding: 14px;
}

.user-list {
  display: grid;
  gap: 10px;
}

.user-item {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 12px;
}

.user-controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.compact-check {
  align-items: center;
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 800;
  gap: 5px;
  white-space: nowrap;
}

.user-item strong {
  display: block;
}

.flat-table {
  box-shadow: none;
}

.segmented {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  padding: 3px;
}

.segmented button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  min-height: 32px;
  padding: 0 12px;
}

.segmented button.active {
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(24, 33, 47, 0.12);
}

.modal {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(16, 34, 49, 0.28);
  max-width: min(760px, calc(100vw - 24px));
  padding: 0;
  width: 760px;
}

.modal::backdrop {
  background: rgba(16, 34, 49, 0.44);
}

.modal form {
  padding: 20px;
}

.modal-header,
.modal-actions {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-subtitle {
  color: var(--muted);
  font-size: 13px;
  margin: 4px 0 0;
}

.modal-actions {
  justify-content: flex-end;
  margin: 18px 0 0;
  gap: 10px;
}

.onboarding-list {
  margin-top: 12px;
}

.onboarding-followup-form {
  margin-top: 14px;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-height: 40px;
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.split-fields {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.check-row {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-direction: row;
  font-size: 13px;
  gap: 8px;
}

.check-row input {
  height: 16px;
  width: 16px;
}

.check-row a {
  color: var(--primary);
  font-weight: 800;
}

.legal-links {
  margin: 0;
}

.legal-links a {
  color: var(--primary);
  font-size: 13px;
  font-weight: 800;
}

.legal-page {
  background: #f6f8fb;
}

.legal-doc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 32px auto;
  max-width: 880px;
  padding: 36px;
}

.legal-doc h1 {
  font-size: 34px;
  margin: 8px 0 14px;
}

.legal-doc h2 {
  font-size: 18px;
  margin: 28px 0 8px;
}

.legal-doc p {
  color: var(--muted);
  line-height: 1.8;
}

.legal-lead {
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
  padding-bottom: 18px;
}

.legal-back {
  color: var(--primary);
  display: inline-block;
  font-weight: 800;
  margin-bottom: 16px;
  text-decoration: none;
}

.legal-note {
  border-top: 1px solid var(--line);
  margin-top: 32px;
  padding-top: 18px;
}

.legal-definition {
  display: grid;
  gap: 0;
  grid-template-columns: 220px minmax(0, 1fr);
}

.legal-definition dt,
.legal-definition dd {
  border-bottom: 1px solid var(--line);
  margin: 0;
  padding: 16px 0;
}

.legal-definition dt {
  color: var(--text);
  font-weight: 800;
}

.legal-definition dd {
  color: var(--muted);
  line-height: 1.8;
}

@media (max-width: 720px) {
  .legal-doc {
    margin: 0;
    min-height: 100vh;
    padding: 24px;
  }

  .legal-definition {
    grid-template-columns: 1fr;
  }

  .legal-definition dt {
    border-bottom: 0;
    padding-bottom: 4px;
  }

  .legal-definition dd {
    padding-top: 0;
  }
}

.hidden {
  display: none !important;
}

.login-screen {
  align-items: center;
  background: rgba(246, 248, 251, 0.92);
  display: flex;
  gap: 18px;
  inset: 0;
  justify-content: center;
  overflow: auto;
  padding: 20px;
  position: fixed;
  z-index: 20;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 80px rgba(16, 34, 49, 0.18);
  display: grid;
  gap: 18px;
  max-width: 430px;
  padding: 26px;
  width: min(430px, 100%);
}

.login-card h1 {
  font-size: 26px;
}

.login-card p {
  color: var(--muted);
  margin-top: 6px;
}

.login-brand {
  color: var(--text);
  padding: 0;
}

.login-brand span {
  color: var(--muted);
}

.form-error {
  color: var(--danger) !important;
  min-height: 20px;
}

.form-success {
  color: var(--success) !important;
  min-height: 20px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.sr-only {
  height: 1px;
  margin: -1px;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .nav-item {
    justify-content: flex-start;
  }

  .metric-grid,
  .customer-grid,
  .two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .activity-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    height: auto;
    position: static;
  }

  .nav-list {
    grid-template-columns: repeat(auto-fit, minmax(124px, 1fr));
  }

  .owner-subnav {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: -2px 0 4px;
  }

  .main {
    padding: 18px;
  }

  .topbar,
  .section-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions,
  .search-box {
    width: 100%;
  }

  .metric-grid,
  .customer-grid,
  .two-columns,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button,
  .file-button {
    width: 100%;
  }

  .admin-actions {
    grid-template-columns: 1fr;
  }
}
