:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #202833;
  --muted: #667085;
  --line: #d9e0ea;
  --soft-line: #edf1f6;
  --accent: #1f6fb2;
  --accent-strong: #19598e;
  --danger: #b42318;
  --ok: #0f766e;
  --warn: #a16207;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 13px;
}

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

button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 5px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text);
  line-height: 1.35;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

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

button.ghost {
  border-color: transparent;
  background: transparent;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 6px 8px;
  background: #fff;
  color: var(--text);
  min-height: 32px;
}

label span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 18%, rgba(31, 111, 178, 0.24), transparent 28%),
    radial-gradient(circle at 82% 22%, rgba(15, 118, 110, 0.18), transparent 25%),
    linear-gradient(135deg, #eef6ff 0%, #f7fbff 42%, #eefaf7 100%);
}

.login-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(31, 111, 178, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(31, 111, 178, 0.08) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(120deg, rgba(0, 0, 0, 0.9), transparent 72%);
}

.login-shell::after {
  content: "";
  position: absolute;
  width: min(760px, 88vw);
  height: min(760px, 88vw);
  right: -220px;
  bottom: -300px;
  border: 1px solid rgba(31, 111, 178, 0.16);
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 80px rgba(255, 255, 255, 0.28),
    inset 0 0 0 160px rgba(31, 111, 178, 0.05);
}

.login-panel {
  width: min(390px, 100%);
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(217, 224, 234, 0.86);
  border-radius: 10px;
  padding: 26px;
  display: grid;
  gap: 14px;
  box-shadow: 0 24px 70px rgba(31, 89, 142, 0.18);
  backdrop-filter: blur(18px);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #0f766e);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 12px 28px rgba(31, 111, 178, 0.28);
}

.login-brand h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

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

.login-panel input {
  min-height: 38px;
  border-color: #d3dde9;
  background: rgba(255, 255, 255, 0.92);
}

.login-panel button {
  min-height: 40px;
}

.login-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 24px;
}

.remember-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: auto;
  cursor: pointer;
  color: var(--muted);
}

.remember-line input {
  width: 15px;
  min-height: 15px;
  height: 15px;
  margin: 0;
  padding: 0;
}

