:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #f8faf9;
  --line: #dfe7e4;
  --line-strong: #c9d6d2;
  --text: #1e2926;
  --muted: #687772;
  --muted-2: #84918d;
  --teal: #0f766e;
  --teal-strong: #0b5f59;
  --teal-soft: #e1f3ef;
  --amber: #b7791f;
  --amber-soft: #fff4d8;
  --blue: #2563eb;
  --blue-soft: #e8efff;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(26, 44, 40, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", system-ui, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

body:not(.is-authenticated) {
  background: #10211f;
}

body:not(.is-authenticated) .app-shell {
  display: none;
}

body.is-authenticated .login-screen {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
tr[tabindex]:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.24);
  outline-offset: 2px;
}

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

.mobile-appbar {
  display: none;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
  background:
    radial-gradient(circle at top left, rgba(225, 243, 239, 0.18), transparent 34%),
    #10211f;
}

.login-card {
  display: grid;
  gap: 24px;
  width: min(100%, 460px);
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 12px;
  color: #ffffff;
  text-align: center;
}

.login-logo {
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.login-logo img {
  display: block;
  width: 112px;
  height: 112px;
  object-fit: contain;
}

.login-brand .brand-name {
  font-size: 32px;
  line-height: 1.1;
}

.login-brand .brand-sub {
  color: #b8cbc6;
  font-size: 14px;
}

.login-fields-box {
  display: grid;
  gap: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 24px;
  background: #ffffff;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.26);
}

.login-fields-box h1 {
  font-size: 24px;
}

.login-field {
  display: grid;
  gap: 7px;
}

.login-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.login-field input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
}

.login-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
}

