/* Базовые стили — стиль аккуратный, корпоративный, адаптивный */
:root{
  --bg:#f4f6f8;
  --panel:#ffffff;
  --primary:#0b5fa5;
  --muted:#6b7a89;
  --accent:#f5f8fb;
  --radius:8px;
  --gap:16px;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:Inter, "Segoe UI", Roboto, Arial, sans-serif;
  background:var(--bg);
  color:#17202a;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  line-height:1.4;
}

/* Header */
.site-header{
  background:linear-gradient(180deg,#133f63, #0f3350);
  color:#fff;
  padding:14px 20px;
  box-shadow:0 2px 8px rgba(10,20,30,0.12);
  position:sticky;
  top:0;
  z-index:50;
}
.header-inner{
  max-width:1200px;
  margin:0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
}
.logo{height:63px}
.brand-name{font-weight:700; font-size:18px}

/* Navigation */
.main-nav .nav-list{
  list-style:none;
  display:flex;
  gap:8px;
  align-items:center;
  margin:0;
  padding:0;
}
.nav-btn{
  background:none;
  border:0;
  color:#fff;
  padding:8px 12px;
  font-size:15px;
  border-radius:6px;
  cursor:pointer;
}
.nav-btn:hover{background:rgba(255,255,255,0.06)}
.nav-dropdown{position:relative}

/* Dropdown */
.drop-toggle{display:inline-flex;align-items:center}
.dropdown{
  position:absolute;
  right:0;
  top:calc(100% + 8px);
  background:#0e2c44;
  border-radius:8px;
  box-shadow:0 8px 24px rgba(3,10,18,0.4);
  padding:8px;
  min-width:200px;
  display:none;
  flex-direction:column;
  gap:6px;
  z-index:60;
}
.dropdown .nav-btn{
  color:#e6f2ff;
  text-align:left;
  width:100%;
  padding:10px 12px;
  border-radius:6px;
  font-size:14px;
}
.dropdown .nav-btn:hover{background:rgba(255,255,255,0.03)}

/* Container + content panel */
.container{
  max-width:1200px;
  margin:20px auto;
  padding:0 16px;
}
.content{
  background:var(--panel);
  border-radius:var(--radius);
  padding:18px;
  box-shadow:0 6px 20px rgba(16,26,38,0.06);
  min-height:360px;
}

/* Panels, tables, controls */
.toolbar{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:space-between;
  margin-bottom:12px;
  flex-wrap:wrap;
}
.controls{display:flex; gap:8px; align-items:center}
.input{
  padding:8px 10px;
  border-radius:8px;
  border:1px solid #e6eef7;
  background:var(--accent);
  min-width:220px;
}
.button{
  background:var(--primary);
  color:#fff;
  border:0;
  padding:8px 12px;
  border-radius:8px;
  cursor:pointer;
  font-weight:600;
}
.button.ghost{
  background:transparent;color:var(--primary);border:1px solid rgba(11,95,165,0.12)
}

/* Table */
.table{
  width:100%;
  border-collapse:collapse;
  margin-top:8px;
  font-size:14px;
}
.table th, .table td{
  padding:10px 12px;
  border-bottom:1px solid #eef4fa;
  text-align:left;
}
.table th{
  background:linear-gradient(180deg,#fbfdff,#f7fbff);
  color:#213547;
  font-weight:600;
}
.status{
  padding:6px 8px;
  border-radius:999px;
  font-size:13px;
  display:inline-block;
  min-width:80px;
  text-align:center;
}
.status.delivered{background:#e6fbf0;color:#036a26}
.status.in-transit{background:#fff6e6;color:#8a5a00}
.status.pending{background:#fff0f4;color:#7a0630}

/* Cards */
.grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
  gap:12px;
  margin-top:12px;
}
.card{
  background:var(--accent);
  padding:14px;
  border-radius:10px;
  box-shadow:inset 0 0 0 1px rgba(10,30,50,0.02);
}
.card h3{margin:0 0 8px 0}
.small{font-size:13px;color:var(--muted)}

/* Footer */
.site-footer{
  max-width:1200px;
  margin:20px auto;
  padding:10px 16px;
  color:var(--muted);
  text-align:center;
  font-size:13px;
}

/* Responsive */
@media (max-width:720px){
  .header-inner{padding:0 8px}
  .brand-name{display:none}
  .dropdown{right:unset; left:0; min-width:160px}
  .input{min-width:140px}
}

/* Modal */
.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.45);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:999;
}
.modal.show{display:flex}

.modal-content{
  background:#fff;
  padding:20px;
  border-radius:12px;
  width:320px;
  display:flex;
  flex-direction:column;
  gap:10px;
  box-shadow:0 12px 34px rgba(0,0,0,0.25);
}

.modal-content label{
  font-size:13px;
  color:#345;
  margin-top:4px;
}

.modal-actions{
  display:flex;
  justify-content:space-between;
  margin-top:10px;
}

.form-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

.form-row label {
  font-size: 14px;
  margin-bottom: 4px;
}

.form-row input,
.form-row select {
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #d6d6d6;
  font-size: 15px;
}

.total-line input {
  font-weight: 600;
}

.submit-btn {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  background: #0059ff;
  color: #fff;
  font-size: 16px;
  border: none;
  cursor: pointer;
}

.submit-btn:hover {
  background: #0046c7;
}

.invoice-form {
  max-width: 500px;
  margin: 0 auto;
  background: #ffffff;
  padding: 24px;
  border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.08);
}

.invoice-form h2 {
  margin-bottom: 18px;
  font-weight: 600;
  font-size: 22px;
}

.form-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
}

