:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #1e2d2f;
  --accent: #006d77;
  --accent-soft: #d6f1f3;
  --line: #d8e0e2;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  background: radial-gradient(circle at 10% 10%, #edf9fa, var(--bg));
  color: var(--ink);
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-container {
  width: min(420px, 94vw);
}

.brand-logo {
  display: block;
  max-width: 100%;
  object-fit: contain;
}

.login-logo {
  width: 330px;
  margin: 0 auto 10px;
}

h1, h2 {
  margin: 0 0 10px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(20, 55, 58, 0.08);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #eff8f9;
  border-bottom: 1px solid var(--line);
}

.topbar-brand {
  flex: 0 0 auto;
}

.topbar-title {
  flex: 1;
}

.topbar-logo {
  width: 180px;
}

.layout {
  padding: 16px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

@media (min-width: 1100px) {
  body.role-1 .layout,
  body.role-2 .layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.role-1 #salesScreenPanel,
  body.role-2 #salesScreenPanel,
  body.role-1 #closingsPanel,
  body.role-2 #closingsPanel {
    grid-column: 1 / -1;
  }
}

.sales-panel {
  grid-column: 1 / -1;
}

.full-width {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  font-weight: 600;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
}

button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  background: #6c7a80;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.size-row {
  display: flex;
  margin-bottom: 10px;
}

.size-row label {
  margin-bottom: 0;
  max-width: 220px;
}

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

.products-grid.size-small {
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.products-grid.size-medium {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.products-grid.size-large {
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
}

.product-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
}

.product-card img {
  width: 100%;
  object-fit: cover;
}

.products-grid.size-small .product-card img {
  height: 84px;
}

.products-grid.size-medium .product-card img {
  height: 92px;
}

.products-grid.size-large .product-card img {
  height: 120px;
}

.product-info {
  padding: 8px;
  display: grid;
  gap: 3px;
  font-size: 12px;
}

.product-info strong {
  font-size: 13px;
}

.products-grid.size-large .product-info {
  font-size: 13px;
}

.products-grid.size-large .product-info strong {
  font-size: 14px;
}

.totals {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  padding: 10px;
  border-radius: 10px;
  background: var(--accent-soft);
}

#addItemBtn {
  margin-bottom: 10px;
}

#saleItemsContainer {
  margin-bottom: 10px;
}

.paste-image-box {
  border: 1px dashed #8ea3a8;
  border-radius: 10px;
  padding: 10px;
  min-height: 52px;
  background: #f9fcfd;
  color: #4d676d;
}

.paste-image-box:focus {
  outline: 2px solid #8dc7cd;
}

#pastedImagePreview {
  margin-bottom: 10px;
}

#pastedImagePreviewImg {
  margin-top: 6px;
  width: min(220px, 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.hidden {
  display: none;
}

.error {
  color: var(--danger);
  min-height: 1.2em;
}

#autoReportInfo {
  margin: 0 0 8px;
  color: #38565c;
  font-size: 13px;
}

#reportResult table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 14px;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 10px;
}

#manageProductsContainer {
  max-height: 460px;
  overflow-y: auto;
}

#closingsResult .table-scroll {
  max-height: 460px;
  overflow-y: auto;
}

.table-scroll table {
  margin-top: 0;
  min-width: 720px;
}

#managementReportsResult h3 {
  margin-top: 18px;
}

.management-period-label {
  margin: 0 0 10px;
  color: #38565c;
}

.management-charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.management-chart {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fbfcfd;
}

.management-chart h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.chart-row {
  display: grid;
  grid-template-columns: 70px 1fr 90px;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}

.chart-label,
.chart-value {
  font-size: 12px;
}

.chart-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-value {
  text-align: right;
  font-weight: 600;
}

.chart-bar-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: #e6eef0;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0997a5, #2cc3cf);
  border-radius: 999px;
}

#reportResult th,
#reportResult td,
#closingsResult th,
#closingsResult td {
  border: 1px solid var(--line);
  padding: 6px;
}

#reportResult tfoot {
  font-weight: 700;
}

#closingsResult table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 14px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: grid;
  place-items: center;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(520px, 92vw);
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid var(--line);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

@media print {
  .topbar,
  #saleForm,
  #searchInput,
  #refreshBtn,
  #reportForm,
  #adminPanel {
    display: none !important;
  }

  body {
    background: white;
  }

  .layout {
    display: block;
  }
}
