:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f2f4f6;
  --surface-blue: #e8f3ff;
  --text: #191f28;
  --text-soft: #4e5968;
  --text-muted: #8b95a1;
  --line: #e5e8eb;
  --line-strong: #d1d6db;
  --blue: #3182f6;
  --blue-strong: #0064ff;
  --green: #00a86b;
  --red: #f04452;
  --orange: #f59f00;
  --violet: #7c5cff;
  --shadow: 0 16px 42px rgba(25, 31, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "Apple SD Gothic Neo",
    "Noto Sans KR",
    sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 28px 20px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--blue-strong);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 1.35;
}

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

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

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

.nav-item:hover,
.nav-item.is-active {
  background: var(--surface-blue);
  color: var(--blue-strong);
  font-weight: 700;
}

.nav-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sidebar-footer span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

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

.main-shell {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 96px;
  padding: 22px 36px;
  border-bottom: 1px solid rgba(229, 232, 235, 0.8);
  background: rgba(247, 248, 250, 0.9);
  backdrop-filter: blur(18px);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
  line-height: 1.25;
}

h2 {
  margin-bottom: 16px;
  font-size: 20px;
  line-height: 1.35;
}

h3 {
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.35;
}

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

.db-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.db-status.is-online {
  border-color: #c8dcff;
  background: var(--surface-blue);
  color: var(--blue-strong);
}

.db-status.is-saving {
  border-color: #ffe08a;
  background: #fff9db;
  color: #8a5a00;
}

.db-status.is-error {
  border-color: #ffd6dc;
  background: #fff1f3;
  color: var(--red);
}

.select-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
}

.select-field select,
.filter-select,
.search-input,
.form-field input,
.form-field select,
.form-field textarea {
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}