.login-submit {
  width: 100%;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: #10211f;
  color: #f8fbfa;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.mobile-brand-name {
  overflow: hidden;
  color: #f8fbfa;
  font-size: 16px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-badge,
.sidebar-user {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--teal-strong);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

  .mobile-user-badge {
    margin-left: auto;
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #f8fbfa;
}

.sidebar-user {
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-height: auto;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.sidebar-user span {
  color: #b8cbc6;
  font-size: 11px;
  font-weight: 700;
}

.sidebar-user strong {
  font-size: 18px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal-strong);
  font-weight: 800;
  overflow: hidden;
}

.brand-mark img {
  display: block;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand-name,
.brand-sub,
.eyebrow,
.panel-head p,
.summary-label {
  margin: 0;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
}

.brand-sub {
  color: #9eb3ae;
  font-size: 12px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 0 12px;
  background: transparent;
  color: #bed0cc;
  text-align: left;
  transition: background 180ms ease, color 180ms ease;
}

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

.nav-item svg,
.topbar svg,
.section-title svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.sidebar-summary {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-summary strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.sidebar-summary span,
.summary-label {
  color: #b8cbc6;
  font-size: 12px;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  margin-top: 2px;
  font-size: 26px;
  line-height: 1.25;
}

h2 {
  font-size: 17px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(620px, 58vw);
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--panel);
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.primary-button,
.icon-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius);
  transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.primary-button {
  gap: 8px;
  white-space: nowrap;
  border: 0;
  padding: 0 16px;
  background: var(--teal);
  color: #ffffff;
  font-weight: 700;
}

.mobile-primary-button {
  display: none;
}

.primary-button:hover {
  background: var(--teal-strong);
  transform: translateY(-1px);
}

.secondary-button {
  gap: 7px;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: var(--panel);
  color: var(--text);
  font-weight: 800;
}

.secondary-button:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(22, 42, 38, 0.04);
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 24px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
  min-height: 0;
}

.list-panel,
.detail-panel,
.panel-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.list-panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.panel-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

select,
input[type="date"] {
  min-height: 40px;
  max-width: 150px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 34px 0 10px;
  background: #ffffff;
  color: var(--text);
}

.table-wrap {
  overflow: auto;
}

.mobile-client-list {
  display: none;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

th:nth-child(1),
td:nth-child(1) {
  width: 25%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 10%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 13%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 13%;
}

th:nth-child(5),
td:nth-child(5) {
  width: 13%;
}

th:nth-child(6),
td:nth-child(6) {
  width: 13%;
}

th:nth-child(7),
td:nth-child(7) {
  width: 13%;
}

tbody tr {
  cursor: pointer;
  transition: background 160ms ease;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #f0f8f6;
}

tbody tr.is-selected td:first-child {
  box-shadow: inset 4px 0 0 var(--teal);
}

.client-cell {
  display: grid;
  gap: 4px;
}

.client-cell strong {
  font-size: 14px;
}

.client-cell span {
  color: var(--muted);
  font-size: 12px;
}

.pill,
.status-chip,
.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.consulting {
  background: #eef2ff;
  color: #4338ca;
}

.status-pill.estimate {
  background: #ecfeff;
  color: #0e7490;
}

.status-pill.negotiation {
  background: #fff7ed;
  color: #c2410c;
}

.status-pill.active {
  background: var(--teal-soft);
  color: var(--teal-strong);
}

.status-pill.payment {
  background: #fef3c7;
  color: #a16207;
}

.status-pill.complete {
  background: #f1f5f9;
  color: #475569;
}

.status-pill.expired {
  background: #fee2e2;
  color: #b91c1c;
}

.status-select {
  width: 120px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 28px 0 12px;
  background-color: #ffffff;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
}

.status-select.active {
  background-color: var(--teal-soft);
  color: var(--teal-strong);
}

.status-select.consulting {
  background-color: #eef2ff;
  color: #4338ca;
}

.status-select.estimate {
  background-color: #ecfeff;
  color: #0e7490;
}

.status-select.negotiation {
  background-color: #fff7ed;
  color: #c2410c;
}

.status-select.payment {
  background-color: #fef3c7;
  color: #a16207;
}

.status-select.complete {
  background-color: #f1f5f9;
  color: #475569;
}

.status-select.expired {
  background-color: #fee2e2;
  color: #b91c1c;
}

.pill.standard {
  background: var(--blue-soft);
  color: var(--blue);
}

.pill.premium {
  background: var(--teal-soft);
  color: var(--teal-strong);
}

.pill.other {
  background: var(--amber-soft);
  color: var(--amber);
}

.detail-panel {
  position: sticky;
  top: 18px;
  align-self: start;
  min-height: 720px;
  overflow: hidden;
}

.detail-empty {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: 720px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.detail-empty svg {
  width: 34px;
  height: 34px;
  color: var(--teal);
}

.detail-content {
  display: block;
}

.is-hidden {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 33, 31, 0.48);
}

.modal-backdrop.is-hidden {
  display: none;
}

.modal-card {
  width: min(100%, 840px);
  max-height: min(90vh, 820px);
  overflow: auto;
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

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

.client-form label {
  display: grid;
  gap: 6px;
}

.client-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.client-form input,
.client-form textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--text);
}

.client-form textarea {
  resize: vertical;
}

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

.utility-view {
  min-width: 0;
}

.dashboard-view {
  min-width: 0;
}

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

.status-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 18px;
}

.status-summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  background: var(--panel-soft);
}

.status-summary-item strong {
  font-size: 20px;
}

.dashboard-list {
  display: grid;
  min-height: 220px;
}

.dashboard-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.dashboard-list-item:last-child {
  border-bottom: 0;
}

.dashboard-list-item strong,
.dashboard-list-item span {
  display: block;
}

.dashboard-list-item > div:first-child {
  min-width: 0;
}

.dashboard-list-item > div:first-child strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-list-item > div:first-child span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.dashboard-list-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
  flex: 0 0 auto;
}

.dashboard-list-meta small {
  color: var(--muted);
  font-weight: 700;
}

.attention-card {
  border-color: #f5d58a;
}

.empty-line {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  font-weight: 700;
}

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

.report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  padding: 18px;
}

