/* ======================================
   common.css  (demo base)
====================================== */

:root {
  --bg: #f5f7f8;
  --card-border: rgba(0,0,0,.08);
  --muted: #6c757d;
  --sidebar-bg: #16332d;
  --sidebar-border: rgba(255,255,255,.12);
  --sidebar-text: #eef7f3;
  --sidebar-muted: rgba(238,247,243,.68);
  --sidebar-active: #d8f2e3;
  --sidebar-active-text: #0f2c24;
}

html {
  min-height: 100%;
}

body {
  background: var(--bg);
  color: #1f2a2e;
  min-height: 100vh;
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(0,0,0,.08);
  color: var(--sidebar-text);
  flex: 0 0 248px;
  min-height: 100vh;
  padding: 22px 16px;
  position: sticky;
  top: 0;
}

.sidebar-brand {
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 18px;
  padding: 0 8px 18px;
}

.sidebar-company {
  color: var(--sidebar-muted);
  font-size: .9rem;
}

.sidebar-system {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-link {
  border-radius: 8px;
  color: var(--sidebar-text);
  display: block;
  font-weight: 600;
  line-height: 1.3;
  padding: 10px 12px;
  text-decoration: none;
}

.sidebar-link:hover,
.sidebar-link:focus {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.sidebar-link.is-active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
}

.sidebar-link.is-disabled,
.sidebar-sublink.is-disabled {
  color: var(--sidebar-muted);
  cursor: default;
}

.sidebar-group-header {
  display: flex;
  gap: 4px;
}

.sidebar-group-link {
  flex: 1 1 auto;
  min-width: 0;
}

.sidebar-toggle {
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--sidebar-text);
  flex: 0 0 38px;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}

.sidebar-toggle:hover,
.sidebar-toggle:focus-visible {
  background: rgba(255,255,255,.1);
  color: #fff;
  outline: none;
}

.sidebar-toggle span {
  display: none;
}

.sidebar-toggle::before {
  content: "+";
}

.sidebar-group.is-open .sidebar-toggle::before {
  content: "-";
}

.sidebar-submenu {
  border-left: 1px solid var(--sidebar-border);
  display: none;
  margin: 4px 0 2px 18px;
  padding-left: 8px;
}

.sidebar-group.is-open .sidebar-submenu {
  display: grid;
  gap: 3px;
}

.sidebar-sublink {
  border-radius: 7px;
  color: var(--sidebar-text);
  display: block;
  font-size: .88rem;
  line-height: 1.3;
  padding: 8px 10px;
  text-decoration: none;
}

.sidebar-sublink:hover,
.sidebar-sublink:focus,
.sidebar-sublink.is-active {
  background: rgba(255,255,255,.1);
  color: #fff;
}

.sidebar-coming-soon {
  color: var(--sidebar-muted);
  float: right;
  font-size: .65rem;
  font-weight: 500;
  margin-left: 6px;
  margin-top: 2px;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 26px 28px 40px;
}

.app-page-header {
  align-items: center;
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  margin: 0 auto 22px;
  max-width: 1180px;
  padding: 18px 20px;
}

.app-system-name {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.app-page-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.25;
  margin: 0;
}

.app-page-subtitle {
  color: var(--muted);
  font-size: .9rem;
  margin-top: 4px;
}

.app-content {
  margin: 0 auto;
  max-width: 1180px;
}


.login-wrap {
  display: flex;
  align-items: center;
}

.login-card {
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 8px;
  overflow: hidden;
}

.login-side {
  background: #0d6efd;
  color: #fff;
}

.login-side .title {
  font-weight: 800;
  letter-spacing: 0;
}

.login-side .desc {
  opacity: .9;
  font-size: .95rem;
}

.login-page .login-wrap {
  min-height: auto;
}

.demo-header {
  border-bottom: 1px solid rgba(0,0,0,.08);
  background: #fff;
}

.demo-title {
  font-weight: 700;
  letter-spacing: 0;
}

.demo-subtitle {
  color: var(--muted);
  font-size: .9rem;
}