.primary-action,
.secondary-action,
.ghost-action,
.danger-action {
  min-height: 42px;
  padding: 0 15px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-action {
  border: 1px solid var(--blue-strong);
  background: var(--blue-strong);
  color: #fff;
}

.primary-action:disabled,
.secondary-action:disabled,
.ghost-action:disabled,
.danger-action:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary-action {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
}

.ghost-action {
  border: 0;
  background: transparent;
  color: var(--blue-strong);
}

.ghost-action.compact {
  min-height: 32px;
  padding: 0 8px;
  font-size: 12px;
}

.danger-action {
  border: 1px solid rgba(240, 68, 82, 0.2);
  background: #fff1f3;
  color: var(--red);
}

.workspace {
  display: grid;
  gap: 28px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 30px 36px 80px;
}

body.is-auth-view .app-shell {
  grid-template-columns: 1fr;
}

body.is-auth-view .sidebar,
body.is-auth-view .mobile-nav {
  display: none;
}

body.is-auth-view .topbar {
  display: none;
}

body.is-auth-view .workspace {
  max-width: none;
  min-height: 100vh;
  padding: 32px 20px;
}

.auth-screen {
  display: grid;
  min-height: calc(100vh - 64px);
  place-items: center;
}

.auth-card {
  width: min(100%, 420px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand-mark {
  margin-bottom: 18px;
}

.auth-eyebrow {
  margin-bottom: 8px;
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 900;
}

.auth-card h2 {
  margin-bottom: 10px;
  font-size: 24px;
}

.auth-copy {
  margin-bottom: 24px;
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.6;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

.auth-error {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(240, 68, 82, 0.2);
  border-radius: 8px;
  background: #fff1f3;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.auth-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 800;
}

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

.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.dashboard-grid.is-four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

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

.metric-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 142px;
  padding: 22px 20px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(25, 31, 40, 0.03);
}

.metric-card.is-tall {
  grid-column: 5;
  grid-row: 1 / span 2;
}

.metric-card.is-tall strong {
  font-size: 32px;
}

.metric-card::before {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  left: -1px;
  height: 3px;
  border-radius: 8px 8px 0 0;
  background: var(--line-strong);
}

.metric-card strong {
  display: block;
  margin: 16px 0 0;
  font-size: 28px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.metric-card span,
.muted,
.table-caption {
  color: var(--text-muted);
}

.metric-card span {
  font-size: 13px;
  font-weight: 800;
}

.metric-card small {
  color: var(--text-soft);
  font-size: 12px;
  line-height: 1.45;
}

.metric-card.is-blue {
  border-color: var(--line);
  background: var(--surface);
}

.metric-card.is-blue::before {
  background: var(--blue-strong);
}

.metric-card.is-green::before {
  background: var(--green);
}

.metric-card.is-red::before {
  background: var(--red);
}

.metric-card.is-red strong {
  color: var(--red);
}

.metric-card.is-green strong {
  color: var(--green);
}

.metric-card.is-blue strong {
  color: var(--blue-strong);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.wide-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.surface-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

.panel-header h2,
.panel-header h3 {
  margin-bottom: 2px;
}

.panel-header p {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

.project-ledger-wrap {
  max-height: calc(100vh - 128px);
  overflow: auto;
  overscroll-behavior: contain;
}

.project-scope-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.project-scope-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.scope-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 800;
}

.scope-tab strong {
  color: var(--text-muted);
  font-size: 12px;
}

.scope-tab.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(25, 31, 40, 0.08);
}

.scope-tab.is-active strong {
  color: var(--blue-strong);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.project-table {
  min-width: 2264px;
  table-layout: fixed;
}

.card-table {
  min-width: 2255px;
}

.product-table {
  min-width: 1008px;
}

.expense-table {
  min-width: 1220px;
}

.expense-review-table {
  min-width: 1440px;
}

.expense-card-table {
  min-width: 760px;
}

.expense-merchant-table {
  min-width: 760px;
}

.project-table.card-table .col-request-date {
  width: 170px;
}

.project-table.card-table .col-stage {
  width: 170px;
}

.project-table .col-request-date {
  width: 82px;
}

.project-table .col-brand-customer {
  width: 250px;
}

.project-table .col-product {
  width: 150px;
}

.project-table .col-category {
  width: 112px;
}

.project-table .col-money {
  width: 126px;
}

.project-table .col-extra-payment {
  width: 132px;
}

.project-table .col-payment {
  width: 116px;
}

.project-table .col-date {
  width: 170px;
}

.project-table .col-payment-date {
  width: 170px;
}

.project-table .col-tax {
  width: 108px;
}

.project-table .col-stage {
  width: 188px;
}

.project-table .col-margin {
  width: 160px;
}

.product-table .col-product-name {
  width: 230px;
}

.product-table .col-product-category {
  width: 108px;
}

.product-table .col-product-pricing {
  width: 100px;
}

.product-table .col-money {
  width: 112px;
}

.product-table .col-product-quota {
  width: 90px;
}

.product-table .col-product-plan {
  width: 260px;
}

.product-table .col-product-status {
  width: 90px;
}

.product-table th:last-child,
.product-table td:not(.empty-state):last-child {
  position: static;
  right: auto;
  z-index: auto;
  box-shadow: none;
}

.project-table .col-type {
  width: 92px;
}

.project-table .col-memo {
  width: 280px;
}

.project-table .col-row-action {
  width: 72px;
}

.expense-table .col-expense-date {
  width: 150px;
}

.expense-table .col-expense-category {
  width: 130px;
}

.expense-table .col-expense-usage {
  width: 230px;
}

.expense-table .col-expense-payment {
  width: 120px;
}

.expense-table .col-expense-card {
  width: 128px;
}

.expense-review-table .col-expense-reason {
  width: 170px;
}

.expense-review-table .col-expense-review-action {
  width: 116px;
}

.expense-card-table .col-expense-card-last4 {
  width: 160px;
}

.expense-card-table .col-expense-card-category {
  width: 150px;
}

.expense-card-table .col-expense-card-memo {
  width: 360px;
}

.expense-merchant-table .col-expense-merchant-usage {
  width: 320px;
}

.expense-merchant-table .col-expense-merchant-meta {
  width: 170px;
}

.project-table td {
  height: 68px;
}

.project-table th,
.project-table td {
  text-align: center;
}

.project-table td.number,
.project-table th.number,
.project-table .inline-cell.number {
  text-align: center;
}

.project-table .inline-cell,
.project-table .mini-select {
  text-align: center;
  text-align-last: center;
}

.project-table .blank-row-button {
  text-align: center;
}

.project-table th:last-child,
.project-table td:not(.empty-state):last-child {
  position: sticky;
  right: 0;
  z-index: 3;
  box-shadow: -1px 0 0 var(--line);
}

.project-table th:last-child {
  z-index: 9;
  background: #fbfcfd;
}

.project-table td:not(.empty-state):last-child {
  background: var(--surface);
}

.project-table tr.row-clickable:hover td:last-child {
  background: #f9fafb;
}

.project-table tr.row-clickable.is-selected td:last-child {
  background: var(--surface-blue);
}

.project-table .blank-project-row td:last-child {
  background: #fcfdff;
}

.project-table .blank-project-row:focus-within td:last-child,
.project-table .blank-project-row:hover td:last-child {
  background: #f8fbff;
}

.project-ledger-table th:first-child,
.project-ledger-table td:not(.empty-state):first-child,
.project-ledger-table th:nth-child(2),
.project-ledger-table td:not(.empty-state):nth-child(2) {
  position: sticky;
  z-index: 5;
  background: var(--surface);
}

.project-ledger-table th:first-child,
.project-ledger-table td:not(.empty-state):first-child {
  left: 0;
}

.project-ledger-table th:nth-child(2),
.project-ledger-table td:not(.empty-state):nth-child(2) {
  left: 82px;
  box-shadow: 1px 0 0 var(--line);
}

.project-ledger-table th:first-child,
.project-ledger-table th:nth-child(2) {
  z-index: 11;
  background: #fbfcfd;
}

.project-ledger-table thead th {
  position: sticky;
  top: 0;
  z-index: 8;
  background: #fbfcfd;
  box-shadow: 0 1px 0 var(--line);
}

.project-ledger-table thead th:first-child,
.project-ledger-table thead th:nth-child(2),
.project-ledger-table thead th:last-child {
  z-index: 12;
}

.project-ledger-table tr.row-clickable:hover td:first-child,
.project-ledger-table tr.row-clickable:hover td:nth-child(2) {
  background: #f9fafb;
}

.project-ledger-table tr.row-clickable.is-selected td:first-child,
.project-ledger-table tr.row-clickable.is-selected td:nth-child(2) {
  background: var(--surface-blue);
}

.project-ledger-table .blank-project-row td:first-child,
.project-ledger-table .blank-project-row td:nth-child(2) {
  background: #fcfdff;
}

.project-ledger-table .blank-project-row:focus-within td:first-child,
.project-ledger-table .blank-project-row:focus-within td:nth-child(2),
.project-ledger-table .blank-project-row:hover td:first-child,
.project-ledger-table .blank-project-row:hover td:nth-child(2) {
  background: #f8fbff;
}

.product-table th:last-child,
.product-table td:not(.empty-state):last-child {
  position: static;
  right: auto;
  z-index: auto;
  box-shadow: none;
}

.product-table th:last-child {
  background: #fbfcfd;
}

.product-table td:not(.empty-state):last-child {
  background: transparent;
}

th,
td {
  height: 46px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fbfcfd;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

td.number,
th.number {
  text-align: right;
}

tr:last-child td {
  border-bottom: 0;
}

tr.row-clickable:hover {
  background: #f9fafb;
}

tr.row-clickable.is-selected {
  background: var(--surface-blue);
}

tr.row-clickable.is-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--blue-strong);
}

.blank-project-row td {
  background: #fcfdff;
}

.blank-project-row .inline-cell,
.blank-project-row .mini-select {
  border-style: dashed;
  color: var(--text-muted);
}

.blank-project-row:focus-within td,
.blank-project-row:hover td {
  background: #f8fbff;
}

.table-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.blank-row-button {
  width: 100%;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--blue-strong);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.blank-row-button:hover {
  background: var(--surface-blue);
}

.row-delete-button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--red);
  font-size: 12px;
  font-weight: 800;
}

.row-delete-button:hover {
  border-color: #ffd6dc;
  background: #fff1f3;
}

.row-confirm-button {
  height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(0, 166, 118, 0.2);
  border-radius: 8px;
  background: #ecfdf6;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.row-confirm-button:hover {
  border-color: rgba(0, 166, 118, 0.34);
  background: #dff9ef;
}

.blank-delete-button {
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.expense-review-panel {
  border-top: 3px solid var(--blue-strong);
}

.gmail-panel {
  border-top: 3px solid var(--line-strong);
}

.ai-panel {
  border-top: 3px solid var(--blue-strong);
}

.gmail-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 900;
}

.gmail-status.is-online {
  background: #ecfdf6;
  color: var(--green);
}

.gmail-status.is-pending {
  background: #fff8e8;
  color: var(--orange);
}

.gmail-config-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 16px 20px;
}

.gmail-config-grid .form-field.full {
  grid-column: span 2;
}

.gmail-config-grid .form-field input[readonly] {
  color: var(--text-soft);
}

.gmail-toggle,
.gmail-meta {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.gmail-toggle {
  gap: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.gmail-meta {
  justify-content: space-between;
  gap: 10px;
}

.gmail-meta span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.gmail-meta strong {
  color: var(--text);
  font-size: 13px;
  font-weight: 900;
}

.gmail-message {
  margin: 0 20px 12px;
  padding: 10px 12px;
  border: 1px solid #c8dcff;
  border-radius: 8px;
  background: var(--surface-blue);
  color: var(--blue-strong);
  font-size: 13px;
  font-weight: 800;
}

.gmail-message.is-error {
  border-color: #ffd6dc;
  background: #fff1f3;
  color: var(--red);
}

.gmail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 20px 16px;
  flex-wrap: wrap;
}

.review-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--surface-blue);
  color: var(--blue-strong);
  font-size: 12px;
  font-weight: 900;
}