.report-toolbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.report-period {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.report-period span,
.date-range span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.date-range label {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.report-grid-wide {
  margin-top: 16px;
}

.panel-card {
  overflow: hidden;
}

.mini-table {
  display: grid;
}

.mini-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 120px 120px 120px 120px;
  gap: 12px;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.mini-row:last-child {
  border-bottom: 0;
}

.mini-row.header {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-row strong,
.mini-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.days-chip {
  display: inline-flex;
  justify-content: center;
  width: fit-content;
  min-width: 72px;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--teal-soft);
  color: var(--teal-strong);
  font-size: 12px;
  font-weight: 800;
}

.bar-list {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.bar-row {
  display: grid;
  gap: 8px;
}

.bar-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 700;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--panel-soft);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.report-table {
  display: grid;
}

.report-detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) 90px 112px 120px;
  gap: 12px;
  align-items: center;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}

.report-detail-row.individual-row {
  grid-template-columns: minmax(0, 1.4fr) 120px 90px;
}

.report-detail-row.owner-row {
  grid-template-columns: minmax(0, 1.2fr) 100px 140px;
}

.report-detail-row:last-child {
  border-bottom: 0;
}

.report-detail-row.header {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.report-detail-row strong,
.report-detail-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-card-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.settings-card-head svg {
  width: 22px;
  height: 22px;
  color: var(--teal);
}

.settings-card-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.master-form {
  display: flex;
  gap: 8px;
  padding: 14px 18px 0;
}

.master-form input,
.editable-tag input {
  min-height: 34px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
}

.tag-list,
.plan-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 18px;
}

.tag,
.editable-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--panel-soft);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.editable-tag button {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.editable-tag button[data-master-delete] {
  border-color: #fecaca;
  color: var(--danger);
}

.setting-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.setting-row:last-child {
  border-bottom: 0;
}

.setting-row span {
  color: var(--muted);
}

.setting-row strong {
  text-align: right;
}

.settings-lock {
  display: grid;
  place-items: center;
  min-height: 420px;
}

.settings-lock.is-hidden,
.settings-unlocked.is-hidden,
.settings-tab-panel.is-hidden {
  display: none;
}

.lock-card {
  display: grid;
  gap: 16px;
  width: min(100%, 420px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.lock-card > svg {
  width: 34px;
  height: 34px;
  color: var(--teal);
}

.lock-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.settings-tab {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 14px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 700;
}

.settings-tab.is-active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal-strong);
}

.user-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.issued-password {
  min-height: 22px;
  margin: 0;
  color: var(--teal-strong);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.mini-row.user-row {
  grid-template-columns: minmax(0, 1.2fr) 80px minmax(0, 1fr) 76px;
}

.mini-row.active-session-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 120px;
}

.mini-row.operation-row {
  grid-template-columns: 90px 70px 90px minmax(0, 1fr) 150px;
}

.danger-button {
  min-height: 34px;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 0 12px;
  background: #fee2e2;
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
}

.danger-button:hover {
  background: #fecaca;
}

.muted-action {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mini-row.history-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
}

.detail-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #f4fbf9 0%, #ffffff 100%);
}

.detail-actions {
  display: flex;
  gap: 8px;
}

.detail-hero h2 {
  margin-top: 10px;
  font-size: 22px;
}

.detail-hero p {
  margin: 4px 0 0;
  color: var(--muted);
}

.status-chip {
  background: var(--teal-soft);
  color: var(--teal-strong);
}