.remember-line span {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.app {
  min-height: 100vh;
  padding: 14px 14px 14px 204px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

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

.top-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.module-tabs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  position: fixed;
  left: 14px;
  top: 14px;
  width: 178px;
  height: calc(100vh - 28px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(16, 24, 40, 0.06);
}

.module-tabs button {
  width: 100%;
  min-width: 0;
  border-color: var(--line);
  background: #fff;
  font-weight: 700;
  text-align: left;
  padding: 9px 10px;
}

.module-tabs button.active {
  border-color: var(--accent);
  background: #eaf4ff;
  color: var(--accent);
}

.workspace {
  display: grid;
  gap: 12px;
}

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

.filters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  min-width: 0;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.04);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.section-title h2 {
  margin: 0;
  font-size: 15px;
}

.section-title span {
  color: var(--muted);
}

.section-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.dashboard-panel .stats-list {
  grid-template-columns: 1fr;
}

.settings-shell {
  display: grid;
  gap: 12px;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--soft-line);
  padding: 8px 7px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.row-no {
  color: var(--accent);
  font-weight: 800;
  width: 54px;
}

.list-amount {
  color: var(--ok);
  font-weight: 800;
}

.type-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.type-chip.general {
  background: #ecfdf5;
  color: var(--ok);
}

.type-chip.private {
  background: #fff7ed;
  color: var(--warn);
}

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

.solution-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.solution-card-main {
  min-width: 0;
}

.solution-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.solution-title-row h3 {
  margin: 0;
  min-width: 0;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.solution-card p {
  margin: 0 0 8px;
  color: var(--text);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

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

.solution-detail {
  display: grid;
  gap: 12px;
}

.solution-content {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.85;
  white-space: normal;
  overflow-wrap: anywhere;
}

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

.row-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.row-actions.compact-actions {
  align-items: center;
  flex-wrap: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2f7;
  color: #344054;
}

.badge.pending {
  background: #fff7d6;
  color: var(--warn);
}

.badge.approved,
.badge.paid {
  background: #dff7f3;
  color: var(--ok);
}

.badge.rejected {
  background: #fde7e4;
  color: var(--danger);
}

.badge.deleted {
  background: #eef2f7;
  color: #667085;
}

.badge.draft,
.badge.unpaid {
  background: #fff7d6;
  color: var(--warn);
}

.badge.submitted {
  background: #e8f1fb;
  color: var(--accent);
}

.stats-list {
  display: grid;
  gap: 12px;
}

.dashboard-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.overview-card {
  display: grid;
  gap: 5px;
  min-height: 96px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.04);
}

.overview-card span {
  color: var(--muted);
  font-weight: 700;
}

.overview-card strong {
  color: var(--text);
  font-size: 22px;
  line-height: 1.15;
}

.overview-card em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.overview-card.primary {
  border-color: rgba(15, 118, 110, 0.24);
  background: linear-gradient(180deg, #f0fdfa 0%, #ffffff 100%);
}

.overview-card.primary strong {
  color: var(--ok);
}

.overview-card.accent {
  border-color: rgba(37, 99, 235, 0.22);
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
}

.overview-card.accent strong {
  color: var(--accent);
}

.dashboard-chart-panel {
  display: grid;
  gap: 8px;
}

.dashboard-chart-panel .section-title {
  margin-bottom: 0;
}

.dashboard-chart-panel h3 {
  margin: 0;
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.stat-item {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.stat-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.stat-card-head strong {
  font-size: 14px;
}

.stat-card-head span {
  color: var(--muted);
  font-size: 12px;
}

.stat-total {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.stat-total span {
  color: var(--muted);
}

.stat-total strong {
  color: var(--ok);
  font-size: 20px;
}

.stat-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.stat-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--ok));
}

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

.stat-money-grid span {
  min-width: 0;
  border-radius: 7px;
  background: #f8fafc;
  padding: 7px;
  color: var(--muted);
}

.stat-money-grid b {
  display: block;
  margin-top: 2px;
  color: var(--text);
}

.stat-breakdown {
  display: grid;
  gap: 7px;
}

.stat-break-row {
  display: grid;
  grid-template-columns: 74px minmax(80px, 1fr) 78px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.stat-break-row > span,
.stat-break-row > b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-break-row > b {
  color: var(--text);
  text-align: right;
}

.stat-mini-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #eef2f7;
}

.stat-mini-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.stat-mini-bar.hotel i {
  background: #0f766e;
}

.stat-mini-bar.local i {
  background: #a16207;
}

.stat-mini-bar.misc i {
  background: #7c3aed;
}

.stat-mini-bar.general i {
  background: #2563eb;
}

.stat-mini-bar.subsidy i {
  background: #059669;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  color: var(--muted);
  font-size: 12px;
}

.stat-paid {
  color: var(--ok);
  font-weight: 800;
}

dialog {
  border: 0;
  border-radius: 7px;
  padding: 0;
  width: min(1040px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 60px rgba(16, 24, 40, 0.18);
}

dialog::backdrop {
  background: rgba(17, 24, 39, 0.45);
}

.wide-dialog > form,
.wide-dialog > div:not(.dialog-head) {
  padding: 0 14px 14px;
}

.password-dialog {
  width: min(420px, calc(100vw - 28px));
}

.password-dialog .form-grid {
  grid-template-columns: 1fr;
  padding: 14px;
}

.password-dialog .dialog-actions {
  padding: 10px 14px 14px;
}

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

.dialog-head h2 {
  margin: 0;
  font-size: 16px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 7px;
  margin: 12px 0;
  padding: 10px;
}

legend {
  padding: 0 6px;
  font-weight: 600;
}

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

.span-2 {
  grid-column: span 2;
}

.field-hint {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.items-box {
  display: grid;
  gap: 8px;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #fbfcfe;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.item-head-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.item-line-no {
  color: var(--accent);
  font-weight: 700;
}

.item-head strong {
  font-size: 14px;
}

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

.form-receipt-field {
  align-self: end;
}

.form-receipt-box {
  min-height: 32px;
  border: 1px dashed #b9c8da;
  border-radius: 5px;
  background: #f8fbff;
  padding: 6px 8px;
  display: grid;
  gap: 6px;
}

.form-receipt-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.form-receipt-box em {
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-receipt-box input {
  flex: 1 1 220px;
  min-height: 28px;
  padding: 3px 0;
  border: 0;
  background: transparent;
}

.receipt-preview-btn {
  min-height: 28px;
  padding: 4px 8px;
  color: var(--accent);
  border-color: #b7cce3;
  background: #fff;
}

.line-actions,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.line-actions {
  justify-content: flex-start;
  margin-top: 8px;
}

.dialog-actions {
  position: sticky;
  bottom: 0;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 10px 0 0;
}

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

.detail-sheet {
  background: #fff;
}

.detail-sheet-head {
  text-align: center;
  padding: 6px 0 2px;
}

.detail-sheet-head h2 {
  margin: 0;
  color: #172033;
  font-size: 20px;
  line-height: 1.35;
  font-weight: 700;
}

.detail-sheet-sub {
  margin-top: 5px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.detail-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 10px 0;
}

.detail-cell {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  background: #fbfcfe;
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-cell span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}

.amount-cell {
  color: var(--ok);
  font-size: 15px;
  font-weight: 800;
  background: #f0fdfa;
  border-color: #bce8df;
}

.detail-section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
  margin: 14px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.detail-section-head h3 {
  margin: 0;
  font-size: 15px;
}

.detail-section-head span {
  color: var(--muted);
}

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

.detail-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.detail-table th,
.detail-table td {
  border: 1px solid var(--soft-line);
  padding: 9px 8px;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.45;
  font-size: 13px;
}

.detail-table th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafc;
  border-bottom-color: var(--line);
}

.detail-table tbody tr:nth-child(even) td {
  background: #fbfcfe;
}

.detail-col-no {
  width: 48px;
}

.detail-col-project {
  width: 13%;
}

.detail-col-invoice {
  width: 11%;
}

.detail-col-time {
  width: 17%;
}

.detail-col-place {
  width: 17%;
}

.detail-col-info {
  width: 18%;
}

.detail-col-product {
  width: 16%;
}

.detail-col-qty {
  width: 58px;
}

.detail-col-unit,
.detail-col-shipping {
  width: 76px;
}

.detail-col-remark {
  width: 15%;
}

.detail-col-amount {
  width: 92px;
}

.detail-col-receipt {
  width: 138px;
}

.detail-row-no {
  color: var(--accent);
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.detail-main {
  display: block;
  color: #101828;
  font-weight: 700;
  line-height: 1.35;
}

.detail-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.detail-row-amount {
  color: var(--ok);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.number-cell {
  text-align: right;
  white-space: nowrap;
}

.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 16px 8px;
}

.attachment {
  display: inline-block;
  margin-right: 8px;
}

.receipt-cell {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.receipt-file {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.receipt-file span {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.receipt-file button {
  padding: 4px 7px;
  font-size: 12px;
}

.receipt-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  color: var(--accent);
  background: #f4f9ff;
  cursor: pointer;
}

.receipt-upload input {
  display: none;
}

.receipt-upload span {
  margin: 0;
  color: inherit;
  font-size: 12px;
}

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

.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
}

.checkbox-line input {
  width: 16px;
  min-height: 16px;
  height: 16px;
  padding: 0;
}

.checkbox-line span {
  margin: 0;
  font-size: 12px;
  color: var(--text);
}

.check-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}

.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: #f8fafc;
  cursor: pointer;
}

.check-chip input {
  width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
}

.check-chip span {
  margin: 0;
  color: var(--text);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #111827;
  color: #fff;
  padding: 13px 18px;
  border-radius: 8px;
  max-width: min(560px, calc(100vw - 40px));
  text-align: center;
  line-height: 1.6;
  box-shadow: 0 20px 50px rgba(16, 24, 40, 0.24);
  z-index: 1000;
}

.admin-grid {
  display: grid;
  gap: 12px;
}

.settings-section-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 9px;
}

.settings-section-tabs button {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.03);
}

.settings-section-tabs button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.settings-section-tabs button.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
  color: var(--accent);
}

.settings-section-tabs button.active span {
  color: var(--accent);
}

.admin-section-grid {
  display: grid;
  gap: 12px;
}

.admin-panel {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.admin-panel h3 {
  margin: 0;
  font-size: 14px;
}

.admin-panel table {
  min-width: 760px;
}

.procurement-grid {
  display: grid;
  gap: 12px;
}

.procurement-grid .panel {
  display: grid;
  gap: 10px;
}

.procurement-hero {
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
}

.procurement-hero h3 {
  margin: 0;
  font-size: 16px;
}

.procurement-hero p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.procurement-hero-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(70px, 1fr));
  gap: 8px;
}

.procurement-hero-stats span {
  min-width: 74px;
  padding: 8px 10px;
  border: 1px solid var(--soft-line);
  border-radius: 7px;
  background: #f8fafc;
  color: var(--muted);
  white-space: nowrap;
}

.procurement-hero-stats b {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 15px;
}

.procurement-hero-actions {
  justify-content: flex-end;
}

.procurement-section-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.procurement-section-tabs button {
  display: grid;
  gap: 4px;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.03);
}

