* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
}

body.ai-modal-open { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button svg, a svg { width: 18px; height: 18px; stroke-width: 1.9; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ai-header {
  position: sticky;
  z-index: var(--z-sticky);
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 68px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: rgba(255, 255, 255, .96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.ai-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
}

.ai-brand img { width: 42px; height: 42px; object-fit: contain; }
.ai-brand span { display: grid; line-height: 1.25; }
.ai-brand strong { font-size: 16px; }
.ai-brand small { color: var(--text-secondary); font-size: 12px; }
.ai-header-actions, .ai-entry-actions, .ai-modal-header-actions, .ai-modal-footer-actions { display: flex; align-items: center; gap: 8px; }
.ai-user { max-width: 220px; overflow: hidden; color: var(--text-secondary); text-overflow: ellipsis; white-space: nowrap; }

.ai-page {
  width: 100%;
  padding: 24px var(--page-inline-gutter) 48px;
}

.ai-card {
  min-width: 0;
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

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

.ai-page-heading h1, .ai-page-heading p, .ai-history-heading h2, .ai-modal-header h2, .ai-modal-header p,
.ai-section-heading h3, .ai-form-group h4, .ai-detail-section h3 { margin: 0; }
.ai-page-heading h1 { margin-top: 2px; font-size: 28px; }
.ai-page-heading > div > p:last-child { margin-top: 5px; color: var(--text-secondary); }

.ai-eyebrow, .ai-step-label {
  margin: 0 0 3px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .06em;
}

.ai-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 15px;
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
  background: var(--surface-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.ai-button:hover { background: var(--surface-muted); }
.ai-button-primary { color: #fff; background: var(--brand); border-color: var(--brand); }
.ai-button-primary:hover { color: #fff; background: var(--brand-hover); border-color: var(--brand-hover); }
.ai-button:disabled { color: var(--text-disabled); background: var(--surface-muted); border-color: var(--border); cursor: not-allowed; }
.ai-button-small { min-height: 36px; padding: 7px 11px; font-size: 13px; }
.ai-create-button { min-width: 146px; }

.profit-ledger-view > .alert-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -7px 0 14px;
}
.profit-ledger-view > .alert-line svg { flex: 0 0 18px; width: 18px; height: 18px; }

.ai-summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
  overflow: hidden;
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.ai-summary-strip > div {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 17px 20px;
  border-right: 1px solid var(--border);
}

.ai-summary-strip > div:last-child { border-right: 0; }
.ai-summary-strip > div > span:last-child { display: grid; min-width: 0; gap: 2px; }
.ai-summary-strip small { color: var(--text-secondary); font-size: 12px; }
.ai-summary-strip strong { overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ai-summary-strip > div:last-child strong { color: var(--brand); }
.ai-summary-icon {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 10px;
}
.ai-summary-icon svg { width: 22px; height: 22px; }

.ai-history-card { padding: 20px; }
.ai-history-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.ai-history-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.ai-scope-tabs { display: inline-flex; min-height: 36px; padding: 3px; background: var(--surface-muted); border-radius: var(--radius-md); }
.ai-scope-tabs button { min-width: 82px; padding: 5px 10px; color: var(--text-secondary); background: transparent; border: 0; border-radius: 6px; cursor: pointer; }
.ai-scope-tabs button.is-active { color: var(--brand); font-weight: 700; background: var(--surface-panel); box-shadow: var(--shadow-sm); }
.ai-search-field { display: grid; grid-template-columns: minmax(180px, 260px) 38px; min-width: 0; }
.ai-search-field input {
  min-width: 0;
  height: 36px;
  padding: 7px 10px;
  color: var(--text);
  background: var(--surface-panel);
  border: 1px solid var(--border-strong);
  border-right: 0;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
}
.ai-search-field button { display: grid; height: 36px; place-items: center; color: var(--text-secondary); background: var(--surface-panel); border: 1px solid var(--border-strong); border-radius: 0 var(--radius-md) var(--radius-md) 0; cursor: pointer; }
.ai-history-status { min-height: 20px; margin: 0 0 9px; color: var(--text-secondary); font-size: 13px; }

.ai-history-table { min-width: 0; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); }
.ai-history-columns, .ai-history-row {
  display: grid;
  grid-template-columns: minmax(142px, .9fr) minmax(260px, 2.2fr) repeat(4, minmax(110px, .8fr)) minmax(88px, .65fr) 58px;
  align-items: center;
}
.ai-history-columns { min-height: 42px; color: var(--text-secondary); font-size: 12px; font-weight: 650; background: var(--surface-muted); border-bottom: 1px solid var(--border); }
.ai-history-columns > span, .ai-history-cell { min-width: 0; padding: 9px 12px; }
.ai-history-columns > span:not(:last-child), .ai-history-cell:not(:last-child) { border-right: 1px solid var(--border); }
.ai-history-row { min-height: 58px; background: var(--surface-panel); border-bottom: 1px solid var(--border); }
.ai-history-row:last-child { border-bottom: 0; }
.ai-history-row:hover { background: #fbfdff; }
.ai-history-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-history-description { color: var(--text); }
.ai-history-money { text-align: right; font-variant-numeric: tabular-nums; }
.ai-history-profit { color: var(--success); font-weight: 700; }
.ai-history-profit.is-negative { color: var(--danger); }
.ai-history-view { display: grid; place-items: center; }
.ai-row-icon-button { display: grid; width: 32px; height: 32px; place-items: center; color: var(--brand); background: transparent; border: 1px solid transparent; border-radius: var(--radius-md); cursor: pointer; }
.ai-row-icon-button:hover { background: var(--brand-soft); border-color: #cfe1f5; }
.ai-row-icon-button svg { width: 17px; height: 17px; }
.ai-history-empty { padding: 54px 18px; color: var(--text-secondary); text-align: center; }
.ai-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; color: var(--text-secondary); font-size: 13px; }

.ai-gate { display: flex; align-items: center; gap: 16px; width: min(560px, 100%); margin: 80px auto; padding: 22px; }
.ai-gate h1 { margin: 0; }
.ai-gate p { margin: 5px 0 0; color: var(--text-secondary); }
.ai-gate.is-error { border-color: #ebc3bd; }
.ai-spinner { flex: 0 0 auto; width: 30px; height: 30px; border: 3px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: ai-spin .8s linear infinite; }
@keyframes ai-spin { to { transform: rotate(360deg); } }

.ai-modal {
  position: fixed;
  z-index: var(--z-modal);
  inset: 0;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(2px);
}

.ai-modal-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(980px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: hidden;
  background: var(--surface-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.ai-create-modal-shell { height: min(920px, calc(100dvh - 32px)); }
.ai-detail-modal-shell { width: min(860px, 100%); height: min(720px, calc(100dvh - 40px)); }

.ai-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 20px;
  background: var(--surface-panel);
  border-bottom: 1px solid var(--border);
}
.ai-modal-header > div:first-child { min-width: 0; }
.ai-modal-header h2 { font-size: 20px; }
.ai-modal-header p:last-child { margin-top: 3px; color: var(--text-secondary); font-size: 13px; }
.ai-model, .ai-form-state, .ai-step-state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  color: var(--text-secondary);
  font-size: 12px;
  background: var(--surface-muted);
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.ai-icon-button { display: grid; flex: 0 0 38px; width: 38px; height: 38px; place-items: center; color: var(--text-secondary); background: var(--surface-panel); border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; }
.ai-icon-button:hover { color: var(--text); background: var(--surface-muted); }

.ai-modal-body { min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.ai-entry-section, .ai-edit-section { padding: 14px 20px; }
.ai-edit-section { border-top: 1px solid var(--border); }
.ai-entry-mode-tabs {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(132px, 1fr));
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.ai-entry-mode-tabs button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 13px;
  color: var(--text-secondary);
  font-weight: 650;
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
.ai-entry-mode-tabs button.is-active { color: var(--brand); background: var(--surface-panel); box-shadow: var(--shadow-sm); }
.ai-entry-mode-tabs button:disabled { color: var(--text-disabled); cursor: not-allowed; opacity: .75; }
.ai-entry-mode-tabs button svg { width: 17px; height: 17px; }
.ai-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.ai-form-heading-actions { display: flex; align-items: center; gap: 7px; }
.ai-section-heading h3 { font-size: 17px; }
.ai-help { margin: 0 0 8px; color: var(--text-secondary); font-size: 13px; }
.ai-text-field { display: grid; gap: 6px; }
.ai-text-field > span { font-weight: 650; }
.ai-text-field textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: 12px 13px;
  color: var(--text);
  line-height: 1.5;
  background: var(--surface-subtle);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
}
.ai-text-field textarea::placeholder { color: var(--text-tertiary); }
.ai-text-field small { justify-self: end; color: var(--text-tertiary); }
.ai-entry-actions { margin-top: 8px; }
.ai-request-status, .ai-form-issues { margin-top: 8px; padding: 7px 10px; color: var(--info); background: var(--info-soft); border-radius: var(--radius-md); }
.ai-request-status.is-error, .ai-form-issues.is-error { color: var(--danger); background: var(--danger-soft); }
.ai-form-issues ul { margin: 0; padding-left: 20px; }
.ai-form-state.is-ready { color: var(--success); background: var(--success-soft); }

.ai-form-group { margin-top: 12px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-md); }
.ai-form-group > h4, .ai-form-group-heading { min-height: 40px; padding: 9px 12px; background: var(--surface-muted); border-bottom: 1px solid var(--border); }
.ai-form-group-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ai-form-group-heading span { color: var(--text-secondary); font-size: 12px; }
.ai-form-lines { display: grid; }
.ai-form-line {
  display: grid;
  grid-template-columns: minmax(120px, .85fr) minmax(150px, 1fr) minmax(220px, 1.2fr) 38px;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--border);
}
.ai-form-line:last-child { border-bottom: 0; }
.ai-form-line > label { display: grid; min-width: 0; gap: 4px; }
.ai-form-line > label > span:first-child { color: var(--text-secondary); font-size: 11px; }
.ai-form-line input, .ai-form-line select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 7px 10px;
  color: var(--text);
  background: var(--surface-panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
}
.ai-form-line input:disabled { color: var(--text); font-weight: 650; background: var(--surface-muted); }
.ai-form-line-spacer { width: 34px; height: 34px; }
.ai-money-input { position: relative; }
.ai-money-input input { padding-right: 30px; text-align: right; font-variant-numeric: tabular-nums; }
.ai-money-input span { position: absolute; top: 50%; right: 10px; color: var(--text-tertiary); transform: translateY(-50%); pointer-events: none; }
.ai-remove-line { display: grid; width: 34px; height: 34px; place-items: center; color: var(--text-tertiary); background: transparent; border: 0; border-radius: var(--radius-md); cursor: pointer; }
.ai-remove-line:hover { color: var(--danger); background: var(--danger-soft); }
.ai-remove-line svg { width: 17px; height: 17px; }
.ai-other-form-line { grid-template-columns: minmax(130px, .9fr) 105px minmax(330px, 1.8fr) 38px; }
.ai-amount-channel { display: grid; grid-template-columns: minmax(110px, .7fr) minmax(190px, 1.3fr); gap: 8px; }
.ai-add-line-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 10px; }
.ai-add-line-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; color: var(--brand); font-weight: 650; background: var(--surface-panel); border: 1px dashed #8cb5dd; border-radius: var(--radius-md); cursor: pointer; }
.ai-add-line-button:hover { background: var(--brand-soft); }

.ai-modal-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 12px 20px max(12px, env(safe-area-inset-bottom));
  background: var(--surface-panel);
  border-top: 1px solid var(--border);
}
.ai-profit-preview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); min-width: 0; overflow: hidden; background: var(--surface-subtle); border: 1px solid var(--border); border-radius: var(--radius-md); }
.ai-profit-preview > div { min-width: 0; padding: 8px 11px; border-right: 1px solid var(--border); }
.ai-profit-preview > div:last-child { border-right: 0; }
.ai-profit-preview span { display: block; color: var(--text-secondary); font-size: 11px; }
.ai-profit-preview strong { display: block; overflow: hidden; margin-top: 2px; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ai-profit-preview-total strong { color: var(--brand); font-size: 18px; }
.ai-modal-footer-actions { flex: 0 0 auto; }
.ai-modal-footer-actions .ai-button { min-width: 100px; }

.ai-detail-body { display: grid; align-content: start; gap: 15px; padding: 18px 20px; }
.ai-detail-profit { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(0, 2.2fr); gap: 16px; padding: 17px; color: #fff; background: var(--brand); border-radius: var(--radius-lg); }
.ai-detail-profit > div:first-child > span { color: rgba(255,255,255,.75); font-size: 12px; }
.ai-detail-profit > div:first-child > strong { display: block; margin-top: 4px; font-size: 30px; font-variant-numeric: tabular-nums; }
.ai-detail-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); overflow: hidden; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18); border-radius: var(--radius-md); }
.ai-detail-metrics > span { min-width: 0; padding: 9px 10px; color: rgba(255,255,255,.74); font-size: 11px; border-right: 1px solid rgba(255,255,255,.18); }
.ai-detail-metrics > span:last-child { border-right: 0; }
.ai-detail-metrics strong { display: block; overflow: hidden; margin-top: 3px; color: #fff; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ai-detail-section { padding: 15px; background: var(--surface-subtle); border: 1px solid var(--border); border-radius: var(--radius-md); }
.ai-detail-section h3 { margin-bottom: 9px; }
.ai-detail-input-text { margin: 0; color: var(--text-secondary); line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.ai-detail-lines { display: grid; gap: 7px; }
.ai-detail-line { display: grid; grid-template-columns: minmax(100px, .8fr) minmax(170px, 1.2fr) minmax(120px, .9fr); align-items: center; gap: 10px; padding: 9px 10px; background: var(--surface-panel); border: 1px solid var(--border); border-radius: var(--radius-md); }
.ai-detail-line > span:nth-child(2) { color: var(--text-secondary); }
.ai-detail-line > strong { text-align: right; font-variant-numeric: tabular-nums; }
.ai-detail-footer { display: flex; justify-content: flex-end; padding: 12px 20px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.ai-detail-footer .ai-button { min-width: 100px; }

@media (max-width: 1120px) {
  .ai-history-columns, .ai-history-row { grid-template-columns: minmax(132px, .9fr) minmax(220px, 2fr) repeat(4, minmax(100px, .8fr)) minmax(80px, .6fr) 54px; }
  .ai-history-table { overflow-x: auto; }
  .ai-history-columns, .ai-history-list { min-width: 1040px; }
  .ai-modal-footer { grid-template-columns: minmax(0, 1fr); }
  .ai-modal-footer-actions { justify-content: flex-end; }
}

@media (max-width: 800px) {
  .ai-page { padding: 18px 14px 36px; }
  .ai-page-heading { align-items: flex-start; }
  .ai-summary-strip > div { padding: 14px; }
  .ai-history-heading { align-items: flex-start; }
  .ai-history-tools { flex-wrap: wrap; }
  .ai-search-field { flex: 1 1 250px; }
  .ai-form-line { grid-template-columns: minmax(100px, .75fr) minmax(120px, .85fr) minmax(190px, 1.2fr) 36px; }
  .ai-other-form-line { grid-template-columns: minmax(110px, .8fr) 96px minmax(300px, 1.7fr) 36px; }
  .ai-detail-profit { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .ai-header { min-height: 60px; }
  .ai-brand img { width: 36px; height: 36px; }
  .ai-brand small, .ai-user { display: none; }
  .ai-page { padding: 13px 9px calc(28px + env(safe-area-inset-bottom)); }
  .ai-page-heading { display: grid; gap: 12px; margin-bottom: 13px; }
  .ai-page-heading h1 { font-size: 24px; }
  .ai-page-heading > div > p:last-child { font-size: 13px; }
  .ai-create-button { width: 100%; }
  .ai-summary-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 12px; }
  .ai-summary-strip > div { display: grid; justify-items: center; gap: 6px; padding: 10px 5px; text-align: center; }
  .ai-summary-icon { width: 34px; height: 34px; flex-basis: 34px; border-radius: 8px; }
  .ai-summary-icon svg { width: 18px; height: 18px; }
  .ai-summary-strip small { font-size: 10px; }
  .ai-summary-strip strong { max-width: 100%; font-size: 13px; }
  .ai-history-card { padding: 13px; border-radius: 10px; }
  .ai-history-heading { display: grid; gap: 10px; }
  .ai-history-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; width: 100%; }
  .ai-scope-tabs { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ai-search-field { grid-template-columns: minmax(0, 1fr) 38px; }
  .ai-history-table { overflow: visible; border: 0; }
  .ai-history-columns { display: none; }
  .ai-history-list { min-width: 0; display: grid; gap: 9px; }
  .ai-history-row {
    position: relative;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
    min-height: 0;
    padding: 12px;
    background: var(--surface-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
  }
  .ai-history-cell { padding: 0; border-right: 0 !important; }
  .ai-history-time { grid-column: 1 / -1; color: var(--text-secondary); font-size: 12px; }
  .ai-history-description { grid-column: 1 / -1; padding-right: 36px; font-weight: 650; white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .ai-history-money { text-align: left; }
  .ai-history-money::before, .ai-history-owner::before { display: block; color: var(--text-tertiary); font-size: 10px; }
  .ai-history-sale::before { content: "销售收入"; }
  .ai-history-purchase::before { content: "采购成本"; }
  .ai-history-expense::before { content: "费用扣减"; }
  .ai-history-profit::before { content: "预计净利润"; }
  .ai-history-owner::before { content: "操作人"; }
  .ai-history-view { position: absolute; top: 38px; right: 9px; }
  .ai-modal { padding: 0; place-items: stretch; }
  .ai-modal-shell, .ai-create-modal-shell, .ai-detail-modal-shell { width: 100vw; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .ai-modal-header { min-height: var(--modal-header-min-height); padding: 13px 12px; }
  .ai-modal-header h2 { font-size: 18px; }
  .ai-modal-header p:last-child { max-width: 290px; font-size: 12px; }
  .ai-modal-header-actions { align-items: flex-start; }
  .ai-model { display: none; }
  .ai-entry-section, .ai-edit-section { padding: 14px 12px; }
  .ai-entry-mode-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .ai-section-heading { gap: 8px; }
  .ai-step-state { max-width: 142px; overflow: hidden; text-overflow: ellipsis; }
  .ai-text-field textarea, .ai-form-line input, .ai-form-line select, .ai-search-field input { font-size: 16px; }
  .ai-text-field textarea { min-height: 132px; resize: none; }
  .ai-entry-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
  .ai-form-line, .ai-other-form-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 7px; padding: 10px; }
  .ai-form-line > label:nth-child(3) { grid-column: 1 / -1; }
  .ai-form-line-spacer { display: none; }
  .ai-other-form-line > label:first-child { grid-column: 1 / -1; }
  .ai-other-form-line > label:nth-child(2) { grid-column: 1 / 2; }
  .ai-other-form-line > label:nth-child(3) { grid-column: 1 / -1; }
  .ai-other-form-line .ai-remove-line { grid-column: 2 / 3; grid-row: 2; justify-self: end; }
  .ai-amount-channel { grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); }
  .ai-add-line-actions { grid-template-columns: minmax(0, 1fr); }
  .ai-modal-footer { gap: 9px; padding: 9px 10px max(9px, env(safe-area-inset-bottom)); }
  .ai-profit-preview { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ai-profit-preview > div { padding: 7px 5px; }
  .ai-profit-preview span { font-size: 9px; }
  .ai-profit-preview strong { font-size: 11px; }
  .ai-profit-preview-total strong { font-size: 13px; }
  .ai-modal-footer-actions { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); }
  .ai-modal-footer-actions .ai-button { width: 100%; min-width: 0; }
  .ai-detail-body { padding: 13px 12px; }
  .ai-detail-profit { padding: 14px; }
  .ai-detail-profit > div:first-child > strong { font-size: 26px; }
  .ai-detail-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ai-detail-metrics > span:nth-child(2) { border-right: 0; }
  .ai-detail-metrics > span:nth-child(-n+2) { border-bottom: 1px solid rgba(255,255,255,.18); }
  .ai-detail-line { grid-template-columns: minmax(90px, .8fr) minmax(0, 1.2fr); }
  .ai-detail-line > strong { grid-column: 1 / -1; text-align: left; }
  .ai-detail-footer { padding: 9px 10px max(9px, env(safe-area-inset-bottom)); }
  .ai-detail-footer .ai-button { width: 100%; }
}

@media (max-width: 360px) {
  .ai-brand strong { font-size: 14px; }
  .ai-header .ai-button { min-height: 38px; padding-inline: 11px; }
  .ai-summary-strip strong { font-size: 12px; }
  .ai-history-tools { grid-template-columns: minmax(0, 1fr); }
  .ai-history-tools > .ai-button { width: 100%; }
  .ai-amount-channel { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-spinner { animation-duration: 1.8s; }
}
