:root{
  --tkmz-card:#ffffff;
  --tkmz-border:#d9dee5;
  --tkmz-border-strong:#c9d0d8;
  --tkmz-text:#1d2327;
  --tkmz-muted:#5f6b76;
  --tkmz-radius:14px;
  --tkmz-radius-sm:10px;
  --tkmz-shadow:0 4px 14px rgba(0,0,0,.04);
  --tkmz-primary:#2271b1;
  --tkmz-primary-hover:#135e96;
  --tkmz-success-bg:#ecfdf3;
  --tkmz-success-border:#b9ebc8;
  --tkmz-danger-bg:#fff1f1;
  --tkmz-danger-border:#f0c2c2;
  --tkmz-danger:#b42318;
}

.tkmz-front-wrap{
  max-width:1200px;
  margin:0 auto;
  padding:32px 28px;
  color:var(--tkmz-text);
  box-sizing:border-box;
  overflow-x:hidden;
}

.tkmz-front-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:16px;
  margin-bottom:24px;
}

.tkmz-front-title{
  margin:0;
  font-size:26px;
  font-weight:800;
  line-height:1.2;
}

.tkmz-front-sub{
  margin-top:6px;
  color:var(--tkmz-muted);
  font-size:14px;
}

.tkmz-front-user{
  text-align:right;
}

.tkmz-front-userline{
  font-size:13px;
  color:var(--tkmz-muted);
}

.tkmz-front-logout{
  display:inline-block;
  margin-top:6px;
  font-size:13px;
  color:#444;
  text-decoration:none;
}

.tkmz-front-logout:hover{
  text-decoration:underline;
}

.tkmz-front-card{
  background:var(--tkmz-card);
  border:1px solid var(--tkmz-border);
  border-radius:var(--tkmz-radius);
  box-shadow:var(--tkmz-shadow);
  padding:28px;
  box-sizing:border-box;
  max-width:100%;
  min-width:0;
}

.tkmz-front-card h3{
  margin:0 0 20px;
}

.tkmz-front-input,
.tkmz-front-wrap select,
.tkmz-front-wrap textarea,
.tkmz-front-wrap input[type="text"],
.tkmz-front-wrap input[type="number"],
.tkmz-front-wrap input[type="search"]{
  width:100%;
  min-height:42px;
  padding:9px 12px;
  border:1px solid var(--tkmz-border-strong);
  border-radius:var(--tkmz-radius-sm);
  box-sizing:border-box;
  font-size:15px;
  background:#fff;
  box-shadow:none;
}

.tkmz-front-input:focus,
.tkmz-front-wrap select:focus,
.tkmz-front-wrap textarea:focus,
.tkmz-front-wrap input[type="text"]:focus,
.tkmz-front-wrap input[type="number"]:focus,
.tkmz-front-wrap input[type="search"]:focus{
  outline:none;
  border-color:var(--tkmz-primary);
  box-shadow:0 0 0 1px var(--tkmz-primary);
}

.tkmz-front-hint{
  color:var(--tkmz-muted);
  font-size:13px;
  margin:10px 0 0;
}

.tkmz-btn,
.tkmz-front-wrap button:not(.tkmz-type-btn),
.tkmz-front-wrap input[type="submit"]{
  min-height:44px;
  padding:0 22px;
  border-radius:var(--tkmz-radius-sm);
  border:1px solid var(--tkmz-border-strong);
  cursor:pointer;
  background:#f6f7f9;
  color:var(--tkmz-text);
  font-size:14px;
  font-weight:600;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  box-sizing:border-box;
  text-decoration:none;
  transition:background .15s ease,border-color .15s ease,color .15s ease,opacity .15s ease;
}

.tkmz-btn:hover,
.tkmz-front-wrap button:not(.tkmz-type-btn):hover,
.tkmz-front-wrap input[type="submit"]:hover{
  background:#e9eaec;
  border-color:#b0b7bf;
  color:var(--tkmz-text);
}

