.login-card {
  width: min(430px, 100%);
  padding: 34px 30px 30px;
  border: 1px solid rgba(216, 221, 226, 0.92);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(6px);
}

.login-brand {
  display: grid;
  gap: 4px;
  margin-bottom: 26px;
}

.login-brand span {
  color: var(--text-soft);
  font-size: 16px;
  font-weight: 780;
  letter-spacing: 0.01em;
  text-transform: none;
}

.login-brand h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form .field {
  gap: 7px;
}

.login-form .field label {
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 780;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.login-form .input {
  min-height: 42px;
}

.login-form .button {
  min-height: 40px;
  margin-top: 18px;
  font-size: 13px;
  font-weight: 800;
}

.app-start-error {
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(200, 70, 62, 0.26);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  line-height: 1.4;
}

.dashboard {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 18px;
}

.user-account-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #ffffff 0%, #f7f8f9 100%);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 750;
}

.user-account-button span {
  color: var(--text-muted);
}

.user-account-button strong {
  color: var(--text);
}

.user-account-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
}

.stat-card {
  position: relative;
  overflow: hidden;
  padding: 15px 15px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.stat-card:hover {
  border-color: rgba(79, 111, 63, 0.24);
  box-shadow: 0 12px 28px rgba(32, 38, 46, 0.08);
  transform: translateY(-1px);
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--border-strong);
}

.stat-card-total::before {
  background: #20262e;
}

.stat-card-available::before {
  background: var(--success);
}

.stat-card-sold::before {
  background: var(--danger);
}

.stat-card-pre_contract::before {
  background: var(--info);
}

.stat-card-reserved::before {
  background: var(--warning);
}

.stat-card-inactive::before {
  background: var(--inactive);
}

.stat-card span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.stat-card strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
  line-height: 1;
  letter-spacing: -0.02em;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 190px;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 251, 0.98));
  box-shadow: var(--shadow-card);
}

.lot-grid-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.lot-grid-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}

.lot-grid-head h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.lot-grid-head .status-badge {
  min-width: 82px;
  min-height: 26px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1;
}

.lot-grid {
  min-height: 0;
  max-height: none;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, 92px);
  grid-auto-rows: auto;
  justify-content: center;
  align-content: start;
  gap: 14px;
  padding: 18px 18px 28px;
  scrollbar-color: var(--primary) transparent;
  scrollbar-width: thin;
}

.lot-card {
  position: relative;
  width: 86px;
  height: 86px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px 4px 18px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  appearance: none;
  user-select: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.035);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    opacity 0.16s ease,
    background-color 0.16s ease;
}

.lot-card:hover {
  border-color: rgba(0, 0, 0, 0.1);
  transform: scale(1.016);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.085);
}

.lot-card.is-search-match {
  box-shadow:
    0 0 0 3px rgba(79, 111, 63, 0.16),
    0 12px 22px rgba(32, 38, 46, 0.12);
}

.lot-card:focus,
.lot-card:focus-visible,
.lot-card:active {
  outline: none;
  transform: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.lot-code {
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.6px;
  color: #1a1a1a;
}

.lot-state-strip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.24px;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.22);
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

.lot-state-strip::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: rgba(255, 255, 255, 0.35);
}

.lot-card.status-available {
  border-color: rgba(79, 139, 106, 0.5);
}

.lot-card.status-available .lot-state-strip {
  background: linear-gradient(180deg, #76ab8c, #4f8b6a);
}

.lot-card.status-sold {
  border-color: rgba(200, 70, 62, 0.5);
}

.lot-card.status-sold .lot-state-strip {
  background: linear-gradient(180deg, #e06860, #c8463e);
}

.lot-card.status-pre_contract {
  border-color: rgba(75, 115, 159, 0.5);
}

.lot-card.status-pre_contract .lot-state-strip {
  background: linear-gradient(180deg, #7199c3, #4b739f);
}

.lot-card.status-reserved {
  border-color: rgba(201, 144, 24, 0.5);
}

.lot-card.status-reserved .lot-state-strip {
  background: linear-gradient(180deg, #e0a934, #c99018);
}

.lot-card.status-inactive {
  border-color: rgba(123, 131, 140, 0.5);
  opacity: 0.48;
}

.lot-card.status-inactive:hover {
  opacity: 0.72;
}

.lot-card.status-inactive .lot-state-strip {
  background: linear-gradient(180deg, #929aa3, #7b838c);
}

.lot-grid-divider {
  grid-column: 1 / -1;
  height: auto;
  align-self: start;
  margin: 0 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lot-grid-divider::before,
.lot-grid-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, transparent, rgba(32, 38, 46, 0.32));
}

.lot-grid-divider::after {
  background: linear-gradient(90deg, rgba(32, 38, 46, 0.32), transparent);
}

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

.document-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 300px);
  gap: 14px;
  height: auto;
  max-height: 100%;
  min-height: 0;
}

.section-card {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid rgba(216, 221, 226, 0.95);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  overflow: hidden;
}

.section-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 850;
  letter-spacing: 0.01em;
}

.edit-mode-badge {
  min-width: 0;
  padding: 4px 8px;
  border: 1px solid rgba(75, 115, 159, 0.22);
  border-radius: 999px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.document-list {
  min-height: 286px;
  max-height: min(42vh, 380px);
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
}

.document-list-actions {
  display: flex;
  justify-content: flex-end;
  padding: 0 26px 12px 12px;
}

.document-list-actions .button {
  min-width: 76px;
  min-height: 38px;
  font-size: 12.5px;
}

.document-area .section-card:last-child {
  grid-template-rows: auto minmax(0, 1fr);
}

.document-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.12s ease;
}

.document-item:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 14px rgba(32, 38, 46, 0.1);
  transform: translateY(-1px);
}