.form-row label {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: #243447;
}

.form-row input,
.form-row select {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #d8e1eb;
  background: #f8fafc;
  font-size: 15px;
  transition: border-color .2s;
}

.form-row input:focus,
.form-row select:focus {
  border-color: #0b5fa5;
  outline: none;
}

.submit-btn {
  width: 100%;
  padding: 14px;
  margin-top: 14px;
  border-radius: 12px;
  background: #0b5fa5;
  color: #fff;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}

.submit-btn:hover {
  background: #094c85;
}

/* ---------- Поисковик подсказок ---------- */

.suggest-item:hover {
  background: #f1f5f9;
}

/* ---------- Invoice (ss) / Packages (aa) styles ---------- */
.invoice-page {
  padding: 18px;
}
.invoice-panel {
  background: #fff;
  border-radius: 10px;
  padding: 22px;
  box-shadow: 0 6px 20px rgba(16,26,38,0.06);
  border: 1px solid #eef4fa;
  margin-bottom: 18px;
}

/* Top row: Откуда / Куда / Тариф */
.row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1.6fr;
  gap: 14px;
  margin-bottom: 14px;
}
.row-3 .form-group label { font-size: 14px; color:#33414a; margin-bottom:6px; }

.form-group { display:flex; flex-direction:column; }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid #e6eef7;
  background: #f8fafc;
  font-size: 14px;
}

/* sender select / search */
.sender-row {
  margin: 8px 0 18px;
}
.sender-row .sender-select {
  display:flex;
  gap:10px;
  align-items:center;
}
.sender-select select {
  flex:1;
  background:#fff;
}
.add-contact {
  color:#6b7a89;
  font-size:13px;
  text-decoration:underline;
  cursor:pointer;
  margin-top:6px;
  display:inline-block;
}

/* Grid of small inputs (weights, fees, etc) */
.grid-6 {
  display:grid;
  grid-template-columns:repeat(6, 1fr);
  gap:12px;
  align-items:end;
  margin-top:12px;
}
.grid-6 .form-group input[disabled] { background:#eef3f6; color:#677b87; }

/* Totals row */
.totals-row {
  display:flex;
  grid-template-columns:repeat(6,1fr);
  gap:12px;
  margin-top:12px;
}
.totals-row .total-box {
  background:#eef3f6;
  padding:12px;
  border-radius:12px;
  min-height:44px;
  display:flex;
  align-items:center;
  justify-content:flex-start;
  color:#4b5b66;
}

/* Packages area */
.packages-wrap {
  margin-top:20px;
}
.package-card {
  background:#fff;
  border-radius:8px;
  padding:16px;
  border:1px solid #eef4fa;
  margin-bottom:12px;
}
.package-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:8px;
}
.package-grid {
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap:12px;
  margin-bottom:8px;
}
.package-grid .form-group textarea { min-height:86px; }

/* small inputs row */
.small-row {
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:12px;
  margin-top:8px;
}

/* bottom actions */
.actions-row {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;
  margin-top:16px;
}
.btn-ghost {
  background:transparent;
  border:1px solid #cfe0ff;
  color:#0b5fa5;
  padding:10px 14px;
  border-radius:8px;
  cursor:pointer;
}
.btn-primary {
  background:#0b5fa5;
  color:#fff;
  border:0;
  padding:12px 18px;
  border-radius:8px;
  cursor:pointer;
}

/* Suggestions for sender search */
.suggest-box {
  position: absolute;
  top: 100%;          /* строго под input */
  left: 0;
  right: 0;
  margin-top: 4px;

  background: #fff;
  border: 1px solid #d4dce4;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.12);

  z-index: 500;
  display: none;
}