.tkmz-btn:disabled,
.tkmz-front-wrap button:not(.tkmz-type-btn):disabled,
.tkmz-front-wrap input[type="submit"]:disabled{
  opacity:.55;
  cursor:not-allowed;
}

.tkmz-btn-primary{
  background:var(--tkmz-primary);
  color:#fff;
  border-color:var(--tkmz-primary);
}

.tkmz-btn-primary:hover{
  background:var(--tkmz-primary-hover);
  color:#fff;
  border-color:var(--tkmz-primary-hover);
}

.tkmz-btn-sm{
  min-height:44px;
  padding:0 14px;
  font-size:13px;
  font-weight:600;
  white-space:nowrap;
}

.tkmz-btn-danger{
  min-height:44px;
  padding:0 14px;
  font-size:13px;
  font-weight:600;
  border-color:var(--tkmz-danger);
  color:var(--tkmz-danger);
  background:#fff;
}

.tkmz-btn-danger:hover{
  background:var(--tkmz-danger);
  color:#fff;
  border-color:var(--tkmz-danger);
}

.tkmz-ops label{
  display:block;
  font-weight:600;
  margin:14px 0 6px;
  color:var(--tkmz-text);
}

.tkmz-row{
  display:flex;
  gap:14px;
  align-items:flex-end;
  margin-top:10px;
  flex-wrap:wrap;
}

.tkmz-row > div{
  min-width:180px;
  flex:0 0 auto;
}

.tkmz-row .tkmz-grow{
  flex:1 1 320px;
  min-width:260px;
}

.tkmz-actions{
  display:flex;
  gap:10px;
  margin-top:16px;
  flex-wrap:wrap;
}

.tkmz-result{
  margin-top:16px;
  padding:12px 14px;
  border-radius:var(--tkmz-radius-sm);
  border:1px solid var(--tkmz-border);
  background:#fff;
  min-height:44px;
  box-sizing:border-box;
}

.tkmz-result.is-ok{
  background:var(--tkmz-success-bg);
  border-color:var(--tkmz-success-border);
}

.tkmz-result.is-err{
  background:var(--tkmz-danger-bg);
  border-color:var(--tkmz-danger-border);
}

.tkmz-front-search{
  display:flex;
  gap:10px;
  align-items:center;
  margin:0 0 16px;
  flex-wrap:wrap;
}

.tkmz-front-search .tkmz-front-input{
  flex:1 1 320px;
  resize:none;
  overflow:hidden;
  height:42px;
  min-height:42px;
  max-height:42px;
}

.tkmz-front-tablewrap{
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
  border:1px solid var(--tkmz-border);
  border-radius:var(--tkmz-radius-sm);
  max-width:100%;
}

.tkmz-scroll-top{
  overflow-x:auto;
  overflow-y:hidden;
  height:12px;
  max-width:100%;
  border:1px solid var(--tkmz-border);
  border-bottom:none;
  border-radius:var(--tkmz-radius-sm) var(--tkmz-radius-sm) 0 0;
}

.tkmz-scroll-top-inner{
  height:1px;
  min-width:100%;
}

.tkmz-scroll-top + .tkmz-front-tablewrap{
  border-radius:0 0 var(--tkmz-radius-sm) var(--tkmz-radius-sm);
}

.tkmz-front-table{
  width:100%;
  border-collapse:collapse;
  background:#fff;
}

.tkmz-front-table th,
.tkmz-front-table td{
  padding:12px 10px;
  border-bottom:1px solid var(--tkmz-border);
  text-align:left;
  font-size:14px;
  vertical-align:middle;
}

.tkmz-front-table th{
  font-weight:700;
}

.tkmz-front-table tbody tr:last-child td{
  border-bottom:none;
}

.tkmz-low{
  background:#fff4f4;
}

.tkmz-lowtxt{
  color:var(--tkmz-danger);
  font-weight:700;
}

.tkmz-cam{
  margin-top:16px;
}

.tkmz-cam video{
  width:100%;
  max-width:520px;
  border-radius:var(--tkmz-radius-sm);
  border:1px solid var(--tkmz-border);
  display:block;
}