.review-reason {
  display: grid;
  gap: 4px;
  justify-items: center;
  white-space: normal;
}

.review-reason strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.review-reason span,
.review-reason em {
  color: var(--text-soft);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.review-reason em {
  color: var(--red);
}

.review-actions {
  display: grid;
  gap: 6px;
}

.expense-review-table tr.is-review-duplicate td {
  background: #fff8e8;
}

.search-box,
.filter-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.search-box {
  min-width: 280px;
  padding: 0 12px;
}

.filter-box {
  padding: 0 10px;
}

.filter-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.search-input {
  width: 100%;
}

.filter-select {
  min-width: 132px;
}

.badge,
.status-select,
.mini-select {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
}

.badge.blue,
.status-select.blue {
  background: var(--surface-blue);
  color: var(--blue-strong);
}

.badge.green,
.status-select.green {
  background: #eafaf2;
  color: var(--green);
}

.badge.orange,
.status-select.orange {
  background: #fff6db;
  color: #b76b00;
}

.badge.red,
.status-select.red {
  background: #fff1f3;
  color: var(--red);
}

.badge.gray,
.status-select.gray {
  background: var(--surface-soft);
  color: var(--text-soft);
}

.badge.violet,
.status-select.violet {
  background: #f1edff;
  color: var(--violet);
}

.status-select,
.mini-select {
  outline: 0;
  appearance: none;
  height: 34px;
}

.status-select {
  min-width: 110px;
  border-color: transparent;
}

.inline-cell {
  width: 100%;
  height: 34px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  line-height: 34px;
}

textarea.inline-cell {
  display: block;
  min-height: 52px;
  line-height: 1.45;
}

.inline-cell.number {
  text-align: right;
  padding-right: 10px;
}

.money-subtext {
  display: block;
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.inline-cell:focus {
  border-color: var(--blue);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(49, 130, 246, 0.12);
}

.mini-select {
  min-width: 88px;
  width: 100%;
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
  margin: 0;
}

.status-inline {
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
  padding-right: 24px;
}

.status-inline.blue {
  background: var(--surface-blue);
  color: var(--blue-strong);
}

.status-inline.green {
  background: #eafaf2;
  color: var(--green);
}

.status-inline.orange {
  background: #fff6db;
  color: #b76b00;
}

.status-inline.red {
  background: #fff1f3;
  color: var(--red);
}

.status-inline.gray {
  background: var(--surface-soft);
  color: var(--text-soft);
}

.status-inline.violet {
  background: #f1edff;
  color: var(--violet);
}

.mini-select.status-action {
  min-width: 128px;
  width: 128px;
  flex: 0 0 auto;
}

.stage-cell-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.stage-history-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.stage-history-button:hover {
  border-color: #c8dcff;
  background: var(--surface-blue);
  color: var(--blue-strong);
}

.extra-payment-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.extra-payment-button small {
  color: var(--text-soft);
  font-size: 10px;
  font-weight: 800;
}

.extra-payment-button:hover,
.extra-payment-button.has-extra {
  border-color: #c8dcff;
  background: var(--surface-blue);
  color: var(--blue-strong);
}

.stage-history-placeholder {
  visibility: hidden;
  pointer-events: none;
}

.inline-cell.deadline-watch {
  border-color: #ffe08a;
  background: #fff9db;
  color: #8a5a00;
  font-weight: 800;
}

.inline-cell.deadline-warning {
  border-color: #ffd09a;
  background: #fff4e6;
  color: #b76b00;
  font-weight: 800;
}

.inline-cell.deadline-danger {
  border-color: rgba(240, 68, 82, 0.32);
  background: #fff1f3;
  color: var(--red);
  font-weight: 800;
}

.brand-customer-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(78px, 0.65fr);
  gap: 6px;
}

.memo-cell {
  white-space: normal;
}

.inline-memo {
  height: 54px;
  padding-top: 7px;
  padding-bottom: 7px;
  resize: vertical;
  white-space: normal;
}

.project-stage-panel {
  overflow: hidden;
}

.stage-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(154px, 1fr));
  gap: 1px;
  overflow-x: auto;
  background: var(--line);
}

