:root{font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;color:#172033;background:#f5f7fb;line-height:1.45}*{box-sizing:border-box} a {text-decoration: none;color: inherit;}body{margin:0}button,input,select,textarea{font:inherit;max-width:100%}button{cursor:pointer}.app{min-height:100vh}.topbar{position:sticky;top:0;z-index:20;background:#fff;border-bottom:1px solid #e7eaf0;display:flex;align-items:center;justify-content:space-between;padding:12px 18px}.brand{font-weight:800;font-size:19px}.brand small{display:block;font-size:11px;color:#7a8395;font-weight:500}.menu-btn{border:1px solid #e2e6ee;background:#fff;border-radius:10px;padding:8px 10px}.layout{display:flex;min-height:calc(100vh - 61px)}.sidebar{width:245px;background:#fff;border-right:1px solid #e7eaf0;padding:14px;flex-shrink:0}.nav-title{font-size:11px;text-transform:uppercase;color:#8a93a5;margin:14px 8px 6px}.nav a{display:flex;gap:10px;padding:10px 11px;border-radius:10px;color:#334056;text-decoration:none;margin:2px 0}.nav a:hover,.nav a.active{background:#eef3ff;color:#244cc0}.main{flex:1;padding:22px;min-width:0}.page-head{display:flex;justify-content:space-between;align-items:flex-start;gap:15px;margin-bottom:18px}.page-head h1{margin:0;font-size:27px}.muted{color:#7a8395}.grid{display:grid;gap:14px}.cards{grid-template-columns:repeat(auto-fit,minmax(180px,1fr))}.card{background:#fff;border:1px solid #e5e9f0;border-radius:15px;padding:16px;box-shadow:0 2px 8px #1a25400a}.metric{font-size:27px;font-weight:800;margin-top:4px}.label{font-size:13px;color:#7b8495}.panel{background:#fff;border:1px solid #e5e9f0;border-radius:15px;padding:16px;margin-bottom:16px}.toolbar{display:flex;gap:9px;flex-wrap:wrap;align-items:center;margin-bottom:14px}.search{min-width:230px;flex:1}.input,select,textarea{width:100%;border:1px solid #d9dee8;border-radius:10px;padding:10px 11px;background:#fff;color:#182238;outline:none}.input:focus,select:focus,textarea:focus{border-color:#6d8df7;box-shadow:0 0 0 3px #6d8df71c}.btn{border:0;border-radius:10px;padding:10px 14px;font-weight:700;min-height:40px}.btn.primary{background:#2d5be3;color:#fff}.btn.secondary{background:#eef2f8;color:#2f3b50}.btn.danger{background:#feecec;color:#bd3030}.btn.success{background:#eaf8ef;color:#1f7a40}.btn.small{padding:7px 9px;font-size:12px;min-height:34px}.table-wrap{overflow:auto}.table{width:100%;border-collapse:collapse;min-width:720px}.table th,.table td{text-align:left;padding:11px 9px;border-bottom:1px solid #edf0f4;vertical-align:middle}.table th{font-size:12px;color:#737d8f;background:#fafbfc}.badge{display:inline-flex;padding:4px 8px;border-radius:99px;font-size:12px;font-weight:700;background:#eef2f8}.badge.red{background:#feecec;color:#b52b2b}.badge.green{background:#eaf8ef;color:#1e7940}.actions{display:flex;gap:6px;flex-wrap:wrap}.empty{text-align:center;padding:35px;color:#8a93a5}.form-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.form-grid.three{grid-template-columns:repeat(3,minmax(0,1fr))}.field label{display:block;font-size:12px;color:#697387;margin:0 0 5px}.field.full{grid-column:1/-1}.modal-backdrop{position:fixed;inset:0;background:#11182780;display:none;align-items:center;justify-content:center;padding:18px;z-index:100}.modal-backdrop.show{display:flex}.modal{background:#fff;border-radius:16px;width:min(760px,100%);max-height:90vh;overflow:auto;padding:20px}.modal h2{margin:0 0 15px}.modal-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:16px}.toast{position:fixed;right:16px;bottom:16px;background:#172033;color:#fff;padding:11px 14px;border-radius:10px;display:none;z-index:200}.toast.show{display:block}.login-page{min-height:100vh;display:grid;place-items:center;padding:20px;background:linear-gradient(135deg,#eef3ff,#f8fafc)}.login-box{width:min(420px,100%);background:#fff;border:1px solid #e5e9f0;border-radius:18px;padding:28px;box-shadow:0 15px 50px #18233d12}.login-box h1{margin:0 0 4px}.login-box p{margin:0 0 20px;color:#778197}.error{color:#bb2d2d;font-size:13px;margin-top:8px}.kpi-note{font-size:12px;color:#8992a3;margin-top:3px}.hierarchy{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:14px}.chip{background:#f1f4f9;border-radius:999px;padding:7px 10px;font-size:12px}.danger-row{background:#fff6f6}.photo-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px}.photo-box{border:1px dashed #cfd6e2;border-radius:12px;padding:10px;text-align:center}.photo-box img{max-width:100%;max-height:220px;border-radius:9px}.mobile-only{display:none}
.debtor-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:14px}
.debtor-card{border:1px solid #e5e7eb;border-radius:16px;padding:16px;background:#fff;box-shadow:0 4px 14px rgba(0,0,0,.04)}
.debtor-card.overdue{border-color:#fca5a5}
.debtor-head{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:12px;align-items:start}
.debtor-head h3{margin:0 0 5px;font-size:18px}
.debtor-main{min-width:0}.debtor-info{display:flex;flex-direction:column;gap:4px;margin-top:6px}.debtor-info span{display:block}
.debtor-head a{text-decoration:none;color:inherit}
.debt-sum{font-size:20px;font-weight:800;white-space:nowrap}
.debtor-meta{display:flex;flex-direction:column;gap:6px;margin:14px 0;color:#555;font-size:14px}
.debtor-actions{display:flex;gap:8px;flex-wrap:wrap}

.поступления-кнопки .btn{min-height:44px}
.поступления-список{display:grid;gap:12px}
.товар-карточка{border:1px solid #e5e9f0;border-radius:14px;padding:14px;background:#fff}
.товар-заголовок{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}
.товар-заголовок b{font-size:16px}
.история-поступлений{display:grid;gap:12px}.история-строка{display:block;padding:16px;border:1px solid #e5e9f0;border-radius:14px;background:#fff}.поступление-заголовок{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:14px}.поступление-товары-title{font-weight:700;margin-bottom:8px}.поступление-товар{padding:12px;border:1px solid #e5e9f0;border-radius:12px;margin-top:8px;background:#f8fafc;line-height:1.5}.поступление-товар>b{display:block;margin-bottom:3px}.поступление-товар div{margin-top:2px}


/* Адаптивность для телефонов */
.main{width:0}
.page-head{flex-wrap:wrap}
.field{min-width:0}
.table-wrap{width:100%;max-width:100%;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain}
.btn:disabled{opacity:.55;cursor:not-allowed}
@media(max-width:800px){
  .sidebar{position:fixed;left:-270px;top:61px;bottom:0;z-index:30;transition:.2s;box-shadow:8px 0 30px #11182720}
  .sidebar.open{left:0}
  .mobile-only{display:block}
  .main{padding:15px}
  .page-head h1{font-size:23px}
  .form-grid,.form-grid.three{grid-template-columns:1fr}
  .cards{grid-template-columns:repeat(2,minmax(0,1fr))}
  .search{min-width:0}
  .topbar{padding:11px 13px}
  body{overflow-x:hidden}
  .main{width:auto;overflow:hidden}
  .toolbar{width:100%}
  .toolbar>.input,.toolbar>.search{flex:1 1 100%;min-width:0}
  .page-head .actions{width:100%}
  .page-head .actions .btn{flex:1}
  .table{min-width:680px}
  .поступления-кнопки{display:grid;grid-template-columns:1fr}
  .поступления-кнопки .btn{width:100%;min-height:44px}
  .товар-карточка{padding:12px}
  .товар-карточка .form-grid{gap:10px}
  .товар-карточка input{min-height:44px}
  .история-строка{padding:12px}
  .поступление-заголовок{align-items:stretch;flex-direction:column}
  .поступление-заголовок .btn{width:100%}
  .поступление-товар{padding:11px}
  .photo-grid{grid-template-columns:1fr}
  .debtor-grid{grid-template-columns:1fr}
  .modal-backdrop{padding:10px}
  .modal{width:100%;max-height:calc(100vh - 20px);padding:14px}
  .modal .input{min-height:44px}
  .modal-actions .btn{min-height:44px}
  .debtor-head{grid-template-columns:minmax(0,1fr) auto}.debtor-info{gap:5px}.debtor-info span{white-space:nowrap}
}
@media(max-width:480px){
  .topbar{gap:8px}
  .brand{font-size:16px;line-height:1.2}
  .main{padding:12px}
  .panel{padding:12px;border-radius:13px}
  .cards{grid-template-columns:1fr}
  .metric{font-size:23px}
  .page-head h1{font-size:21px}
  .page-head>.btn,.page-head .actions .btn{width:100%}
  .actions{width:100%}
  .actions .btn{flex:1 1 100%}
  .toolbar>.btn{flex:1 1 100%;min-height:44px}
  .search{min-width:0}
  .поступления-кнопки .btn{min-height:46px}
  .товар-карточка{padding:10px}
  .товар-заголовок{align-items:flex-start}
  .товар-заголовок .btn{min-height:40px}
  .modal-actions{display:grid;grid-template-columns:1fr}
  .modal-actions .btn{width:100%}
  .topbar .btn{min-height:40px}
  .menu-btn{min-width:42px;min-height:42px}
}

@media(max-width:800px){
  body[data-page="sales"] .table-wrap,
  body[data-page="warehouse"] .table-wrap,
  body[data-page="metered"] .table-wrap{
    overflow:visible;
    width:100%;
  }

  body[data-page="sales"] .table,
  body[data-page="warehouse"] .table,
  body[data-page="metered"] .table{
    width:100%;
    min-width:0;
    border-collapse:separate;
    border-spacing:0;
    display:block;
  }

  body[data-page="sales"] .table thead,
  body[data-page="warehouse"] .table thead,
  body[data-page="metered"] .table thead{
    display:none;
  }

  body[data-page="sales"] .table tbody,
  body[data-page="warehouse"] .table tbody,
  body[data-page="metered"] .table tbody{
    display:flex;
    flex-direction:column;
    gap:12px;
  }

  body[data-page="sales"] .table tr,
  body[data-page="warehouse"] .table tr,
  body[data-page="metered"] .table tr{
    display:block;
    width:100%;
    box-sizing:border-box;
    padding:12px 14px;
    border:1px solid #e5e7eb;
    border-radius:14px;
    background:#fff;
    box-shadow:0 2px 8px rgba(0,0,0,.04);
  }

  body[data-page="sales"] .table td,
  body[data-page="warehouse"] .table td,
  body[data-page="metered"] .table td{
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    width:100%;
    box-sizing:border-box;
    padding:7px 0;
    border:0;
    font-size:14px;
    line-height:1.35;
    text-align:right;
  }

  body[data-page="sales"] .table td:not(:last-child),
  body[data-page="warehouse"] .table td:not(:last-child),
  body[data-page="metered"] .table td:not(:last-child){
    border-bottom:1px solid #f0f1f3;
  }

  body[data-page="sales"] .table td::before,
  body[data-page="warehouse"] .table td::before,
  body[data-page="metered"] .table td::before{
    content:attr(data-label);
    flex:0 0 auto;
    max-width:45%;
    color:#737b89;
    font-size:13px;
    font-weight:500;
    text-align:left;
  }

  body[data-page="sales"] .table td:last-child,
  body[data-page="warehouse"] .table td:last-child,
  body[data-page="metered"] .table td:last-child{
    display:block;
    padding-top:12px;
    border-bottom:0;
  }

  body[data-page="sales"] .table td:last-child .btn,
  body[data-page="warehouse"] .table td:last-child .btn,
  body[data-page="metered"] .table td:last-child .btn{
    width:100%;
    min-height:42px;
    border-radius:10px;
  }

  body[data-page="sales"] .table td input,
  body[data-page="warehouse"] .table td input,
  body[data-page="metered"] .table td input,
  body[data-page="sales"] .table td select,
  body[data-page="warehouse"] .table td select,
  body[data-page="metered"] .table td select{
    width:100%;
    max-width:220px;
    min-width:0;
  }

  body[data-page="sales"] .table td:first-child,
  body[data-page="warehouse"] .table td:first-child,
  body[data-page="metered"] .table td:first-child{
    padding-top:0;
  }
}
.sale-summary{display:flex;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:12px 14px;border:1px solid #e5e7eb;border-radius:12px;background:#f8fafc;font-size:14px}.sale-summary b{font-size:16px}.sale-summary span{display:flex;gap:5px;align-items:center}
@media(max-width:640px){.sale-summary{flex-direction:column;gap:8px}}
