:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --accent: #0f766e;
  --danger: #b91c1c;
  --line: #dbe3ef;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding-top: 66px;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(145deg, #e6eef8, var(--bg));
  color: var(--text);
}

.top-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  border-bottom: 1px solid #cfe5ec;
  background: linear-gradient(90deg, #0f766e, #0b5f58);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.24);
}

.top-banner-inner {
  width: min(96%, 1160px);
  margin: 0 auto;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.top-banner-title {
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.top-banner-subtitle {
  display: block;
  font-size: 0.86rem;
  opacity: 0.92;
}

.top-banner-logout {
  margin-top: 0;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.55);
  padding: 0.55rem 0.8rem;
}

.top-banner-controls {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.top-banner-mode-toggle {
  margin-top: 0;
  background: rgba(15, 23, 42, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.45);
  padding: 0.55rem 0.75rem;
}

.top-banner-config {
  margin-top: 0;
  background: rgba(15, 23, 42, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.45);
  padding: 0.55rem 0.75rem;
}

.top-banner-config.is-active {
  background: rgba(255, 255, 255, 0.22);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42);
}

.container {
  width: min(96%, 1160px);
  padding: 2rem;
  margin: 1rem auto;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.1);
  text-align: left;
}

h1 {
  margin-top: 0;
  margin-bottom: 0.4rem;
}

h2 {
  margin: 0;
}

.subtitle {
  margin-top: 0;
  color: #64748b;
}

form {
  display: grid;
  gap: 0.5rem;
  text-align: left;
}

label {
  font-weight: 600;
  margin-top: 0.4rem;
}

input {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
}

select {
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font-size: 1rem;
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid #99f6e4;
  border-color: var(--accent);
}

button {
  margin-top: 1rem;
  border: 0;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  filter: brightness(1.05);
}

.feedback {
  min-height: 1.5rem;
  margin-bottom: 0;
  color: var(--danger);
  font-weight: 600;
}

.hidden {
  display: none;
}

body.ui-mode-pc #add-camera-controls,
body.ui-mode-pc #add-scan-feedback,
body.ui-mode-pc #add-scanner-reader,
body.ui-mode-pc #stock-camera-controls,
body.ui-mode-pc #stock-feedback,
body.ui-mode-pc #stock-scanner-reader,
body.ui-mode-pc #start-scan-btn,
body.ui-mode-pc #stop-scan-btn,
body.ui-mode-pc #scanner-reader {
  display: none !important;
}

body.ui-mode-pc.sell-manual-mode #start-scan-btn,
body.ui-mode-pc.sell-manual-mode #stop-scan-btn,
body.ui-mode-pc.sell-manual-mode #scanner-reader {
  display: initial !important;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.top-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.7rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
}

.top-actions-4 {
  display: flex;
}

.mode-btn {
  margin-top: 0;
  white-space: nowrap;
  flex: 1 1 0;
}

.mode-btn-secondary {
  background: #334155;
}

.mode-btn.is-active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 0 0 3px #99f6e4;
}

.panel {
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
}

.owner-admin {
  margin-top: 1rem;
  border-top: 1px dashed var(--line);
  padding-top: 1rem;
}

h3 {
  margin-top: 0;
}

h4 {
  margin: 1rem 0 0.6rem;
}

.icon {
  margin-right: 0.35rem;
}

.feature-list {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.feature-item {
  margin: 0;
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
}

.feature-icon {
  white-space: nowrap;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.stock-filters {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: 2fr 1fr;
  margin-bottom: 0.6rem;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 0.6rem;
  font-size: 0.95rem;
}

#stock-table-body tr[data-stock-row-id] {
  cursor: pointer;
}

#stock-table-body tr[data-stock-row-id]:hover {
  background: #f8fafc;
}

thead th {
  font-size: 0.85rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.scan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.scan-actions button {
  margin-top: 0;
}

.country-autocomplete {
  position: relative;
}

.country-suggestions {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  z-index: 30;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
  max-height: 210px;
  overflow-y: auto;
  padding: 0.2rem;
}

.country-suggestion-item {
  width: 100%;
  text-align: left;
  margin-top: 0;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: #0f172a;
  padding: 0.45rem 0.55rem;
}

.country-suggestion-item:hover {
  background: #ecfeff;
}

.plan-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.plan-card {
  margin-top: 0;
  display: grid;
  gap: 0.3rem;
  text-align: left;
  padding: 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  color: #0f172a;
}

.plan-card-title {
  font-size: 1rem;
  font-weight: 700;
}

.plan-card-price {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f766e;
}

.plan-card-description {
  font-size: 0.84rem;
  color: #334155;
}

.plan-card-features {
  font-size: 0.76rem;
  color: #64748b;
}

.plan-card.is-selected {
  border-color: #0f766e;
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.22);
  background: #ecfeff;
}