.stage-card {
  min-width: 154px;
  padding: 14px;
  background: var(--surface);
}

.stage-card.blue {
  box-shadow: inset 0 3px 0 var(--blue-strong);
}

.stage-card.green {
  box-shadow: inset 0 3px 0 var(--green);
}

.stage-card.orange {
  box-shadow: inset 0 3px 0 var(--orange);
}

.stage-card.violet {
  box-shadow: inset 0 3px 0 var(--violet);
}

.stage-card.red {
  box-shadow: inset 0 3px 0 var(--red);
}

.stage-card.gray {
  box-shadow: inset 0 3px 0 var(--line-strong);
}

.stage-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.stage-heading span {
  font-size: 13px;
  font-weight: 800;
}

.stage-heading strong {
  color: var(--text-muted);
  font-size: 12px;
}

.stage-project-list {
  display: grid;
  gap: 7px;
  min-height: 108px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.stage-project-list li {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.stage-project-list strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-project-list span,
.stage-empty,
.stage-more {
  color: var(--text-muted);
  font-size: 11px;
}

.stage-more {
  font-weight: 800;
}

.amount-up {
  color: var(--blue-strong);
  font-weight: 800;
}

.amount-good {
  color: var(--green);
  font-weight: 800;
}

.amount-risk {
  color: var(--red);
  font-weight: 800;
}

.stack-list {
  display: grid;
  gap: 10px;
  padding: 18px 20px;
}

.stack-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.progress-track {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--surface-soft);
}

.progress-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.progress-fill.green {
  background: var(--green);
}

.progress-fill.orange {
  background: var(--orange);
}

.progress-fill.red {
  background: var(--red);
}

.progress-fill.gray {
  background: var(--line-strong);
}

.progress-fill.violet {
  background: var(--violet);
}

.dashboard-progress {
  margin-top: 8px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--line);
}

