
:root {
  --ink: #263238;
  --muted: #60727b;
  --line: #d9e1e5;
  --panel: #ffffff;
  --surface: #f4f7f6;
  --blue: #285f8f;
  --green: #1f7a5a;
  --amber: #b7791f;
  --red: #a6403b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--surface);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 11px;
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 21px;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar .data-version {
  margin-top: 2px;
  font-size: 12px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  width: 112px;
  height: auto;
  flex: 0 0 auto;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: calc(100vh - 76px);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #eef3f2;
  padding: 14px;
  overflow: auto;
}

.workspace {
  padding: 16px;
  overflow: auto;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.count-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.manufacturer-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.manufacturer-button,
.model-button {
  text-align: left;
  width: 100%;
}

.manufacturer-button.active,
.model-button.active {
  border-color: var(--green);
  background: #e4f3ec;
  color: #155d43;
  font-weight: 700;
}

.model-panel {
  margin-bottom: 0;
}

.search-input,
select,
.controls-row input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.model-category-filter {
  margin-top: 8px;
}

.model-feature-filters {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.model-feature-filters[hidden] {
  display: none;
}

.feature-filter {
  display: grid;
  gap: 4px;
}

.feature-filter span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.controls-row input:disabled {
  background: #eef3f2;
  color: #6f7f87;
  cursor: not-allowed;
}

.model-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.model-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.model-main {
  display: grid;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.model-thumb {
  width: 52px;
  height: 38px;
  flex: 0 0 52px;
  object-fit: contain;
}

.model-category-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.model-button > span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.machine-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 14px;
}

.machine-bar h2 {
  margin: 2px 0 0;
  font-size: 26px;
  letter-spacing: 0;
}

.machine-visual {
  width: 220px;
  height: 132px;
  flex: 0 0 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.machine-visual img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.machine-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.metric strong {
  font-size: 20px;
  letter-spacing: 0;
}

.controls-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}

.controls-row label {
  color: var(--muted);
  font-size: 12px;
  display: grid;
  gap: 5px;
}

.controls-row [hidden] {
  display: none;
}

.kioti-condition-control {
  grid-column: span 2;
  min-width: 0;
}

.support-control {
  display: grid;
  gap: 8px;
  align-content: start;
}

.support-control button.active {
  border-color: var(--green);
  background: #e4f3ec;
  color: #155d43;
  font-weight: 700;
}

.support-fields {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 8px;
}

.support-fields[hidden] {
  display: none;
}

.manual-form {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) minmax(190px, 1.6fr) minmax(120px, 1fr) repeat(3, minmax(105px, 0.8fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.manual-form label {
  color: var(--muted);
  font-size: 12px;
  display: grid;
  gap: 5px;
}

.manual-form input,
.manual-form select,
.offer-price-input,
.offer-margin-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.manual-form button {
  min-height: 37px;
}

.manual-remove {
  color: var(--red);
}

.offer-table input {
  min-width: 120px;
}

.offer-margin small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.notice {
  border: 1px solid #e8c872;
  background: #fff8dc;
  color: #775613;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}

.base-options {
  display: grid;
  gap: 8px;
}

.base-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 130px 130px;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.base-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.item-title {
  font-weight: 700;
}

.item-detail {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.item-tech {
  display: block;
  color: #36515f;
  font-size: 12px;
  line-height: 1.35;
  margin-top: 5px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 220px;
  gap: 10px;
  margin-bottom: 10px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.item-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  background: #fff;
}

.item-table th,
.item-table td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

.item-table th {
  background: #edf3f7;
  font-size: 12px;
  color: #36515f;
  position: sticky;
  top: 0;
  z-index: 1;
}

.item-table td:nth-child(1) {
  width: 76px;
  text-align: center;
}

.offer-table td:nth-child(1),
.manual-table-wrap .item-table td:nth-child(1) {
  width: auto;
  text-align: left;
}

.item-table td:nth-child(4),
.item-table td:nth-child(5),
.item-table td:nth-child(6) {
  white-space: nowrap;
}

.qty-input {
  width: 70px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.money-muted {
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
  padding: 12px;
}

.print-view {
  display: none;
}

.print-document {
  color: #111827;
  font-size: 12px;
}

.print-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  border-bottom: 2px solid #111827;
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.print-header h1 {
  margin: 0 0 4px;
  font-size: 22px;
}

.print-header p {
  margin: 2px 0;
}

.print-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.print-logo {
  width: 120px;
  height: auto;
  flex: 0 0 auto;
}

.print-image {
  width: 150px;
  height: 90px;
  object-fit: contain;
}

.print-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.print-summary div {
  border: 1px solid #d1d5db;
  padding: 7px;
}

.print-summary span {
  display: block;
  color: #4b5563;
  font-size: 10px;
  margin-bottom: 3px;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
}

.print-table th,
.print-table td {
  border-bottom: 1px solid #d1d5db;
  padding: 7px 5px;
  text-align: left;
  vertical-align: top;
}

.print-table th {
  background: #f3f4f6;
  font-size: 10px;
  text-transform: uppercase;
}

.print-group-row td {
  background: #e8f2ec;
  color: #155d43;
  font-weight: 700;
}

.print-group-row span {
  float: right;
  font-weight: 700;
}

.print-money,
.print-qty {
  text-align: right;
  white-space: nowrap;
}

@media print {
  body.print-ready .app-shell {
    display: none;
  }
  body.print-ready .print-view {
    display: block;
  }
  body {
    background: #fff;
  }
  @page {
    margin: 12mm;
  }
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .summary-grid,
  .controls-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .topbar,
  .machine-bar {
    flex-direction: column;
    align-items: stretch;
    height: auto;
  }
  .machine-visual {
    width: 100%;
    max-width: 260px;
    height: 130px;
    align-self: center;
  }
  .brand-block {
    align-items: flex-start;
  }
  .brand-logo {
    width: 92px;
  }
  .summary-grid,
  .controls-row,
  .manual-form,
  .filters,
  .base-row {
    grid-template-columns: 1fr;
  }
  .kioti-condition-control {
    grid-column: auto;
  }
  .machine-meta {
    align-items: flex-start;
  }
}