.tkmz-mini{
  margin-top:18px;
}

.tkmz-flash{
  position:fixed;
  inset:0;
  pointer-events:none;
  opacity:0;
  transition:opacity .15s ease;
  z-index:999999;
}

.tkmz-flash.ok{ background:rgba(0,200,0,.25); }
.tkmz-flash.err{ background:rgba(220,30,30,.25); }
.tkmz-flash.warn{ background:rgba(255,140,0,.35); }
.tkmz-flash.show{ opacity:1; }

/* LOGIN FORM */

.tkmz-front-wrap .login-username input,
.tkmz-front-wrap .login-password input{
  width:100%;
  min-height:42px;
  padding:9px 12px;
  border:1px solid #c9d0d8;
  border-radius:10px;
  box-sizing:border-box;
  font-size:15px;
  background:#fff;
}

.tkmz-front-wrap .login-username,
.tkmz-front-wrap .login-password{
  margin-bottom:14px;
}

.tkmz-front-wrap .login-remember{
  margin-bottom:14px;
}

.tkmz-front-wrap .login-submit input{
  padding:8px 16px;
  border-radius:10px;
  background:#111;
  color:#fff;
  border:0;
  cursor:pointer;
}

.tkmz-recaptcha-wrap{
  margin:16px 0 10px;
}

.tkmz-front-wrap #tkmz-loginform p{
  margin-bottom:14px;
}

.tkmz-front-wrap #tkmz-loginform label{
  display:block;
  margin:0 0 6px;
  font-weight:600;
  color:var(--tkmz-text);
}

.tkmz-front-wrap #tkmz-loginform .login-submit{
  margin-top:10px;
}

/* TOGGLE CARICO / SCARICO */

.tkmz-type-toggle{
  display:inline-flex;
  gap:0;
  border-radius:var(--tkmz-radius-sm);
  overflow:hidden;
  border:1px solid var(--tkmz-border-strong);
}

.tkmz-type-btn{
  min-height:42px;
  padding:0 20px;
  font-size:14px;
  font-weight:700;
  letter-spacing:.03em;
  cursor:pointer;
  border:none;
  border-radius:0;
  background:#f0f2f5;
  color:#5f6b76;
  transition:background .15s ease, color .15s ease;
  outline:none;
}

.tkmz-type-btn:not(:last-child){
  border-right:1px solid var(--tkmz-border-strong);
}

.tkmz-type-btn.tkmz-type-in.is-active{
  background:#16a34a;
  color:#fff;
}

.tkmz-type-btn.tkmz-type-out.is-active{
  background:#dc2626;
  color:#fff;
}

.tkmz-type-btn:hover:not(.is-active){
  background:#e2e6ea;
  color:#1d2327;
}

.tkmz-type-badge{
  display:inline-block;
  padding:6px 14px;
  border-radius:20px;
  font-size:13px;
  font-weight:700;
  letter-spacing:.02em;
}

.tkmz-badge-in{
  background:#dcfce7;
  color:#15803d;
}

.tkmz-badge-out{
  background:#fee2e2;
  color:#b91c1c;
}

/* GRID colonna singola */

.tkmz-front-grid{
  display:grid;
  grid-template-columns:1fr;
  gap:20px;
}

/* NOTICE */

.tkmz-front-notice{
  padding:12px 16px;
  border-radius:var(--tkmz-radius-sm);
  margin-bottom:16px;
  font-weight:600;
  font-size:14px;
}

.tkmz-notice-success{
  background:var(--tkmz-success-bg);
  border:1px solid var(--tkmz-success-border);
  color:#15803d;
}

.tkmz-notice-error{
  background:var(--tkmz-danger-bg);
  border:1px solid var(--tkmz-danger-border);
  color:var(--tkmz-danger);
}

/* FORM PRODOTTO */