.summary-cell {
  padding: 18px;
  background: var(--surface);
}

.summary-cell span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.summary-cell strong {
  display: block;
  font-size: 20px;
}

.summary-cell small {
  display: block;
  margin-top: 7px;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.detail-panel {
  position: sticky;
  top: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.detail-body {
  display: grid;
  gap: 14px;
  padding: 18px 20px 20px;
}

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

.detail-kpis {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-kpis div {
  min-height: 72px;
  padding: 12px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.detail-kpis span,
.detail-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-kpis strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.detail-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.detail-field.full {
  grid-column: 1 / -1;
}

.detail-field input,
.detail-field select,
.detail-field textarea {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
}

.detail-field textarea {
  min-height: 84px;
  padding: 10px;
  resize: vertical;
}

.detail-field input:focus,
.detail-field select:focus,
.detail-field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(49, 130, 246, 0.12);
}

.detail-actions {
  display: flex;
  grid-column: 1 / -1;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 4px;
}

.project-stage-toolbar {
  display: flex;
  grid-column: 1 / -1;
  gap: 8px;
  justify-content: flex-start;
  padding: 0 0 4px;
}

.detail-row {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  min-height: 26px;
}

.detail-row span:first-child {
  color: var(--text-muted);
  font-size: 12px;
}

.detail-row strong,
.detail-row span:last-child {
  min-width: 0;
  word-break: keep-all;
}

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

.lane {
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.lane strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.lane-list {
  display: grid;
  gap: 8px;
}

.lane-item {
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 12px;
}

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

.product-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.product-card strong {
  font-size: 17px;
}

.product-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.product-price {
  display: grid;
  gap: 5px;
}

.product-price span {
  color: var(--text-muted);
  font-size: 12px;
}

.product-price b {
  font-size: 22px;
}

.modal-root:empty {
  display: none;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(25, 31, 40, 0.34);
}

.modal {
  width: min(720px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 24px 14px;
}

.modal-header h2 {
  margin-bottom: 0;
}

.close-button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-soft);
  font-size: 18px;
}

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

.form-field {
  display: grid;
  gap: 8px;
}

.form-field.full {
  grid-column: 1 / -1;
}

.form-error.full {
  grid-column: 1 / -1;
}

.form-field label,
.form-field span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.form-field textarea {
  min-height: 92px;
  padding: 12px;
  resize: vertical;
}

.form-error {
  min-height: 42px;
  padding: 12px;
  border: 1px solid #ffd6dc;
  border-radius: 8px;
  background: #fff1f3;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.stage-history-modal {
  max-width: 620px;
}

.stage-history-modal.is-wide {
  max-width: 860px;
}

.extra-payments-modal {
  width: min(1120px, 100%);
}

.extra-payment-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 24px 14px;
}

.extra-payment-summary div {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.extra-payment-summary span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.extra-payment-summary strong {
  font-size: 18px;
  font-weight: 900;
}

.extra-payment-wrap {
  margin: 0 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.extra-payment-table {
  min-width: 1008px;
  table-layout: fixed;
}

.extra-payment-table th,
.extra-payment-table td {
  text-align: center;
}

.extra-payment-table td.number,
.extra-payment-table th.number,
.extra-payment-table .inline-cell.number {
  text-align: center;
}

.extra-payment-table .inline-cell,
.extra-payment-table .mini-select {
  text-align: center;
  text-align-last: center;
}

.extra-payment-table .col-extra-date {
  width: 132px;
}

.extra-payment-table .col-extra-item {
  width: 132px;
}

.extra-payment-table .col-extra-money {
  width: 124px;
}

.extra-payment-table .col-extra-terms {
  width: 124px;
}

.extra-payment-table .col-extra-tax {
  width: 112px;
}

.extra-payment-table .col-extra-action {
  width: 72px;
}

.stage-history-list {
  display: grid;
  gap: 8px;
  padding: 0 24px 4px;
}

.stage-history-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stage-history-item.is-voided {
  background: var(--surface-soft);
  opacity: 0.72;
}

.stage-history-index {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.stage-history-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.stage-history-title,
.stage-history-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stage-history-meta {
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 700;
}

.stage-history-item.is-wide .stage-history-title,
.stage-history-item.is-wide .stage-history-meta {
  justify-content: flex-start;
}

.stage-history-voided {
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
}

.stage-history-toggle {
  height: 32px;
  padding: 0 10px;
  border: 1px solid #ffd6dc;
  border-radius: 8px;
  background: #fff1f3;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.stage-history-toggle.is-restore {
  border-color: #c8dcff;
  background: var(--surface-blue);
  color: var(--blue-strong);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px 24px;
  border-top: 1px solid var(--line);
}

.empty-state {
  padding: 42px 20px;
  color: var(--text-muted);
  text-align: center;
}

.mobile-nav {
  display: none;
}

@media (max-width: 1180px) {
  .dashboard-kpi-grid,
  .dashboard-grid,
  .dashboard-grid.is-four,
  .dashboard-grid.is-two,
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card.is-tall {
    grid-column: span 2;
    grid-row: auto;
  }

  .dashboard-panel-grid,
  .two-column,
  .split-layout {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }

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

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .workspace {
    padding: 20px 16px 92px;
  }

  .summary-strip,
  .dashboard-kpi-grid,
  .dashboard-grid,
  .dashboard-grid.is-four,
  .dashboard-grid.is-two,
  .dashboard-panel-grid,
  .lane-grid,
  .product-grid {
    grid-template-columns: 1fr;
  }

  .metric-card.is-tall {
    grid-column: auto;
  }

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

  .detail-form,
  .detail-kpis {
    grid-template-columns: 1fr;
  }

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

  .mobile-nav {
    position: fixed;
    right: 12px;
    bottom: 12px;
    left: 12px;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
  }

  .mobile-nav-item {
    min-height: 38px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 800;
  }

  .mobile-nav-item.is-active {
    background: var(--surface-blue);
    color: var(--blue-strong);
  }
}

@media (max-width: 560px) {
  h1 {
    font-size: 23px;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .select-field,
  .primary-action {
    width: 100%;
    justify-content: center;
  }

  .metric-card strong {
    font-size: 24px;
  }

  .toolbar,
  .toolbar-group {
    align-items: stretch;
    width: 100%;
  }

  .filter-box,
  .filter-select,
  .secondary-action,
  .ghost-action {
    width: 100%;
  }
}