.card {
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

.table thead th {
  white-space: nowrap;
}

.table td, .table th {
  vertical-align: middle;
}

.text-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.badge-soft {
  background: rgba(13,110,253,.08);
  color: #0d6efd;
  border: 1px solid rgba(13,110,253,.18);
}

.badge-soft-danger {
  background: rgba(220,53,69,.08);
  color: #dc3545;
  border: 1px solid rgba(220,53,69,.18);
}

.badge-soft-success {
  background: rgba(25,135,84,.08);
  color: #198754;
  border: 1px solid rgba(25,135,84,.18);
}

.small-note {
  font-size: .85rem;
  color: var(--muted);
}

.feature-card {
  transition: transform .18s ease, box-shadow .18s ease;
}

.feature-card:hover {
  box-shadow: 0 .5rem 1rem rgba(0,0,0,.08);
  transform: translateY(-2px);
}

.icon-box {
  align-items: center;
  background: rgba(13,110,253,.08);
  border-radius: 10px;
  color: #0d6efd;
  display: inline-flex;
  font-size: 1.15rem;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.flow-step {
  background: #fff;
  border: 1px solid var(--card-border);
  border-top: 4px solid #198754;
  border-radius: 8px;
  height: 100%;
  padding: 16px;
}

.flow-number {
  color: #198754;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-left: 4px solid #0d6efd;
  border-radius: 8px;
  height: 100%;
  padding: 18px;
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.2;
}

.chart-bar {
  background: #dce7f8;
  border-radius: 4px 4px 0 0;
  min-height: 16px;
  width: 100%;
}

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

.estimate-item-table {
  min-width: 1460px;
}

.estimate-item-table th {
  font-size: .82rem;
}

.estimate-item-table td {
  padding: .5rem;
}

.estimate-item-table .form-control,
.estimate-item-table .form-select {
  font-size: .88rem;
  min-width: 0;
}

.estimate-item-table textarea.form-control {
  min-height: 3.15rem;
  resize: vertical;
}

.estimate-col-no {
  width: 52px;
}

.estimate-col-menu {
  width: 250px;
}

.estimate-col-name {
  width: 190px;
}

.estimate-col-description {
  width: 250px;
}

.estimate-col-quantity {
  width: 100px;
}

.estimate-col-unit {
  width: 90px;
}

.estimate-col-price,
.estimate-col-amount {
  width: 130px;
}

.estimate-col-order {
  width: 95px;
}

.estimate-col-delete {
  width: 80px;
}

.estimate-item-deleted {
  opacity: .5;
}

.estimate-item-deleted input,
.estimate-item-deleted select,
.estimate-item-deleted textarea {
  text-decoration: line-through;
}

.chart-bar.is-accent {
  background: #198754;
}

.chart-column {
  align-items: center;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  justify-content: end;
  min-width: 42px;
}

.chart-area {
  align-items: end;
  display: flex;
  gap: 12px;
  height: 180px;
}

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

.contact-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  box-shadow: 0 .125rem .25rem rgba(0,0,0,.04);
  min-width: 0;
  padding: 20px;
}

.contact-card-header {
  align-items: flex-start;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
}

.contact-card-name {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
}

.contact-card-meta {
  color: var(--muted);
  font-size: .88rem;
  margin-top: 4px;
}

.contact-card-details {
  display: grid;
  font-size: .9rem;
  gap: 7px 12px;
  grid-template-columns: 72px minmax(0, 1fr);
  margin-bottom: 16px;
}

.contact-card-details dt {
  color: var(--muted);
  font-weight: 600;
}

.contact-card-details dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.business-card-images {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.business-card-label {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  margin-bottom: 5px;
}

.business-card-thumb,
.business-card-empty {
  aspect-ratio: 1.75 / 1;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  width: 100%;
}

.business-card-thumb {
  background: #f8f9fa;
  display: block;
  object-fit: contain;
}

.business-card-empty {
  align-items: center;
  background: #f8f9fa;
  color: var(--muted);
  display: flex;
  font-size: .78rem;
  justify-content: center;
  padding: 8px;
  text-align: center;
}

.business-card-main-preview {
  margin-bottom: 12px;
}

.business-card-main-image,
.business-card-placeholder {
  aspect-ratio: 1.75 / 1;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  width: 100%;
}

.business-card-main-image {
  background: #f8f9fa;
  display: block;
  object-fit: contain;
}

.business-card-placeholder {
  align-items: center;
  background: #f1f4f3;
  color: var(--muted);
  display: flex;
  font-size: .9rem;
  font-weight: 700;
  justify-content: center;
}

.business-card-upload-note {
  background: #f8f9fa;
  border-radius: 7px;
  margin-bottom: 16px;
  padding: 10px;
}

.business-card-upload-note .form-label {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
  margin-bottom: 5px;
}

.contact-face-upload {
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 16px;
}

.contact-face-image,
.contact-face-placeholder {
  border: 1px solid var(--card-border);
  border-radius: 50%;
  flex: 0 0 72px;
  height: 72px;
  width: 72px;
}

.contact-face-image {
  background: #f8f9fa;
  object-fit: cover;
}

.contact-face-placeholder {
  align-items: center;
  background: #f1f4f3;
  color: var(--muted);
  display: flex;
  font-size: .65rem;
  justify-content: center;
  line-height: 1.25;
  padding: 8px;
  text-align: center;
}

.contact-card-note {
  background: #f8f9fa;
  border-radius: 6px;
  font-size: .88rem;
  margin-top: 16px;
  padding: 12px;
}

.contact-card-empty-state {
  grid-column: 1 / -1;
}

.contact-form-section {
  background: #eef4f1;
  border: 1px solid rgba(22,51,45,.12);
  border-radius: 10px;
  padding: 22px;
}

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

.contact-form-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-top: 4px solid #198754;
  border-radius: 10px;
  box-shadow: 0 .125rem .25rem rgba(0,0,0,.04);
  min-width: 0;
  padding: 18px;
}

.contact-form-card-header {
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
}

.contact-form-card-title {
  font-size: 1rem;
  font-weight: 800;
  margin: 0;
}

.contact-form-remove {
  white-space: nowrap;
}

.business-card-upload-row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.business-card-current-image {
  align-items: center;
  background: #f8f9fa;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  display: flex;
  gap: 10px;
  margin-top: 8px;
  padding: 8px;
}

.business-card-current-image img {
  border-radius: 4px;
  height: 54px;
  object-fit: contain;
  width: 94px;
}

.business-card-current-image span {
  color: #198754;
  font-size: .8rem;
  font-weight: 700;
}

.ai-card-actions {
  align-items: center;
  background: rgba(13,110,253,.05);
  border: 1px solid rgba(13,110,253,.14);
  border-radius: 7px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 16px;
  padding: 10px;
}

.ai-status-badge {
  background: #e9ecef;
  border-radius: 999px;
  color: #495057;
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  padding: 4px 8px;
}

.ai-status-note {
  color: var(--muted);
  font-size: .72rem;
  margin-top: 4px;
}

.ai-status-analyzed {
  background: rgba(25,135,84,.12);
  color: #146c43;
}

.ai-status-failed {
  background: rgba(220,53,69,.1);
  color: #b02a37;
}

.ai-status-not-analyzed {
  background: rgba(108,117,125,.12);
  color: #495057;
}

.business-card-create-box {
  margin: 0 auto;
  max-width: 820px;
}

.business-card-upload-panel {
  align-items: center;
  background: #fff;
  border: 2px dashed rgba(13,110,253,.35);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  min-height: 360px;
  overflow: hidden;
  padding: 24px;
  transition: border-color .2s, background-color .2s;
}

.business-card-upload-panel:hover,
.business-card-upload-panel:focus-within {
  background: rgba(13,110,253,.03);
  border-color: #0d6efd;
}

.business-card-upload-preview {
  display: none;
  max-height: 440px;
  max-width: 100%;
  object-fit: contain;
}

.business-card-upload-preview.is-visible {
  display: block;
}

.business-card-upload-placeholder {
  color: var(--muted);
  display: grid;
  gap: 8px;
  text-align: center;
}

.business-card-upload-placeholder strong {
  color: #1f2a2e;
  font-size: 1.1rem;
}

.business-card-upload-placeholder.is-hidden {
  display: none;
}

.business-card-create-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

@media (max-width: 767.98px) {
  .app-shell {
    display: block;
  }

  .app-sidebar {
    min-height: auto;
    padding: 16px;
    position: static;
  }

  .sidebar-brand {
    margin-bottom: 14px;
    padding-bottom: 14px;
  }

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

  .sidebar-link {
    font-size: .92rem;
    min-height: 42px;
    padding: 9px 10px;
  }

  .sidebar-group {
    min-width: 0;
  }

  .sidebar-submenu {
    margin-left: 12px;
  }

  .app-main {
    padding: 18px 14px 28px;
  }

  .app-page-header {
    margin-bottom: 16px;
    padding: 16px;
  }

  .app-page-title {
    font-size: 1.3rem;
  }

  .table {
    min-width: 720px;
  }

  .card-body.p-0 {
    overflow-x: auto;
  }

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

  .contact-form-grid,
  .business-card-upload-row {
    grid-template-columns: 1fr;
  }

  .contact-form-section {
    padding: 16px;
  }

  .contact-face-upload {
    align-items: flex-start;
  }

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

  .business-card-upload-panel {
    min-height: 240px;
  }

  .contact-card-header {
    align-items: center;
  }

  .contact-card-header .contact-face-image,
  .contact-card-header .contact-face-placeholder {
    flex-basis: 60px;
    height: 60px;
    width: 60px;
  }
}

/* ======================================
   Compact typography and content density
====================================== */

.app-main {
  font-size: .72rem;
  line-height: 1.4;
}

.app-main p,
.app-main dl,
.app-main ol,
.app-main ul {
  margin-bottom: .65rem;
}

.app-main h1,
.app-main .h1 {
  font-size: 1.45rem;
}

.app-main h2,
.app-main .h2 {
  font-size: 1.2rem;
}

.app-main h3,
.app-main .h3 {
  font-size: 1.05rem;
}

.app-main h4,
.app-main .h4 {
  font-size: .95rem;
}

.app-main h5,
.app-main .h5 {
  font-size: .86rem;
}

.app-main h6,
.app-main .h6 {
  font-size: .78rem;
}

.app-main .small,
.app-main small,
.small-note {
  font-size: .64rem;
}

.app-main .form-label {
  font-size: .68rem;
  margin-bottom: .2rem;
}

.app-main .form-control,
.app-main .form-select {
  font-size: .7rem;
  line-height: 1.3;
  min-height: 30px;
  padding: .28rem .42rem;
}

.app-main textarea.form-control {
  min-height: 58px;
}

.app-main .form-check-input {
  height: .85rem;
  width: .85rem;
}

.app-main .form-check-label {
  font-size: .68rem;
}

.app-main .table {
  font-size: .68rem;
  line-height: 1.3;
}

.app-main .table > :not(caption) > * > * {
  padding: .34rem .42rem;
}

.app-main .table thead th {
  font-size: .65rem;
  letter-spacing: .01em;
}

.app-main .btn {
  font-size: .72rem;
  line-height: 1.35;
  min-height: 30px;
  padding: .3rem .58rem;
}

.app-main .btn-sm {
  font-size: .64rem;
  min-height: 25px;
  padding: .2rem .4rem;
}

.app-main .badge {
  font-size: .58rem;
  padding: .28em .48em;
}

.app-main .card-header,
.app-main .card-body,
.app-main .card.p-4 {
  padding: .8rem;
}

.app-main .alert {
  font-size: .68rem;
  line-height: 1.4;
  padding: .55rem .7rem;
}

.app-main dt {
  font-size: .67rem;
}

.app-main dd {
  font-size: .7rem;
}

.sidebar-link {
  font-size: .82rem;
  padding: 8px 10px;
}

.sidebar-sublink {
  font-size: .74rem;
  padding: 6px 9px;
}

.sidebar-company {
  font-size: .76rem;
}

.sidebar-system {
  font-size: 1.05rem;
}

.estimate-item-table {
  min-width: 1280px;
}

.estimate-item-table th {
  font-size: .61rem;
}

.estimate-item-table td {
  padding: .28rem;
}

.estimate-item-table .form-control,
.estimate-item-table .form-select {
  font-size: .62rem;
  min-height: 26px;
  padding: .2rem .3rem;
}

.estimate-item-table textarea.form-control {
  min-height: 42px;
}

.contact-card,
.contact-form-card,
.contact-form-section {
  padding: 12px;
}

.contact-card-name {
  font-size: .86rem;
}

.contact-card-meta,
.contact-card-details,
.contact-card-note {
  font-size: .68rem;
}

@media (max-width: 767.98px) {
  .app-main {
    font-size: .74rem;
  }

  .sidebar-link {
    font-size: .8rem;
    min-height: 38px;
  }

  .sidebar-sublink {
    font-size: .72rem;
  }

  .app-main .btn {
    min-height: 32px;
  }
}