.suggest-item {
  padding:10px 12px;
  cursor:pointer;
}
.suggest-item:hover { background:#f7fbff; }

/* Responsive */
@media (max-width:980px){
  .row-3 { grid-template-columns:1fr; }
  .grid-6, .totals-row { grid-template-columns: repeat(2,1fr); }
  .package-grid { grid-template-columns:1fr; }
  .small-row { grid-template-columns: repeat(2,1fr); }
}
.profile-wrapper {
  position: relative;
  z-index: 200;
  margin-left: auto;
}

.profile-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.2s;
  pointer-events: auto;
}

.profile-btn:hover {
  background: rgba(0,0,0,0.05);
}

.profile-btn i {
  font-size: 26px;
}

.profile-name {
  font-weight: 500;
}

.profile-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 200px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
}

.profile-item {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
}

.profile-item:hover {
  background: #f5f6f8;
}

.profile-divider {
  height: 1px;
  background: #eee;
}

.profile-item.logout {
  color: #d93025;
  font-weight: 500;
}

.main-nav {
  position: relative;
  z-index: 100;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.show {
  display: flex;
}
.autocomplete {
  position: relative;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--crm-accent);
  border-radius: 6px;
  margin-top: 4px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background: rgba(59, 130, 246, 0.12); /* мягкая голубая подсветка */
}

.autocomplete-item.active {
  outline: 1px solid var(--crm-accent);
}
.input.locked {
  background-color: #f4f9fc;
  cursor: pointer;
}
#tariffSelect:disabled {
  background: #f4f9fc;
  cursor: not-allowed;
}
.package-card-mini {
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
  background: #f7fbff;
  display: flex;
  gap: 12px;
}

.pkg-id {
  font-weight: 600;
  color: #1e88e5;
}

.pkg-info {
  font-size: 13px;
}

.muted {
  opacity: 0.6;
  font-size: 12px;
}
#savePdfBtn {
  margin-top: 8px;
  width: 100%;
}
@media print {
  body * {
    visibility: hidden;
  }

  .invoice-page,
  .invoice-page * {
    visibility: visible;
  }

  .invoice-page {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }

  /* скрываем кнопки */
  button {
    display: none !important;
  }
}
.pdf-row {
  max-width: 220px; /* ровно как total-box */
  margin-top: 8px;
}

.pdf-row button {
  width: 100%;
}
/* =========================
   PDF TEMPLATE (A4)
   ========================= */

#pdfTemplate{
  position: absolute;
  left: -10000px;
  top: 0;
  width: 794px;       /* A4 @ 96dpi */
  min-height: 1123px; /* A4 */
  background: #ffffff;
  visibility: hidden;
}

.pdf-page{
  width: 100%;
  min-height: 1123px;
  padding: 32px;
  font-family: Arial, sans-serif;
  font-size: 14px;
  color: #000;
}

.pdf-block{
  margin-bottom: 16px;
}
#pdfTemplate table td,
#pdfTemplate table th {
  border: 1px solid #000;
  padding: 4px;
}

#pdfTemplate th {
  background: #f2f2f2;
  font-weight: bold;
  text-align: center;
}

.pdf-td-label {
  font-weight: bold;
  background: #f9f9f9;
  width: 20%;
}

#pdfTemplate .pdf-table th:nth-child(1),
#pdfTemplate .pdf-table td:nth-child(1) { width: 5%; }

#pdfTemplate .pdf-table th:nth-child(2),
#pdfTemplate .pdf-table td:nth-child(2) { width: 10%; }

#pdfTemplate .pdf-table th:nth-child(3),
#pdfTemplate .pdf-table td:nth-child(3) { width: 14%; }

#pdfTemplate .pdf-table th:nth-child(4),
#pdfTemplate .pdf-table td:nth-child(4) { width: 7%; text-align: center; }

#pdfTemplate .pdf-table th:nth-child(5),
#pdfTemplate .pdf-table td:nth-child(5) { width: 14%; }

#pdfTemplate .pdf-table th:nth-child(6),
#pdfTemplate .pdf-table td:nth-child(6) { width: 16%; }

#pdfTemplate .pdf-table th:nth-child(7),
#pdfTemplate .pdf-table td:nth-child(7) { width: 10%; }

#pdfTemplate .pdf-table th:nth-child(8),
#pdfTemplate .pdf-table td:nth-child(8) { width: 24%; }

.invoice-search {
  position: relative; /* 🔑 ОПОРНАЯ ТОЧКА */
  max-width: 320px;
}

.invoice-search .input {
  width: 100%;
}
#pdfTemplate .pdf-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* критично */
  font-size: 11px;
}

#pdfTemplate .pdf-table th,
#pdfTemplate .pdf-table td {
  padding: 6px 6px;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

#pdfTemplate .pdf-table th {
  text-align: center;
  font-weight: 600;
  border-bottom: 1px solid #000;
}
.action-wrap {
  position: relative;
}

.action-menu {
  display: flex;
  gap: 6px;
}

.button.danger {
  background: #ff4d4f;
  color: #fff;
  border: none;
}