.procurement-section-tabs button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.procurement-section-tabs button.active {
  border-color: var(--accent);
  background: linear-gradient(180deg, #eff6ff 0%, #ffffff 100%);
  color: var(--accent);
}

.procurement-section-tabs button.active span {
  color: var(--accent);
}

.procurement-master-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.procurement-master-grid.single {
  grid-template-columns: minmax(0, 1fr);
}

.procurement-mini-panel {
  align-self: start;
}

.procurement-grid .section-title h3 {
  margin: 0;
  font-size: 14px;
}

.procurement-filters {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
}

.inline-notice {
  border: 1px solid #fedf89;
  border-radius: 7px;
  background: #fffaeb;
  color: #93370d;
  padding: 8px 10px;
  line-height: 1.5;
}

.danger-notice {
  border-color: #f1b4af;
  background: #fff4f2;
  color: var(--danger);
}

.procurement-detail .detail-cell {
  min-height: 84px;
}

.procurement-qr-row {
  display: flex;
  justify-content: center;
  margin: 10px 0 12px;
}

.procurement-qr-card {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: min(520px, 100%);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.procurement-qr-card .qr-code {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
}

.procurement-qr-card b,
.procurement-qr-card span {
  display: block;
}

.procurement-qr-card b {
  color: var(--text);
  font-size: 15px;
  overflow-wrap: anywhere;
}

.procurement-qr-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.procurement-qr-card .compact-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.procurement-flow-line {
  display: grid;
  gap: 3px;
  padding: 8px 0;
  border-bottom: 1px solid var(--soft-line);
}

.procurement-flow-line small {
  color: var(--muted);
  line-height: 1.5;
}

.procurement-flow-line:last-child {
  border-bottom: 0;
}

.hardware-price-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.hardware-ocr-panel {
  display: grid;
  gap: 8px;
}

.hardware-ocr-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hardware-ocr-panel textarea {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.55;
}

.hardware-items-box {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.hardware-item-row {
  display: grid;
  grid-template-columns: 34px minmax(110px, 0.9fr) minmax(150px, 1.35fr) 78px minmax(92px, 0.7fr) minmax(92px, 0.75fr) auto;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--soft-line);
  border-radius: 7px;
  padding: 8px;
  background: #fbfcfe;
}

.hardware-item-no {
  min-height: 32px;
  display: grid;
  place-items: center;
  color: var(--accent);
  font-weight: 800;
}

.hardware-item-actions {
  display: flex;
  justify-content: flex-end;
}

.hardware-spec-grid {
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

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

.hardware-price-line {
  display: grid;
  grid-template-columns: 36px minmax(80px, 0.8fr) minmax(150px, 1.3fr) 70px 100px 110px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--soft-line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fbfcfe;
}

.hardware-price-line span {
  color: var(--accent);
  font-weight: 800;
}

.hardware-price-line b {
  overflow-wrap: anywhere;
}

.hardware-price-line em {
  color: var(--muted);
  font-style: normal;
  overflow-wrap: anywhere;
}

.hardware-price-line i,
.hardware-price-line small {
  color: var(--muted);
  font-style: normal;
  text-align: right;
}

.hardware-price-line strong {
  color: var(--ok);
  text-align: right;
  font-size: 15px;
}

.asset-batch-cell {
  display: grid;
  gap: 3px;
}

.asset-batch-cell b {
  color: var(--text);
  font-size: 13px;
}

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

.batch-asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin: 8px 0 12px;
}

.batch-asset-card {
  display: grid;
  gap: 4px;
  border: 1px solid var(--soft-line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fbfcfe;
}

.batch-asset-card b {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.batch-asset-card span,
.batch-asset-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.scan-action-row {
  display: flex;
  justify-content: center;
  margin: 8px 0 12px;
}

.dialog-inner-box {
  margin: 0 14px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #fbfcfe;
}

.attachment-panel {
  display: grid;
  gap: 8px;
}

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

.attachment-preview-group {
  display: grid;
  gap: 6px;
  border: 1px solid var(--soft-line);
  border-radius: 7px;
  padding: 8px;
  background: #fbfcfe;
}

.attachment-preview-group b {
  font-size: 12px;
  color: var(--muted);
}

.attachment-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.attachment-preview-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.attachment-preview-row em {
  color: var(--muted);
  font-style: normal;
  white-space: nowrap;
}

.attachment-preview-dialog {
  width: min(1040px, calc(100vw - 28px));
}

.attachment-preview-body {
  display: grid;
  gap: 10px;
  min-height: min(72vh, 760px);
}

.attachment-preview-frame {
  width: 100%;
  height: min(72vh, 760px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.attachment-preview-image {
  display: block;
  max-width: 100%;
  max-height: min(72vh, 760px);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.attachment-preview-message {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfe;
  text-align: center;
  padding: 18px;
}

.attachment-doc-preview {
  display: grid;
  gap: 8px;
  align-content: start;
  max-height: min(72vh, 760px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.attachment-doc-preview p {
  margin: 0;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.attachment-preview-table-wrap {
  max-height: min(72vh, 760px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.attachment-preview-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 12px;
}

.attachment-preview-table th,
.attachment-preview-table td {
  border: 1px solid var(--soft-line);
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.attachment-preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef5fb;
  color: var(--text);
  font-weight: 800;
}

.bank-cell {
  display: grid;
  gap: 2px;
  min-width: 150px;
}

.bank-cell b,
.bank-cell span,
.bank-cell em {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bank-cell b {
  color: var(--text);
  font-size: 12px;
}

.bank-cell span,
.bank-cell em {
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
}

.procurement-grid table {
  min-width: 1280px;
}

.procurement-grid .table-wrap {
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: #fff;
}

.procurement-grid .badge {
  white-space: nowrap;
}

.procurement-grid .row-actions {
  min-width: 180px;
}

.procurement-grid .filters button {
  align-self: stretch;
}

@media print {
  body {
    background: #fff;
  }
  .topbar,
  .module-tabs,
  .filters,
  .panel.stats,
  #logoutBtn,
  #newBtn,
  #exportBtn,
  #passwordBtn,
  #printBtn,
  #detailPrintBtn,
  #detailImageBtn,
  #detailJpgBtn {
    display: none !important;
  }
  .app {
    padding: 0;
  }
  .panel {
    border: 0;
    padding: 0;
  }
  .detail-grid,
  .detail-items {
    break-inside: avoid;
  }
}

@media (max-width: 980px) {
  .app {
    padding: 14px;
  }

  .procurement-hero {
    grid-template-columns: 1fr;
  }

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

  .procurement-hero-actions {
    justify-content: flex-start;
  }

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

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

  .procurement-master-grid {
    grid-template-columns: 1fr;
  }

  .hardware-item-row,
  .hardware-price-line {
    grid-template-columns: 1fr;
  }

  .hardware-item-no,
  .hardware-price-line span,
  .hardware-price-line strong {
    text-align: left;
    justify-content: flex-start;
  }

  .topbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .module-tabs {
    position: static;
    width: auto;
    height: auto;
    min-height: 0;
    flex-direction: row;
    overflow-x: auto;
    padding: 0 0 2px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .module-tabs button {
    width: auto;
    min-width: 108px;
    text-align: center;
  }

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

  .detail-items {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  body {
    background: #eef3f8;
    font-size: 14px;
  }

  .app {
    padding: 8px;
    gap: 10px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    gap: 10px;
    margin: -8px -8px 10px;
    padding: 9px 8px;
    border-bottom: 1px solid rgba(217, 224, 234, 0.86);
    background: rgba(245, 247, 250, 0.96);
    backdrop-filter: blur(14px);
  }

  .topbar h1 {
    font-size: 18px;
  }

  .topbar p {
    font-size: 12px;
    line-height: 1.45;
  }

  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    width: 100%;
    gap: 7px;
  }

  .top-actions button,
  .filters button {
    width: 100%;
    min-height: 40px;
    border-radius: 8px;
    font-weight: 600;
  }

  .filters {
    padding: 10px;
    gap: 8px;
    margin-bottom: 10px;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(16, 24, 40, 0.06);
  }

  .filters label span,
  fieldset label span,
  .admin-panel label span {
    font-size: 12px;
    font-weight: 600;
  }

  .workspace {
    gap: 10px;
  }

  .panel {
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 8px 22px rgba(16, 24, 40, 0.06);
  }

  .section-title {
    align-items: flex-start;
  }

  .section-title h2 {
    font-size: 16px;
  }

  .table-wrap {
    border: 1px solid var(--soft-line);
    border-radius: 9px;
    background: #fff;
  }

  table {
    min-width: 820px;
  }

  th,
  td {
    padding: 9px 8px;
  }

  .solution-card {
    grid-template-columns: 1fr;
  }

  .solution-card > .row-actions {
    width: 100%;
  }

  .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    min-width: 154px;
  }

  .row-actions button {
    width: 100%;
    min-height: 34px;
    border-radius: 7px;
    padding: 7px 8px;
  }

  .badge,
  .type-chip {
    min-height: 24px;
    padding-inline: 8px;
  }

  .list-amount {
    font-size: 15px;
  }

  dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    background: #f5f7fa;
  }

  .password-dialog {
    width: min(420px, calc(100vw - 28px));
    max-width: calc(100vw - 28px);
    height: auto;
    max-height: calc(100dvh - 28px);
    border-radius: 10px;
    background: #fff;
  }

  .password-dialog .form-grid {
    padding: 12px;
  }

  .password-dialog .dialog-actions {
    position: static;
    padding: 10px 12px 12px;
  }

  .wide-dialog > form,
  .wide-dialog > div:not(.dialog-head) {
    padding: 0 10px 96px;
  }

  .dialog-head {
    position: sticky;
    top: 0;
    z-index: 5;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.96);
    padding: 10px;
    backdrop-filter: blur(14px);
  }

  .dialog-head h2 {
    font-size: 16px;
    line-height: 1.35;
  }

  .dialog-head .top-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 230px;
  }

  .procurement-qr-card {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .procurement-qr-card .qr-code {
    width: 64px;
    height: 64px;
  }

  .procurement-qr-card .row-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .procurement-qr-card button {
    grid-column: 1 / -1;
    width: 100%;
  }

  fieldset {
    margin: 10px 0;
    padding: 10px;
    border: 0;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(16, 24, 40, 0.05);
  }

  legend {
    padding: 0;
    margin-bottom: 8px;
    font-size: 14px;
  }

  input,
  select,
  textarea {
    min-height: 40px;
    border-radius: 8px;
    font-size: 16px;
  }

  button {
    min-height: 38px;
    border-radius: 8px;
    padding: 8px 10px;
  }

  .filters,
  .form-grid,
  .item-fields,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  .item-card {
    padding: 10px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(16, 24, 40, 0.05);
  }

  .item-head {
    align-items: flex-start;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--soft-line);
  }

  .item-head .danger {
    min-height: 34px;
  }

  .item-fields {
    margin-top: 8px;
  }

  .form-receipt-box {
    padding: 9px;
    border-radius: 8px;
    background: #f8fbff;
  }

  .form-receipt-box input {
    flex-basis: 100%;
    min-height: 36px;
    font-size: 14px;
  }

  .receipt-preview-btn {
    width: 100%;
    min-height: 36px;
  }

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

  .line-actions button {
    width: 100%;
  }

  .dialog-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 8;
    padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 -8px 28px rgba(16, 24, 40, 0.12);
  }

  .dialog-actions > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
    width: 100%;
  }

  .dialog-actions strong {
    width: 100%;
    color: var(--ok);
    font-size: 17px;
  }

  .dialog-actions button {
    width: 100%;
    min-height: 42px;
  }

  #printBtn {
    grid-column: span 2;
  }

  .stats-list {
    gap: 9px;
  }

  .stat-item {
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 5px 16px rgba(16, 24, 40, 0.04);
  }

  .stat-item strong {
    color: #1c2b3a;
    font-size: 15px;
    line-height: 1.45;
  }

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

  .stat-grid span {
    min-height: 30px;
    padding: 6px 7px;
    border-radius: 8px;
    background: #f8fafc;
    line-height: 1.35;
  }

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

  .stat-break-row {
    grid-template-columns: 64px minmax(60px, 1fr) 72px;
    gap: 6px;
  }

  .admin-grid {
    gap: 10px;
  }

  .admin-panel {
    padding: 10px;
    border-radius: 10px;
    background: #fff;
    overflow-x: auto;
    box-shadow: 0 5px 16px rgba(16, 24, 40, 0.04);
  }

  .admin-panel h3 {
    font-size: 15px;
  }

  .admin-panel table {
    min-width: 740px;
  }

  .detail-grid {
    gap: 8px;
  }

  .detail-headline {
    border-radius: 10px;
  }

  .detail-table-wrap {
    border-radius: 9px;
  }

  .detail-table {
    min-width: 980px;
  }

  .receipt-file button,
  .receipt-upload {
    min-height: 34px;
  }
}