.sell-search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

.sell-search-row input {
  margin: 0;
}

.sell-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  color: #334155;
}

.sell-mode-switch input[type="checkbox"] {
  width: 2.2rem;
  height: 1.2rem;
  margin: 0;
}

.sale-search-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.sale-suggestion-pill {
  display: inline-flex;
  align-items: center;
  margin-top: 0;
  padding: 0.35rem 0.55rem;
  border-radius: 999px;
  background: #0f766e;
  font-size: 0.82rem;
  color: #ffffff;
  cursor: pointer;
}

.sale-suggestion-empty {
  color: #64748b;
  font-size: 0.88rem;
}

.scanner-box {
  top: 50px;
  margin-top: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem;
  background: #f8fafc;
  min-height: 120px;
}

.sale-total-line {
  text-align: right;
  margin-bottom: 0;
}

.sale-remove-btn {
  margin-top: 0;
  padding: 0.3rem 0.55rem;
  line-height: 1;
  background: #b91c1c;
}

.stock-danger {
  color: #b91c1c;
  font-weight: 700;
}

.stock-warning {
  color: #a16207;
  font-weight: 700;
}

.stock-edit-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.stock-edit-input {
  width: 92px;
  padding: 0.4rem 0.5rem;
}

.stock-save-btn {
  margin-top: 0;
  padding: 0.45rem 0.7rem;
  white-space: nowrap;
}

.stock-delete-btn {
  margin-top: 0;
  padding: 0.45rem 0.7rem;
  background: #b91c1c;
  white-space: nowrap;
}

.stock-delete-btn.is-loading {
  position: relative;
  pointer-events: none;
  padding-left: 1.8rem;
}

.stock-delete-btn.is-loading::before {
  content: "";
  position: absolute;
  left: 0.65rem;
  top: 50%;
  width: 0.75rem;
  height: 0.75rem;
  margin-top: -0.375rem;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin-delete-btn 0.8s linear infinite;
}

@keyframes spin-delete-btn {
  to {
    transform: rotate(360deg);
  }
}

.stock-detail-panel {
  margin-top: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  padding: 0.9rem;
}

.stock-detail-panel p {
  margin: 0.35rem 0;
}

.cash-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.7rem;
  margin-bottom: 0.8rem;
}

.cash-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  background: #f8fafc;
}

.cash-card h4 {
  margin: 0 0 0.35rem;
  font-size: 0.88rem;
  color: #475569;
}

.cash-value {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.site-footer {
  width: 100%;
  margin-top: 1rem;
  border-top: 1px solid #dbe3ef;
  background: rgba(255, 255, 255, 0.86);
}

.site-footer-inner {
  width: min(96%, 1160px);
  margin: 0 auto;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  color: #334155;
  font-size: 0.9rem;
}

.site-footer a {
  color: #0f766e;
  font-weight: 600;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  body {
    padding-top: 62px;
  }

  .top-banner-inner {
    width: 100%;
    padding: 0 0.8rem;
    height: 52px;
  }

  .top-banner-title {
    font-size: 0.92rem;
  }

  .top-banner-subtitle {
    font-size: 0.74rem;
  }

  .container {
    width: 100%;
    border-radius: 0;
    min-height: 100vh;
    padding: 1rem 0.8rem;
  }

  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .top-banner-logout {
    padding: 0.5rem 0.62rem;
    font-size: 0.76rem;
  }

  .top-banner-mode-toggle {
    padding: 0.5rem 0.62rem;
    font-size: 0.76rem;
  }

  .top-actions,
  .top-actions-4 {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.45rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mode-btn {
    flex: 0 0 auto;
    font-size: 0.77rem;
    padding: 0.58rem 0.62rem;
  }

  .stock-filters {
    grid-template-columns: 1fr;
  }

  .plan-cards {
    grid-template-columns: 1fr;
  }

  .sell-search-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .sell-mode-switch {
    justify-content: flex-start;
  }

  .stock-edit-cell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
    width: 100%;
  }

  .stock-edit-input {
    grid-column: 1 / -1;
    width: 100%;
  }

  .stock-save-btn,
  .stock-delete-btn {
    width: 100%;
  }

  .cash-summary {
    grid-template-columns: 1fr;
  }

  .sell-action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.55rem;
    margin: 0 auto;
    width: 100%;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-bottom: 0;
    border-left: 0;
    border-right: 0;
    border-radius: 14px 14px 0 0;
    z-index: 50;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    padding-bottom: calc(0.55rem + env(safe-area-inset-bottom, 0px));
  }

  #sell-panel {
    padding-bottom: 7.2rem;
  }

  .site-footer-inner {
    width: 100%;
    padding: 0 0.8rem;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 64px;
    font-size: 0.8rem;
  }
}
