*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: #111;
}

/* App shell */
body.app-shell {
  font-family: 'Inter', sans-serif;
  background: #f5f5f5;
  display: flex;
}

.mobile-navbar {
  display: none;
  height: 50px;
  background: transparent;
  border-bottom: none;
}

.sidebar-toggle {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1001;
  background: transparent;
  border: none;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1;
  color: #333;
}

.sidebar {
  width: 220px;
  min-height: 100vh;
  background: #fafafa;
  color: #333;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #111;
  border-bottom: 1px solid #e5e5e5;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: #666;
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}

.sidebar-nav a:hover {
  color: #111;
  background: #f0f0f0;
}

.sidebar-nav a.active {
  color: #111;
  background: #f0f0f0;
  border-left: 3px solid rgb(228, 0, 46);
  padding-left: 17px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid #e5e5e5;
  font-size: 13px;
  color: #999;
  line-height: 1.5;
}

.sidebar-footer strong {
  display: block;
  color: #333;
  font-weight: 500;
  margin-bottom: 4px;
}

.sidebar-footer a {
  color: #999;
  text-decoration: none;
  font-size: 13px;
  transition: color 0.15s;
}

.sidebar-footer a:hover {
  color: rgb(228, 0, 46);
}

.app-main {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
}

.comparables-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.comparables-header h1 {
  margin: 0;
}