.tkmz-prod-form .tkmz-form-fields{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.tkmz-form-row{
  display:flex;
  gap:14px;
  align-items:flex-start;
}

.tkmz-form-col{
  display:flex;
  flex-direction:column;
  min-width:0;
}

.tkmz-form-col label:first-child{
  display:block;
  font-weight:600;
  margin-bottom:6px;
  color:var(--tkmz-text);
}

.tkmz-form-col input,
.tkmz-form-col select{
  width:100%;
  box-sizing:border-box;
}

.tkmz-required{
  color:var(--tkmz-danger);
}

.tkmz-check-label{
  display:inline-flex !important;
  align-items:center;
  gap:8px;
  font-weight:400 !important;
  margin-top:4px;
  cursor:pointer;
}

.tkmz-prod-actions{
  white-space:nowrap;
}

.tkmz-prod-actions form{
  display:inline;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width:900px){
  .tkmz-front-head{
    flex-direction:column;
    align-items:flex-start;
  }

  .tkmz-front-user{
    text-align:left;
  }

  .tkmz-front-grid{
    grid-template-columns:1fr;
  }

  .tkmz-row > div,
  .tkmz-row .tkmz-grow{
    width:100%;
    min-width:100%;
    flex:1 1 100%;
  }

  .tkmz-actions{
    flex-direction:column;
    align-items:stretch;
  }

  .tkmz-actions .tkmz-btn{
    width:100%;
  }
}

@media (max-width:768px){
  .tkmz-front-wrap{
    padding:16px 14px;
  }

  .tkmz-front-title{
    font-size:22px;
  }

  .tkmz-front-sub{
    font-size:13px;
  }

  .tkmz-front-card{
    padding:18px 14px;
    border-radius:12px;
    width:100%;
    box-sizing:border-box;
  }

  .tkmz-front-table th,
  .tkmz-front-table td{
    padding:10px 8px;
    font-size:13px;
    white-space:nowrap;
  }

  .tkmz-front-search{
    flex-direction:column;
    align-items:stretch;
  }

  .tkmz-front-search .tkmz-front-input,
  .tkmz-front-search input[type="text"],
  .tkmz-front-search input[type="search"]{
    width:100%;
    height:42px;
    min-height:42px;
    max-height:42px;
  }

  .tkmz-front-search .tkmz-btn{
    width:100%;
  }

  .tkmz-form-row{
    flex-direction:column;
    gap:0;
  }

  .tkmz-form-col{
    width:100% !important;
    flex:1 1 100% !important;
    margin-bottom:14px;
  }

  .tkmz-prod-actions{
    display:flex;
    gap:6px;
    flex-wrap:nowrap;
  }

  .tkmz-prod-actions .tkmz-btn{
    flex:1;
    white-space:nowrap;
    min-width:72px;
    padding:0 10px;
    font-size:12px;
  }

  .tkmz-front-wrap .login-submit input{
    width:100%;
    min-height:42px;
  }

  .tkmz-recaptcha-wrap .g-recaptcha{
    transform-origin:left top;
  }
}

@media (max-width:420px){
  .tkmz-front-wrap{
    padding:12px 10px;
  }

  .tkmz-front-title{
    font-size:20px;
  }

  .tkmz-front-card{
    padding:14px 12px;
  }

  .tkmz-result{
    padding:10px 12px;
    font-size:14px;
  }

  .tkmz-actions{
    gap:8px;
  }

  .tkmz-btn,
  .tkmz-front-wrap button:not(.tkmz-type-btn),
  .tkmz-front-wrap input[type="submit"]{
    width:100%;
  }

  .tkmz-recaptcha-wrap .g-recaptcha{
    transform:scale(0.92);
  }
}

/* =============================================
   MENU SHORTCUT (sopra i moduli)
   ============================================= */
.tkmz-shortcut-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0 4px;
  margin-bottom: 4px;
}

.tkmz-shortcut-btn {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px;
  background: #e8f1ee;
  border: 2px solid #225d4b;
  border-radius: 8px;
  color: #225d4b;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.tkmz-shortcut-btn:hover {
  background: #225d4b !important;
  border-color: #225d4b !important;
  color: #fff !important;
  text-decoration: none !important;
}