.icon-button {
  width: 44px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

.danger-icon-button {
  border-color: #fecaca;
  color: var(--danger);
}

.danger-icon-button:hover {
  background: #fee2e2;
}

.detail-list,
.contract-grid {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 18px 20px;
}

.detail-list div,
.contract-grid div {
  display: grid;
  gap: 3px;
}

dt {
  color: var(--muted);
  font-size: 12px;
}

dd {
  margin: 0;
  color: var(--text);
  font-weight: 600;
  line-height: 1.5;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  color: var(--teal-strong);
  font-size: 13px;
  font-weight: 800;
}

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

.contract-grid .wide {
  grid-column: 1 / -1;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.memo-box {
  margin: 2px 20px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}

.memo-box .section-title {
  padding: 14px 14px 0;
}

.memo-box p {
  margin: 8px 0 0;
  padding: 0 14px 14px;
  color: var(--muted);
  line-height: 1.7;
}

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

  .brand div:not(.brand-mark),
  .nav-item:not(.is-active),
  .sidebar-user,
  .sidebar-summary {
    font-size: 0;
  }

  .brand {
    justify-content: center;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .report-grid,
  .dashboard-grid,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .report-summary-grid {
    grid-template-columns: 1fr;
  }

  .mini-row {
    grid-template-columns: minmax(0, 1.4fr) 92px 92px 92px 92px;
  }

  .detail-panel {
    position: static;
    min-height: auto;
  }

  .detail-empty {
    min-height: 260px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .mobile-appbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    width: 100vw;
    max-width: 100vw;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 10px 12px;
    background: #10211f;
    box-shadow: 0 10px 28px rgba(16, 33, 31, 0.18);
  }

  .mobile-appbar .brand-mark {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
  }

  .mobile-appbar .brand-mark img {
    width: 30px;
    height: 30px;
  }

  .mobile-primary-button {
    display: inline-flex;
    width: 44px;
    min-width: 44px;
    padding: 0;
  }

  .sidebar {
    position: static;
    top: 0;
    display: block;
    padding: 8px 12px 10px;
  }

  .brand,
  .sidebar-user,
  .sidebar-summary {
    display: none;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    flex: 0 0 48px;
    width: 48px;
    font-size: 0;
  }

  .workspace {
    max-width: 100vw;
    overflow-x: hidden;
    padding: 16px;
  }

  .topbar,
  .panel-head,
  .report-toolbar {
    align-items: stretch;
    flex-direction: column;
    min-width: 0;
  }

  .topbar {
    gap: 12px;
  }

  .topbar-actions {
    min-width: 0;
    width: 100%;
  }

  .topbar-actions .user-badge {
    display: none;
  }

  .topbar-actions .primary-button {
    display: none;
  }

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

  .metric strong {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .status-summary {
    grid-template-columns: 1fr;
  }

  .dashboard-list-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-list-meta {
    justify-items: start;
  }

  .filters {
    flex-direction: column;
    justify-content: stretch;
  }

  select,
  input[type="date"] {
    max-width: none;
  }

  .table-wrap {
    display: none;
  }

  .mobile-client-list {
    display: grid;
    gap: 10px;
    padding: 12px;
    background: var(--panel-soft);
  }

  .mobile-client-card {
    display: grid;
    gap: 12px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    background: var(--panel);
    box-shadow: 0 8px 22px rgba(22, 42, 38, 0.05);
    color: var(--text);
    text-align: left;
  }

  .mobile-client-card.is-selected {
    background: #f0f8f6;
    border-color: rgba(15, 118, 110, 0.36);
    box-shadow: inset 4px 0 0 var(--teal);
  }

  .mobile-card-head,
  .mobile-card-meta,
  .mobile-card-grid {
    display: flex;
    min-width: 0;
  }

  .mobile-card-head {
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-card-head > span:first-child {
    display: grid;
    gap: 3px;
    min-width: 0;
  }

  .mobile-card-head strong {
    font-size: 15px;
    line-height: 1.35;
  }

  .mobile-card-head small,
  .mobile-card-grid small {
    color: var(--muted);
    font-size: 12px;
  }

  .mobile-card-meta {
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
  }

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

  .mobile-card-grid span {
    display: grid;
    gap: 2px;
    border-radius: var(--radius);
    padding: 9px 10px;
    background: var(--panel-soft);
  }

  .mobile-card-grid strong {
    font-size: 13px;
  }

  .contract-grid {
    grid-template-columns: 1fr;
  }

  .mini-table,
  .report-table {
    gap: 10px;
    padding: 12px;
    background: var(--panel-soft);
  }

  .mini-row.header,
  .report-detail-row.header {
    display: none;
  }

  .mini-row,
  .report-detail-row,
  .report-detail-row.individual-row,
  .report-detail-row.owner-row,
  .mini-row.user-row,
  .mini-row.history-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    background: var(--panel);
    box-shadow: 0 8px 22px rgba(22, 42, 38, 0.05);
  }

  .mini-row > *,
  .report-detail-row > * {
    white-space: normal;
  }

  .date-range,
  .date-range label {
    align-items: stretch;
    flex-direction: column;
    justify-content: stretch;
  }

  .client-form .form-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: end;
    padding: 10px;
  }

  .modal-card {
    max-height: 92vh;
  }
}

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