.document-main {
  min-width: 0;
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.document-main:hover .document-price {
  color: var(--primary);
}

.document-thumb {
  width: 62px;
  height: 62px;
  object-fit: cover;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.document-meta {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.document-meta-head {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.document-price {
  font-size: 15px;
  font-weight: 850;
  white-space: nowrap;
}

.document-description {
  color: var(--text-soft);
  overflow-wrap: anywhere;
}

.document-date {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.document-time {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 750;
}

.document-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.document-action-button {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #ffffff 0%, #f7f8f9 100%);
  color: var(--text-soft);
  font-weight: 800;
  transition:
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.12s ease;
}

.document-action-button svg {
  width: 15px;
  height: 15px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.document-action-button:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 6px 14px rgba(32, 38, 46, 0.08);
}

.document-action-button:active {
  transform: translateY(1px);
}

.document-action-danger:hover {
  border-color: rgba(200, 70, 62, 0.45);
  color: var(--danger);
}

.document-preview-modal {
  width: min(820px, 100%);
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--popup-bg);
  box-shadow: var(--shadow-modal);
}

.document-preview-head {
  position: relative;
  display: grid;
  place-items: center;
  padding: 18px 54px 16px;
  border-bottom: 1px solid var(--border);
}

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

.document-preview-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

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

.document-zoom-controls,
.document-file-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.document-tool-button {
  min-width: 38px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #ffffff 0%, #f7f8f9 100%);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 850;
}

.document-tool-button:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.document-preview-button {
  min-height: 36px;
  font-size: 12px;
}

.document-preview-image-frame {
  width: 100%;
  max-height: 58vh;
  min-height: 280px;
  display: grid;
  place-items: center;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.document-preview-image {
  max-width: 100%;
  max-height: 56vh;
  object-fit: contain;
  transform-origin: center;
  transition: transform 0.14s ease;
}

.document-preview-meta {
  display: grid;
  gap: 10px;
  margin: 0;
}

.document-preview-meta div {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.document-preview-meta dt {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.document-preview-meta dd {
  margin: 0;
  color: var(--text);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.document-form {
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 12px;
  overflow: hidden;
}

.document-form .field {
  min-width: 0;
  gap: 5px;
}

.document-form .field label {
  font-size: 10.5px;
  letter-spacing: 0.065em;
}

.document-form .input {
  min-height: 36px;
}

.document-form .textarea {
  min-height: 68px;
  max-height: 86px;
  resize: none;
}

.document-form .button {
  width: auto;
  min-height: 38px;
  margin-top: 2px;
  font-size: 12.5px;
}

.document-form-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.document-form-actions .button[hidden] {
  display: none;
}

.document-form-actions .button {
  min-width: 76px;
}

.document-form-actions [data-document-submit] {
  justify-self: end;
}

.upload-preview {
  width: 100%;
  min-width: 0;
  height: 104px;
  min-height: 104px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: var(--surface-muted);
}

.empty-state {
  padding: 18px;
  color: var(--text-muted);
  text-align: center;
  font-weight: 700;
}

@media (max-width: 980px) {
  .dashboard {
    height: auto;
    min-height: 0;
    grid-template-rows: auto auto auto;
  }

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

  .toolbar,
  .document-area,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .lot-grid {
    grid-template-columns: repeat(auto-fill, 74px);
    grid-auto-rows: auto;
    justify-content: center;
    max-height: none;
    overflow: visible;
    gap: 10px;
    padding: 12px 10px 18px;
  }

  .lot-card {
    width: 72px;
    height: 72px;
    border-radius: 12px;
    padding: 6px 4px 16px;
  }

  .lot-code {
    font-size: 0.74rem;
  }

  .lot-state-strip {
    height: 16px;
    font-size: 7px;
  }
}

@media (max-width: 720px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat-card {
    padding: 12px 12px 11px;
  }

  .stat-card span {
    font-size: 11px;
  }

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

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

  .lot-grid-panel {
    overflow: hidden;
  }

  .lot-grid-head {
    padding: 12px;
  }

  .document-list {
    min-height: 180px;
    max-height: none;
    overflow: visible;
  }

  .document-list-actions {
    padding: 0 12px 12px;
  }

  .document-item {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .document-actions {
    justify-content: flex-end;
  }

  .document-preview-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .document-zoom-controls,
  .document-file-controls {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .document-preview-button,
  .document-tool-button {
    width: 100%;
  }

  .document-preview-image-frame {
    min-height: 220px;
    max-height: 50vh;
  }

  .document-preview-meta div {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (max-width: 520px) {
  .login-brand h1 {
    font-size: 29px;
  }

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

  .lot-grid {
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    grid-auto-rows: minmax(74px, auto);
    max-height: calc((74px * 6) + (8px * 5) + 24px);
    overflow: auto;
    gap: 8px;
    padding: 10px 8px 14px;
  }

  .lot-card {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    min-height: 64px;
  }

  .document-main {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 8px;
  }

  .document-thumb {
    width: 54px;
    height: 54px;
  }

  .document-meta-head {
    align-items: start;
    flex-direction: column;
    gap: 5px;
  }

  .document-form {
    padding: 10px;
  }

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

  .document-form-actions .button,
  .document-list-actions .button {
    width: 100%;
  }

  .document-list-actions {
    justify-content: stretch;
  }
}
