/*
  Kasiopes Base UI (v2)
  Goals:
  - More modern, calmer visual hierarchy
  - Better mobile ergonomics
  - No functional changes (selectors preserved)
*/

:root{
  /* Page + surfaces */
  --bg: #f4f6fb;          /* page background */
  --surface: #ffffff;     /* cards / panels */
  --surface-2: #f8fafc;   /* subtle fills */
  --cell: #eef2f7;        /* legacy variable used across UI */

  /* Typography */
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(15, 23, 42, .12);

  /* Brand / actions */
  --btn:#3498db;
  --ok:#22c55e;
  --danger:#ef4444;
  --import:#f59e0b;
  --export:#f97316;
  --print:#8b5cf6;

  /* Layout */
  --shadow: 0 10px 28px rgba(15,23,42,.08);
  --shadow-sm: 0 6px 16px rgba(15,23,42,.06);
  --radius: 14px;
}

    *{box-sizing:border-box}
    body{
      margin:0;
      background:var(--bg);
      color:var(--text);
      font-family: "Arial Cyr","Inter","Segoe UI",system-ui,-apple-system,Arial,sans-serif;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
    }

    header{
      position:sticky;
      top:0;
      z-index:20;
      background:rgba(255,255,255,.92);
      backdrop-filter: blur(10px);
      border-bottom:1px solid var(--border);
    }

    .topbar{
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:12px;
      padding:12px 14px;
      max-width:1300px;
      margin:0 auto;
    }

    .brand{display:flex; flex-direction:column; line-height:1.15;}
    .brand b{font-size:16px; letter-spacing:.2px}
    .brand small{color:var(--muted)}

    .top-actions{
      display:flex;
      gap:10px;
      flex-wrap:wrap;
      justify-content:flex-end;
    }

    .wrap{
      max-width:1300px;
      margin:0 auto;
      padding:14px;
      display:grid;
      grid-template-columns: 1fr 320px;
      gap:14px;
      align-items:start;
    }

    @media (max-width: 980px){
      .wrap{grid-template-columns: 1fr; padding:12px; }
      .summary{position:relative !important; top:auto !important;}
      .topbar{padding:10px 12px;}
    }

    .panel{
      background:var(--surface);
      border:1px solid var(--border);
      border-radius:var(--radius);
      box-shadow:var(--shadow);
      overflow:hidden;
    }
    .panel .hd{
      padding:12px 14px;
      background:linear-gradient(to bottom, rgba(255,255,255,1), rgba(248,250,252,1));
      border-bottom:1px solid var(--border);
      display:flex;
      align-items:center;
      justify-content:space-between;
      gap:10px;
    }
    .panel .hd h2{
      margin:0;
      font-size:15px;
      letter-spacing:.2px;
    }
    .panel .bd{padding:14px; overflow:auto;}

    .stepper{display:flex; gap:8px; flex-wrap:wrap;}
    .chip{
      padding:8px 10px;
      border-radius:999px;
      background:var(--surface-2);
      border:1px solid var(--border);
      font-size:13px;
      cursor:pointer;
      user-select:none;
    }
    .chip.active{
      background:#e8f4ff;
      border-color: rgba(52,152,219,.55);
      font-weight:bold;
    }
    .chip.done{
      background:#eafff0;
      border-color: rgba(46,204,113,.50);
    }

    .grid2{
      display:grid;
      grid-template-columns: 1fr 1fr;
      gap:10px;
    }
    @media (max-width:650px){
      .grid2{grid-template-columns: 1fr;}
    }

    label{display:block; font-size:12px; color:var(--muted); margin-bottom:6px; font-weight:700}
    input, select, textarea{
      width:100%;
      padding:10px 12px;
      border-radius:12px;
      background:#fff;
      border:1px solid var(--border);
      outline:none;
      color:var(--text);
      font-size:14px;
    }
    input::placeholder, textarea::placeholder{color:#94a3b8}
    input.invalid, select.invalid, textarea.invalid{
      border-color: var(--danger);
      box-shadow: 0 0 0 3px rgba(231,76,60,.12);
      background: #fff3f2;
    }
    textarea{min-height:90px; resize:vertical}

    .row{
      display:flex;
      gap:10px;
      align-items:center;
      flex-wrap:wrap;
    }

    .btn{
      border:none;
      border-radius:12px;
      padding:10px 12px;
      cursor:pointer;
      font-weight:800;
      color:#fff;
      background:var(--btn);
      box-shadow:var(--shadow-sm);
      transition:.12s transform ease, .12s filter ease, .12s box-shadow ease;
      font-size:13px;
      display:inline-flex;
      align-items:center;
      justify-content:center;
      gap:8px;
      white-space:nowrap;
    }
    .btn:hover{ filter:brightness(.98); box-shadow: 0 10px 22px rgba(15,23,42,.10); }
    .btn:active{transform: translateY(1px)}
    .btn.secondary{
      color:var(--text);
      background:var(--surface-2);
      border:1px solid var(--border);
      box-shadow:none;
      font-weight:800;
    }
    .btn.ok{background:var(--ok); box-shadow:0 8px 18px rgba(46,204,113,.18)}
    .btn.danger{background:var(--danger); box-shadow:0 8px 18px rgba(231,76,60,.18)}
    .btn.import{background:var(--import); color:#111; box-shadow:0 8px 18px rgba(241,196,15,.18)}
    .btn.export{background:var(--export); box-shadow:0 8px 18px rgba(230,126,34,.18)}
    .btn.print{background:var(--print); box-shadow:0 8px 18px rgba(155,89,182,.18)}

    .hint{font-size:12px; color:var(--muted); line-height:1.35}
    .warn{
      background:#fffbeb;
      border:1px solid rgba(245,158,11,.35);
      padding:10px;
      border-radius:12px;
      font-size:12px;
      color:#5a4300;
      margin-top:10px;
      white-space:pre-wrap;
    }
    .okbox{
      background:#eafff0;
      border:1px solid rgba(46,204,113,.45);
      padding:10px;
      border-radius:10px;
      font-size:12px;
      color:#0c4a22;
      margin-top:10px;
    }

    table{
      width:100%;
      border-collapse:separate;
      border-spacing:0;
      overflow:hidden;
      border-radius:14px;
      border:1px solid var(--border);
      background:#fff;
    }
    th, td{
      padding:10px 10px;
      border-bottom:1px solid rgba(15,23,42,.08);
      font-size:13px;
      vertical-align:middle;
    }
    th{
      background:#f8fafc;
      text-align:left;
      font-size:12px;
      color:var(--muted);
      font-weight:900;
      text-transform:uppercase;
      letter-spacing:.04em;
      position:sticky;
      top:0;
      z-index:1;
    }
    tr:hover td{ background: rgba(2, 132, 199, .04); }
    tr:last-child td{border-bottom:none}

    /* Reduce border radius inside scroll containers */
    .panel .bd table{ border-radius:12px; }

    .col-num{width:70px}
    .col-w{width:200px}
    .col-h{width:200px}
    .col-dir{width:200px}
    .col-x{width:30px; text-align:center}

    .dirSwitch{
      display:flex;
      border:1px solid rgba(0,0,0,.18);
      background:var(--cell);
      border-radius:10px;
      overflow:hidden;
    }
    .dirSwitch button{
      flex:1;
      padding:10px 8px;
      border:none;
      background:transparent;
      cursor:pointer;
      font-weight:800;
      color:#333;
    }
    .dirSwitch button.active{
      background:#fff;
      box-shadow:inset 0 0 0 2px rgba(52,152,219,.35);
    }

    .summary{position:sticky; top:70px;}
    .sumGrid{
      display:grid;
      grid-template-columns: 1fr 1fr;
      gap:10px;
      margin-top:10px;
    }
    .sumCard{
      background:var(--cell);
      border:1px solid rgba(0,0,0,.12);
      border-radius:12px;
      padding:10px;
      min-height:66px;
    }
    .sumCard small{color:#555; display:block; margin-bottom:4px}
    .sumCard b{font-size:16px}
    .sumCard .big{font-size:18px}
    .sumRow{
      display:flex;
      justify-content:space-between;
      gap:10px;
      padding:8px 10px;
      background:var(--cell);
      border:1px solid rgba(0,0,0,.12);
      border-radius:12px;
      margin-top:10px;
      font-size:12px;
    }
    .badge{
      display:inline-flex;
      align-items:center;
      gap:6px;
      padding:6px 9px;
      border-radius:999px;
      border:1px solid rgba(0,0,0,.14);
      background:#fff;
      font-size:12px;
      font-weight:800;
    }
    .muted{color:#666}

    .divider{height:1px; background:rgba(0,0,0,.10); margin:12px 0}
    .hidden{display:none !important;}

    /* calc value cell */
    .cell-value{font-weight:900;}

    /* calc grouping */
    .calc-cat{background:#f2f2f2; font-weight:900;}
    .calc-subtotal{background:#fafafa; font-weight:900; border-top:2px solid rgba(0,0,0,.35);}
  
/* Hide empty summary cards */
.sumCard:empty{display:none;}

/* === INLINE box arrows (minimal width) === */
.box-stepper,
.box-arrows,
.box-selector {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: auto !important;
  min-width: unset !important;
  flex: 0 0 auto !important;
}

.box-stepper button,
.box-arrows button,
.box-selector button {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 6px;
  line-height: 1;
  font-size: 14px;
  flex: 0 0 auto;
}

.calc-row .box-stepper,
.calc-row .box-arrows,
.calc-row .box-selector {
  justify-content: center;
}


/* client checkboxes */
.chk{ display:inline-flex; align-items:center; gap:8px; padding:8px 10px; border:1px solid #e5e7eb; border-radius:10px; background:#fff; }
.chk input{ width:18px; height:18px; }


/* Editable Offer Number */
.summaryOfferNo{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:8px;
  flex: 0 1 320px;        /* allow shrink inside SUMMARY header */
  max-width: 56%;
  min-width: 0;
}
.summaryOfferNo .badge{
  white-space: nowrap;
}
.offerNoInput{
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  max-width: 220px;       /* keep inside the summary box */
  box-sizing: border-box;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.14);
  background: rgba(255,255,255,0.75);
  text-align: right;
  font-weight: 700;
}
.offerNoInput.isEditing{
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,160,234,0.18);
}
@media (max-width: 900px){
  .summaryOfferNo{ max-width: 100%; flex: 1 1 100%; }
  .offerNoInput{ max-width: 100%; }
}


/* Place Offer Number under SUMMARY */
.summaryOfferNo{
  margin-top: 8px;
  justify-content: flex-start;
  max-width: 100%;
}
.offerNoInput{
  max-width: 320px;
  text-align: left;
}


/* Offer number on new lines */
.offerNoColumn{
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.offerNoColumn .badge{
  padding-left: 0;
}



/* Confirm modal (ДА/НЕ) */
.k-modal.hidden{display:none !important;}
.k-modal{
  position:fixed; inset:0;
  z-index:9999;
  display:flex; align-items:center; justify-content:center;
}
.k-modal__backdrop{
  position:absolute; inset:0;
  background:rgba(0,0,0,.45);
}
.k-modal__panel{
  position:relative;
  width:min(420px, calc(100% - 24px));
  background:#fff;
  border-radius:14px;
  box-shadow:0 20px 60px rgba(0,0,0,.35);
  padding:16px 16px 14px;
}
.k-modal__title{
  font-weight:800;
  letter-spacing:.2px;
  margin-bottom:8px;
}
.k-modal__msg{
  line-height:1.35;
  margin-bottom:14px;
}
.k-modal__actions{
  display:flex;
  gap:10px;
  justify-content:flex-end;
}
@media print{
  .k-modal{display:none !important;}
}

#btnImport:hover,
#btnExport:hover,
#btnExportXlsx:hover,
#btnOffer:hover,
#btnCut:hover {
  background: #dfe6e9 !important;
  border-color: #dfe6e9 !important;
}

/* Action buttons (Import/Export/Offer/Cut) – compact, readable on dark RAL2100 background */
.btn.actionBtn{
  background:#ecf0f1;
  color:#2c3e50;
  border:1px solid rgba(0,0,0,.25);
  outline:1px solid rgba(255,255,255,.35);
  outline-offset:-2px;
  box-shadow:0 1px 0 rgba(0,0,0,.15);
}
.btn.actionBtn:hover{
  background:#dfe6e9;
  border-color:rgba(0,0,0,.35);
}
.btn.actionBtn:active{
  transform:translateY(1px);
  box-shadow:none;
}
.btn.actionBtn:disabled,
.btn.actionBtn.disabled{
  opacity:.55;
  cursor:not-allowed;
  transform:none;
  box-shadow:none;
}
.btn.actionBtn:hover{
  background:#dfe6e9;
  border-color:rgba(223,230,233,.9);
}
.btn.actionBtn:active{
  transform:translateY(1px);
  box-shadow:none;
}
.btn.actionBtn:disabled,
.btn.actionBtn.disabled{
  opacity:.55;
  cursor:not-allowed;
  transform:none;
  box-shadow:none;
}


/* Remove outline/contour on hover for all buttons */
button:hover,
.btn:hover{
  outline: none !important;
  outline-offset: 0 !important;
}


/* Unified hover behavior: hide outline, keep border (all buttons) */
button,
.btn{
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

button:hover,
.btn:hover{
  outline: none !important;
}


/* Header logo */
.headerTitle{
  display:flex;
  align-items:center;
  gap:12px;
}
.headerTitle img{
  height:32px;
  width:auto;
}


/* Header logo in visible topbar */
.topbar .brand{
  display:flex;
  flex-direction:row;
  align-items:center;
  gap:12px;
}
.topbar .brand .brandLogo{
  height:32px;
  width:auto;
  display:block;
}
.topbar .brand b,
.topbar .brand small{
  display:block;
}


.topbar .brandText{
  display:flex;
  flex-direction:column;
  line-height:1.15;
}


    /* Offer table: automatic column widths and compact control column */
    table{ table-layout:auto; width:100%; }
    th,td{ width:auto; }
    td.colControl{ white-space:nowrap; font-size:12px; }



/* =========================
   Документи: drop-down меню (отворя НАГОРЕ, без изрязване)
   ========================= */
.docsDropdown{ position: relative; display: inline-flex; }

.docsMenu{
  position: fixed; /* set by JS */
  z-index: 99999;
  background: #fff;
  border: 1px solid rgba(0,0,0,.14);
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(0,0,0,.18);
  padding: 6px;
  min-width: 240px;
}

.docsMenu.hidden{ display:none; }

.docsItem{
  width: 100%;
  display: block;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}

.docsItem:hover{ background: rgba(52,152,219,.10); }

.colorIcon {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.15);
  vertical-align: middle;
  margin-right: 6px;
  object-fit: cover;
}
.colorWrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.colorCode {
  font-size: 11px;
  opacity: .85;
  white-space: nowrap;
}

/* Top dropdown menu (НОВА/ИМПОРТ/ЕКСПОРТ/НАСТРОЙКИ/ИЗХОД) */
.topMenu{ position: relative; }
.menuList{
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0,0,0,.12);
  padding: 6px;
  z-index: 2000;
}
.menuList.hidden{ display:none; }
.menuItem{
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
}
.menuItem:hover{ background: rgba(52,152,219,.10); }

/* Bottom actions alignment */
.bottomActions{ display:flex; align-items:center; gap:10px; }
.bottomActions .bottomLeft{ display:flex; align-items:center; gap:10px; }
.bottomActions .bottomRight{ margin-left:auto; display:flex; align-items:center; gap:10px; }


/* ===== Inventory (v104.17) ===== */
.modal{ position:fixed; inset:0; background:rgba(0,0,0,.45); display:flex; align-items:center; justify-content:center; z-index:9999; }
.modal.hidden{ display:none; }
.modalCard{ width:min(1100px, 96vw); max-height:92vh; overflow:auto; background:#fff; border-radius:14px; padding:14px; box-shadow:0 10px 40px rgba(0,0,0,.25); }
.modalHd{ display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; }
.invTabs{ display:flex; gap:8px; border-bottom:1px solid #e6e6e6; padding-bottom:8px; margin-bottom:10px; }
.invTab{ border:1px solid #d8d8d8; background:#f8f8f8; padding:6px 10px; border-radius:10px; cursor:pointer; }
.invTab.active{ background:#fff; border-color:#bdbdbd; font-weight:700; }
.invActions{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:10px; }
.tableWrap{ overflow:auto; border:1px solid #e9e9e9; border-radius:12px; }
.tbl{ width:100%; border-collapse:collapse; font-size:13px; }
.tbl th, .tbl td{ padding:8px 10px; border-bottom:1px solid #eee; white-space:nowrap; text-align:left; }
.tbl th{ background:#fafafa; position:sticky; top:0; z-index:1; }

/* Warehouse row delete button */
.whRowDel{color:#b00020 !important;border-color:#b00020 !important;}
.whRowDel:hover{background:#b00020 !important;color:#fff !important;}

/* Status badges */
.status-badge{
  display:inline-block;
  padding:2px 8px;
  border-radius:10px;
  font-size:12px;
  font-weight:600;
}
.st-available{background:#e6f4ea;color:#137333;}
.st-reserved{background:#fff4e5;color:#b45309;}
.st-expected{background:#e8f0fe;color:#1a73e8;}
.st-scrap{background:#fdecea;color:#b00020;}
.st-consumed{background:#f1f3f4;color:#5f6368;}