.tkmz-shortcut-btn.is-active {
  background: #225d4b !important;
  border-color: #225d4b !important;
  color: #fff !important;
}

/* =============================================
   PULSANTE FULLSCREEN
   ============================================= */
.tkmz-btn-fs {
  background: #1e293b;
  color: #f8fafc;
  border: none;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.tkmz-btn-fs:hover { background: #334155; }
.tkmz-btn-fs.is-fullscreen { background: #dc2626; }

/* =============================================
   AUTOCOMPLETE DROPDOWN
   ============================================= */
.tkmz-ac-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #fff;
  border: 1px solid #d1d5db;
  border-top: none;
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  max-height: 280px;
  overflow-y: auto;
}

.tkmz-ac-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  border-bottom: 1px solid #f3f4f6;
  transition: background .1s;
}
.tkmz-ac-item:last-child { border-bottom: none; }
.tkmz-ac-item:hover { background: #f0f4ff; }

.tkmz-ac-item strong { flex: 1; color: #111827; }

.tkmz-ac-code {
  font-family: monospace;
  font-size: 12px;
  color: #6b7280;
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
}

.tkmz-ac-stock {
  font-size: 12px;
  color: #059669;
  font-weight: 600;
}

.tkmz-ac-empty {
  color: #9ca3af;
  font-style: italic;
  cursor: default;
}

.tkmz-ac-empty:hover { background: #fff; }

/* =============================================
   BARRA FILTRI CON SELECT PER PAGINA
   ============================================= */
.tkmz-search-filterbar {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 8px !important;
  align-items: center !important;
  margin-bottom: 8px !important;
  width: 100% !important;
}

.tkmz-search-input {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  width: auto !important;
}

.tkmz-front-select {
  width: auto !important;
  max-width: 130px !important;
  flex: 0 0 auto !important;
  height: 42px !important;
  padding: 0 10px !important;
  border: 1.5px solid #d1d5db !important;
  border-radius: 8px !important;
  background: #fff !important;
  font-size: 14px !important;
  color: #374151 !important;
  cursor: pointer !important;
  display: inline-block !important;
  box-sizing: border-box !important;
}

.tkmz-front-select:focus {
  outline: none !important;
  border-color: #6366f1 !important;
}

/* =============================================
   PAGINAZIONE FRONTEND CON NUMERI PAGINA
   ============================================= */
.tkmz-pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.tkmz-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  line-height: 1;
}

.tkmz-page-btn:hover {
  background: #f0f4ff;
  border-color: #6366f1;
  color: #6366f1;
  text-decoration: none;
}

.tkmz-page-btn.is-active {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
  font-weight: 700;
  pointer-events: none;
}

.tkmz-page-btn.is-disabled {
  opacity: .38;
  pointer-events: none;
}

.tkmz-page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 36px;
  color: #9ca3af;
  font-size: 14px;
}

.tkmz-pagination-info {
  margin-left: 6px;
  font-size: 13px;
  color: #6b7280;
}

/* =============================================
   OPERAZIONI: CODICE + CERCA NOME AFFIANCATI
   ============================================= */
.tkmz-ops-search-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tkmz-ops-search-col {
  flex: 1;
  min-width: 200px;
}

.tkmz-ops-search-col label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: #374151;
  margin-bottom: 6px;
}

/* Forza stile identico a tkmz_code sul campo ricerca nome */
#tkmz_name_search {
  width: 100% !important;
  min-height: 42px !important;
  padding: 9px 12px !important;
  border: 1px solid var(--tkmz-border-strong) !important;
  border-radius: var(--tkmz-radius-sm) !important;
  box-sizing: border-box !important;
  font-size: 15px !important;
  background: #fff !important;
  box-shadow: none !important;
  outline: none !important;
}
#tkmz_name_search:focus {
  border-color: var(--tkmz-primary) !important;
  box-shadow: 0 0 0 1px var(--tkmz-primary) !important;
}
