/* styles.css — светлая тема, селекторы ровно под твой HTML */

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:#f7f7f9;
  color:#111;
  font:14px/1.45 system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;
  padding:18px;
}

/* Header */
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:14px;
}
.topbar h1{font-size:18px;margin:0}
.preview-toggle{display:flex;align-items:center;gap:8px}
.preview-toggle input{width:18px;height:18px}

/* Cards */
.card{
  background:#fff;
  border:1px solid #e7e7ec;
  border-radius:10px;
  padding:14px;
  margin-bottom:14px;
  box-shadow:0 3px 10px rgba(0,0,0,.05);
}
.card-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}
.card h2{font-size:16px;margin:0}

/* Grid helpers */
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
@media (max-width:720px){.grid-2{grid-template-columns:1fr}}
.span-2{grid-column:1 / -1}
.stack>*+*{margin-top:8px}

/* Buttons */
.btn{
  background:#2f6feb;
  color:#fff; border:1px solid #2b63d2;
  padding:8px 12px;
  border-radius:8px;
  cursor:pointer;
}
.btn:hover{opacity:.95}
.btn.outline{
  background:#fff; color:#2f6feb; border:1px solid #2f6feb;
}
.btn.warning{
  background:#ffc107; color:#111; border-color:#e2ab06;
}
.btn.icon{
  background:#f2f4f7; color:#333; border:1px solid #e0e3e8;
  padding:6px 10px;
}