.primary-btn,
.secondary-btn {
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.primary-btn {
  background: #111;
  color: #fff;
}

.primary-btn:hover {
  background: rgb(228, 0, 46);
}

.secondary-btn {
  background: #f0f0f0;
  color: #222;
}

.secondary-btn:hover {
  background: #e5e5e5;
}

.alert {
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-error {
  background: #fff0f2;
  border: 1px solid rgb(228, 0, 46);
  color: rgb(228, 0, 46);
}

.alert-success {
  background: #ecfdf5;
  border: 1px solid #10b981;
  color: #047857;
}

.table-wrap {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f0;
  text-align: left;
  font-size: 14px;
}

.data-table th {
  background: #fafafa;
  font-weight: 600;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.icon-action-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  background: #fff;
  color: #333;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
}

.icon-action-btn:hover {
  background: #f4f4f5;
}

.icon-action-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.icon-action-btn.danger {
  border-color: #fecaca;
  background: #fff5f5;
  color: #b91c1c;
}

.icon-action-btn.danger:hover {
  background: #fee2e2;
}

.link-btn,
.danger-btn {
  border: none;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.link-btn {
  background: #f3f4f6;
  color: #111;
}

.link-btn:hover {
  background: #e5e7eb;
}

.danger-btn {
  background: #fee2e2;
  color: #b91c1c;
}

.danger-btn:hover {
  background: #fecaca;
}

.project-placeholder {
  padding: 24px;
  font-size: 15px;
  color: #525252;
}

.project-sections {
  display: grid;
  gap: 20px;
}

.project-workspace {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.project-input-panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px;
}


.project-input-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.project-input-header h2 {
  margin: 0;
}

.input-toggle-btn {
  min-width: 74px;
}

.icon-toggle-btn {
  min-width: 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-toggle-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  transition: transform 0.2s ease;
}

.icon-toggle-btn[aria-expanded='true'] svg {
  transform: rotate(180deg);
}

.subject-input-form {
  display: grid;
  gap: 4px;
}

.subject-input-form.is-collapsed {
  display: none;
}

.subject-input-form label {
  font-size: 13px;
  font-weight: 500;
  margin-top: 10px;
}

.subject-input-form label:first-child {
  margin-top: 0;
}

.subject-input-form input {
  width: 100%;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
}

.subject-input-form select {
  width: 100%;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 14px;
  background: #fff;
}

.subject-input-form input:focus {
  outline: none;
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.subject-input-form select:focus {
  outline: none;
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.subject-input-form input[disabled] {
  background: #f4f4f5;
  color: #525252;
  cursor: not-allowed;
}

.subject-input-form select:disabled {
  background: #f4f4f5;
  color: #525252;
  cursor: not-allowed;
}

.subject-input-form .currency-input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.project-output-panel {
  min-width: 0;
}

.project-page-actions {
  margin-bottom: 18px;
}

.project-section-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
}

.project-section-card h2 {
  margin: 0;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  background: #fafafa;
  border-bottom: 1px solid #e5e7eb;
}

.project-section-card .table-wrap {
  border: none;
  border-radius: 0;
}

.comparable-edit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.comparable-edit-main,
.comparable-edit-form {
  display: grid;
  gap: 14px;
}

.edit-card,
.edit-sidebar-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: none;
  overflow: hidden;
}

.edit-card-header,
.edit-sidebar-card h2 {
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.edit-card-footer {
  padding: 10px 14px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
}

.save-card-btn {
  background: rgb(228, 0, 43);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.save-card-btn:hover {
  background: rgb(200, 0, 38);
}

.save-card-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.edit-card-header h2,
.edit-sidebar-card h2 {
  margin: 0;
  font-size: 15px;
}

.edit-card-body {
  padding: 14px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.inline-field {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.inline-field-full {
  grid-column: 1 / -1;
}

.inline-field label {
  font-size: 13px;
  font-weight: 500;
  color: #555;
}

.inline-field input,
.inline-field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  font: inherit;
  color: #111;
  background: #fff;
}

.inline-field input:focus,
.inline-field select:focus {
  outline: none;
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.inline-field input[disabled] {
  background: #f4f4f5;
  color: #525252;
  cursor: not-allowed;
}

.inline-field .currency-input {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.comparable-edit-sidebar {
  display: grid;
  gap: 16px;
}

.sticky-card {
  position: sticky;
  top: 16px;
}

.summary-list,
.sidebar-action-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.summary-label {
  color: #666;
}

.summary-value {
  color: #111;
  text-align: right;
  word-break: break-word;
}

.sidebar-action-btn {
  justify-content: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1200;
}

.modal-backdrop.is-open {
  display: flex;
}

.modal-card {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  padding: 18px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  color: #666;
}

.modal-card label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
}

.modal-card input[type='text'] {
  width: 100%;
  border: 1px solid #d4d4d8;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 16px;
}

.modal-card input[type='text']:focus {
  outline: none;
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Login page */
body.login-page {
  min-height: 100dvh;
  font-family: 'Inter', sans-serif;
  background: #fafafa;
}

.login-wrap {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.login-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 48px 40px;
}

.login-inner {
  width: 100%;
  max-width: 360px;
}

.login-brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 0 0 40px;
  color: #111;
}

.login-inner h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 600;
}

.login-inner p {
  margin: 0 0 28px;
  font-size: 14px;
  color: #666;
}

.error-msg {
  background: #fff0f2;
  border: 1px solid rgb(228, 0, 46);
  color: rgb(228, 0, 46);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 20px;
}

.pin-group {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
}

.pin-digit {
  width: 64px;
  height: 68px;
  text-align: center;
  font-size: 24px;
  font-family: inherit;
  font-weight: 600;
  border: 1.5px solid #ddd;
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  color: #111;
}

.pin-digit:focus {
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.submit-btn {
  width: 100%;
  padding: 13px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 600;
  background: #111;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.submit-btn:hover {
  background: rgb(228, 0, 46);
}

.login-image {
  flex: 1;
  background: #e5e5e5;
  overflow: hidden;
}

.login-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* DB test page */
body.db-test-page {
  display: grid;
  place-items: center;
  font-family: Arial, sans-serif;
  background: #f5f7fb;
}

.card {
  width: min(760px, 92vw);
  padding: 24px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.status {
  font-weight: 700;
  margin-bottom: 12px;
}

.status-success {
  color: #0f766e;
}

.status-failed {
  color: #b91c1c;
}

.details {
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}

@media (max-width: 768px) {
  body.app-shell {
    flex-direction: column;
  }

  .mobile-navbar {
    display: flex;
    align-items: center;
    position: relative;
    height: 50px;
  }

  .sidebar-toggle {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1000;
    transform: translateX(-100%);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .app-main {
    padding: 20px;
    flex: 1;
  }

  .comparables-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .project-workspace {
    grid-template-columns: 1fr;
  }

  .comparable-edit-layout,
  .form-grid-2 {
    grid-template-columns: 1fr;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .login-image {
    display: none;
  }

  .login-panel {
    padding: 40px 24px;
  }
}

/* Toast notifications */
#toastContainer {
  position: fixed;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: 320px;
  word-break: break-word;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast-success {
  background: #111;
}

.toast-error {
  background: rgb(228, 0, 46);
}

/* Notes / textarea fields */
.textarea-field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.textarea-field:last-child {
  margin-bottom: 0;
}

.textarea-field label {
  font-size: 13px;
  font-weight: 500;
  color: #555;
}

.textarea-field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d9d9d9;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  color: #111;
  resize: vertical;
  min-height: 90px;
}

.textarea-field textarea:focus {
  outline: none;
  border-color: #111;
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}