/* Text */
.muted{color:#6b7280}
.small{font-size:12px;color:#6b7280}
.row{display:flex;align-items:center;justify-content:space-between}
.row.gap{gap:8px}
hr{border:0;border-top:1px solid #ececf0;margin:8px 0}

/* Inputs */
input[type="text"], input[type="number"], select{
  background:#fff; color:#111;
  border:1px solid #d9dde3; border-radius:8px;
  padding:7px 9px;
}
.num{width:100px;text-align:right}

/* Lines */
.lines{display:flex;flex-direction:column;gap:8px}
.line{
  display:grid; grid-template-columns: 2fr 0.7fr 0.9fr 1fr auto;
  gap:8px; align-items:center;
  background:#fafbfc; border:1px solid #e7e7ec; border-radius:8px; padding:8px;
}
.line .ln-amount{
  text-align:right; background:#fff; border:1px dashed #e3e6eb; border-radius:6px; padding:8px
}
.line .ln-del{
  background:#fff; border:1px solid #e0e4ea; color:#b40000;
  border-radius:8px; padding:6px 10px; cursor:pointer;
}
.line .ln-del:hover{background:#f5f7fa}

/* Totals */
.totals .row .val{font-weight:700}
.totals .grand .val{color:#000}

/* Modals */
.modal{
  position:fixed; inset:0; display:flex; align-items:center; justify-content:center;
  background:rgba(0,0,0,.4); z-index:100;
}
.modal-content{
  background:#fff; color:#111;
  border:1px solid #e7e7ec; border-radius:10px;
  width:min(720px,92vw); max-height:86vh; overflow:auto;
  padding:14px;
  box-shadow:0 8px 24px rgba(0,0,0,.12);
}
.modal-head{display:flex; align-items:center; gap:8px; margin-bottom:8px}
#searchQ{height:36px; line-height:1.25}
.status{color:#6b7280; margin:6px 0}

/* Results */
.results{display:flex; flex-direction:column; gap:6px}
.result{
  display:grid; grid-template-columns: 1fr auto; gap:8px; align-items:center;
  background:#fff; border:1px solid #e7e7ec; border-radius:8px; padding:10px;
}
.result .name{font-weight:700}
.result .meta{color:#6b7280; font-size:12px}
.result .btn{padding:6px 10px}

/* Preview mode (скрыть финансы) */
body.preview #totalsBlock,
body.preview .ln-price,
body.preview .ln-amount,
body.preview #internalBlock{
  display:none !important;
}

/* Canvas */
#sign{width:100%; display:block; background:#fff; border:1px solid #e0e4ea; border-radius:8px}
.is-invalid{outline:2px solid #ff5c5c}
/* Гарантия, что модалки скрыты по умолчанию и управляются через [hidden] */
.modal[hidden] { display: none !important; }

/* Базовая модалка (если у вас уже есть — оставьте, но важно чтобы была подложка и центрирование) */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.5);
  z-index: 1000;
}

/* Контент модалки, чтобы не растягивался на всю ширину на планшете */
.modal .modal-content {
  max-width: 720px;
  width: min(92vw, 720px);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  padding: 16px;
}

/* Область подписи: всегда видна и кликабельна на планшете */
#sign {
  width: 100%;            /* растягиваем визуально */
  height: 200px;          /* исходная высота; реальный буфер масштабируется в JS */
  border: 1px dashed var(--border, #ccc);
  background: #fff;
  touch-action: none;     /* важно для планшетов: отключает жесты скролла/зум */
  display: block;         /* исключает inline-артефакты */
}

/* ---------- Modal polish ---------- */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22, 22, 22, .45);
  z-index: 1000;
}

.modal[hidden] { display: none !important; }

.modal .modal-content {
  width: min(720px, 92vw);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 18px;
}

/* Header: title left, close icon right */
.modal-head.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border, #e7e7e7);
  margin-bottom: 12px;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

.btn.icon.close {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.btn.icon.close:hover { background: #f3f3f3; }

/* Search row: wide input + Search on the right */
.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 8px;
}
.search-row input#searchQ {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid #d9d9d9;
  border-radius: 10px;
}
.search-row .btn.primary {
  height: 40px;
  padding: 0 16px;
  border-radius: 10px;
}

/* Status */
.status {
  font-size: .9rem;
  color: #555;
  margin: 6px 2px 10px;
}

/* Results list */
.results { display: grid; gap: 8px; }

.result-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid #ececec;
  border-radius: 12px;
  background: #fafafa;
  transition: background .15s, border-color .15s, transform .04s;
}
.result-row:hover {
  background: #f2f6ff;
  border-color: #d6e4ff;
}
.result-row:active { transform: translateY(1px); }

.result-row .small { font-size: .85rem; }
.result-row .muted { color: #6b7280; }

/* Signature canvas keeps same styles */
#sign {
  width: 100%;
  height: 200px;
  border: 1px dashed var(--border, #ccc);
  background: #fff;
  touch-action: none;
  display: block;
  border-radius: 10px;
}
/* -------- Search Customer modal layout -------- */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(22,22,22,.45);
  z-index: 1000;
}
.modal[hidden] { display: none !important; }

.modal .modal-content {
  position: relative;
  width: min(720px, 94vw);
  max-height: 90vh;
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow-y: auto;
}

/* Close button — в правом верхнем углу */
.btn.icon.close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.btn.icon.close:hover { background: #f4f4f4; }

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 16px;
  padding-right: 42px; /* чтобы не наезжало на крестик */
}

/* Вся строка поиска */
.search-row.fullwidth {
  width: 100%;
  margin-bottom: 14px;
}
.input-wrap {
  display: flex;
  align-items: stretch;
  width: 100%;
}
.input-wrap input#searchQ {
  flex: 1 1 auto;
  padding: 0 14px;
  height: 44px;
  border: 1px solid #d9d9d9;
  border-radius: 10px 0 0 10px;
  font-size: 1rem;
}
.input-wrap button.btn.primary {
  border-radius: 0 10px 10px 0;
  padding: 0 20px;
  font-weight: 600;
  height: 44px;
  cursor: pointer;
}

/* Результаты */
.results { display: grid; gap: 8px; margin-top: 8px; }
.result-row {
  background: #fafafa;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  transition: 0.15s;
}
.result-row:hover {
  background: #eef4ff;
  border-color: #cbd8ff;
}
.result-row .small { font-size: .85rem; }
.result-row .muted { color: #6b7280; }


